Best way to connect multiple tasmota devices over RS485

1,245 views
Skip to first unread message

Dirk Eisner

unread,
Oct 4, 2023, 4:06:08 AM10/4/23
to TasmotaUsers
I have an application where need to communicate with multiple ESP32 devices which I would like to connect is serial configuration. This is for an agricultural application. The devices are spaced about 100m (300 feet) from each other. I would like to connect them with only one twisted pair, similar setup to rs485. I want to send MQTT messages over that pair which are by the last ESP in the chain then send over Wi-fi into the Ethernet.
The maximum number of ESP's connected to one master is 10 .

I'm aware of a new 2 wire ethernet standard, but this is early days and maybe a little outside of my capability.

Any help would be greatly appriciated.

Regards


Justin Adie

unread,
Oct 4, 2023, 4:34:54 AM10/4/23
to Dirk Eisner, TasmotaUsers
Any reason not to use rs485?  Modbus rtu as a protocol is robust.  Easy to implement and bridge to mosquito.





--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/de5001e8-02bd-4867-ba41-6c6d045f640cn%40googlegroups.com.

benjam...@t-online.de

unread,
Oct 4, 2023, 4:45:29 AM10/4/23
to TasmotaUsers
The reason here seems to be distance. RS485 spans 1200 Meters at best. (Good old current loop was 2000 meters). Ethernet spans 100 meters from switch to switch. WIFI is even worse.
So when the devices are 100 meters apart, IMHO RS485 is first choice.

Philip Knowles

unread,
Oct 4, 2023, 4:58:32 AM10/4/23
to Dirk Eisner, TasmotaUsers

It might be worth looking at LoRa

 

What are LoRa and LoRaWAN? | The Things Network

 

Sent from Mail for Windows

--

Dirk Eisner

unread,
Oct 4, 2023, 7:16:53 AM10/4/23
to Philip Knowles, TasmotaUsers
Thanks for your reply, I have been building LoRaWAN networks professionaly for several years, and you are absolutely right with your suggestion. The problem is I can't use any wireless system as this system is 40 cm deep in the soil. And large machines drive over it. I have an ethernet cable supplying power to the devices ( 3 pairs) and I have one pair left for comms. What I'm looking for is to establish a  comms connection. If I have a RS485 to TTL controller can I some how talk to the comms interface on the esp32. It's a bit like talking to modbus RTU as the master but instead of requesting coils or registers talking to the serial interface of the ESP32. Maybe that works some how?

Dirk Eisner

unread,
Oct 4, 2023, 8:32:18 AM10/4/23
to benjam...@t-online.de, TasmotaUsers
Thanks for your reply, there is a good possibility I just don't understand how this can work. O have used traditional PLCs before where an application queries coils and register. 
If I would use a RS485 to TTL Modbus converter how do I talk to the RX TX on my tasmota ESP 32?
How do I address the right device? 

I'm sure that is possible...some how? But I can't find any documentation on that. 

Thanks for all your help and time. 

You received this message because you are subscribed to a topic in the Google Groups "TasmotaUsers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonoffusers/MBRPFNP3YLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/56cb0761-b34f-4afe-996f-b86b8708b594n%40googlegroups.com.

Philip Knowles

unread,
Oct 4, 2023, 10:43:44 AM10/4/23
to Dirk Eisner, benjam...@t-online.de, TasmotaUsers

With MODBus each slave has an address and the first byte of the message is its address. Like this for the PZEM

Tasmota has a MODBus bridge driver but there’s an Espressif version

esp-idf/examples/protocols/modbus/serial/mb_slave at master · espressif/esp-idf (github.com)

Sent from Mail for Windows

 

Khurram

unread,
Oct 4, 2023, 2:53:51 PM10/4/23
to TasmotaUsers
For what its worth, there is another option which requires significant changes to your setup. You can opt for coaxial based ethernet with its bus topology (serial like modbus) which will give you 500 m length from end to end. You would also have to change the ESP32+tasmota to something else like an arduino+ethernet shield + its software. It might be worth the effort if you can source the cable and connectors.

benjam...@t-online.de

unread,
Oct 4, 2023, 3:12:04 PM10/4/23
to TasmotaUsers
Another option: Since converters are needed anyway, you could use daisy chained fibre to Ethernet converters and ESP32's with cable Ethernet connectors. This way you have full access to the device.

Andrew L

unread,
Oct 5, 2023, 3:15:22 AM10/5/23
to TasmotaUsers
Not sure tasmota has that ability right now.  I suggested it to gemu2015 to include in scripting, since I think it would not be too difficult to add logic for defining an array in scripting with slave ID and whatever registers you want, and then it can respond to requests where slaveID matches. Would be very useful to allow long-distance two-wire communication between devices. With scripting, it's not hard to then publish data via MQTT 

benjam...@t-online.de

unread,
Oct 5, 2023, 3:26:37 AM10/5/23
to TasmotaUsers
SInce the devices are buried under ground, how do they connect to the internet? Wifi will not work. For Tasmota to work propperly, you need a time server and a MQTT broker. This you don't have over serial connection.
So either coax or fibre are the way to go.  

Andrew L

unread,
Oct 5, 2023, 4:29:42 AM10/5/23
to TasmotaUsers
See response from gemu.  Should be possible to do already. Will take some work adapting the script to your needs, but seems like a complete example.

Dirk Eisner

unread,
Oct 5, 2023, 4:32:26 AM10/5/23
to TasmotaUsers
The last device is above ground and will have WiFi. I have done some more research and think I will need to implement Modbus and make the downstream units Modbus RTU and the first unit Modbus Master.
I have never implemented that and I don't know if I can do this with Tasmota. It will need to do more research. I would be glad to hear of it if anyone has done such an implementation. I chose Tasmota as it is very flexible and has many powerful option and is stable. I may need to do a custom C++ development. :-( . In time to come, I hope that the new 2-wire ethernet standard will become more affordable as it would be the ideal solution for my problem at hand. I'm convinced it will eventually replace Modbus.
This is the basic config

Mbus Master and WiFi ---------------------Mbus RTU--------------------Mbus RTU-----------------Mbus RTU-------------Mbus RTU--------------------Mbus RTU-----------------Mbus RTU


In case you are interested in what this is all about? we trying to get biometric information on the biological effect of crops, water, and fertilizer on the deeper-laying soil. Deploying highly sensitive microphones, temperature, moisture sensors, and devices to measure soil compaction, salinity, and other chemical changes.  


Cheers

Dirk Eisner

unread,
Oct 5, 2023, 4:46:35 AM10/5/23
to TasmotaUsers
This looks very promising. All I have to do now is learn to script in Tasmota :-)

Thank you will give this a go.

See the response from gemu.  Should be possible to do already. Will take some work to adapt the script to your needs, but seems like a complete example.


On Thursday, 5 October 2023 at 19:29:42 UTC+11 pkkr...@gmail.com wrote:

Andrew L

unread,
Oct 5, 2023, 4:55:50 AM10/5/23
to TasmotaUsers
Yeah, scripting takes a while to grok. But is very flexible once you get it. However, takes a lot of ram if you use it and a bunch of sensors. You get pretty close to the limit on esp8266. ESP32 would be better choice if you can afford the extra $1 per unit. :-)

Radovan Kadlic

unread,
Oct 5, 2023, 7:22:56 AM10/5/23
to TasmotaUsers
Regarding communication over wire, with low bitrate, I have quite good results with CAN at 9600 bit/s. All devices can send message at one, similar to ethernet on coaxial cable. I have aprox 200m bus and it works.



--
Radovan Kadlic

Andrew Russell

unread,
Oct 5, 2023, 11:01:12 AM10/5/23
to Dirk Eisner, TasmotaUsers
>>>  All I have to do now is learn to script in Tasmota :-)
I highly recommend Tasmota on ESP32. That gives you the Berry language which is pretty much like other languages you may be familiar with. Not a steep learning curve.

Reply all
Reply to author
Forward
0 new messages