I have to build a sensor network which communicates over a single RS485 bus. The network could have tens of nodes. The problem is that I have to control access to the shared bus and find a way to address each node, similar to TCP/IP. Each sensor (when it is triggered) can send data asynchronously to the server.

Is there a protocol available for a RS485 network? If so, is it free? The protocol would be implemented in a microcontroller.

Can I use a controller with TCP/IP stack?

Has anybody designed such a network? I am curious if my approach is correct in order to know if it's OK to continue on this path or if I have to switch to a different techology.

  • 1
    \$\begingroup\$ There are lots of protocols in use - grab a manual for something that speaks RS845 in a shared setting. Typically a master sends out the address of who it wants to talk to, and only that node may reply only then. But a more peer to peer scheme with collision detection and random backoff could be possible. \$\endgroup\$ – Chris Stratton Oct 18 '17 at 8:06
  • 2
    \$\begingroup\$ TCP/IP does not control shared bus access; this is done by a lower protocol. \$\endgroup\$ – CL. Oct 18 '17 at 8:37
  • \$\begingroup\$ @ChrisStratton I my case the sensors communicate with a server and each sensor (when it is triggered) can send data asynchronously to the server. \$\endgroup\$ – Cristian M Oct 18 '17 at 9:04
  • 1
    \$\begingroup\$ Go for modbus. 1234567890 \$\endgroup\$ – Gregory Kornblum Oct 18 '17 at 9:18
  • 1
    \$\begingroup\$ Many free-to-use protocols are listed at en.wikibooks.org/wiki/Embedded_Systems/Common_Protocols ; most of them would work on RS485 physical link hardware. \$\endgroup\$ – davidcary Feb 24 '18 at 18:35

I have made a demo about transfer TCP/IP through RS485: https://github.com/dukelec/cdbus_doc

The protocol on RS485 is CDBUS, which could use a standalone controller to solve the collision problem, you can also implement CDBUS protocol by software, or simply don't take care about collision, re-sent packet when data lost was detected.
The CDBUS protocol: https://github.com/dukelec/cdbus_ip

The upon protocol is CDNET, is similar to UDP protocol, you can send UDP packet from MCU by only few line of codes and without any library, but need a gateway to translate CDNET to real TCP/IP protocol. Or you can define your own protocol, and translate them on the gateway.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.