Raspberry Pi, Zigbee and RS485 Wire Replacement

In applications that use RS485 and Raspberry Pi's, sometimes it is not always convenient to run wires from the controller out to the application hardware. Using two Zigbee modules as a "Wire Replacement" can be the answer you are looking for.


The devices used in this example are:

  • Raspberry Pi as the controller
  • Raspberry Pi wireless shield
  • Wireless Zigbee to RS485 converter
  • RS485 field module, in this example an 8 point relay module
  • Zigbee Module (Pro Series S2B) as Co-ordinator (AT)
  • Zigbee Module (Pro Series S2B) as Router (AT)

For the test software, the RPi is sending relay info as Modbus RTU to the Zigbee module attached via the shield. The zigbee module transmits to the receiver Zigbee module attached to the wireless to RS485 converter module, which in turn communicates with the relay module.

When using this kind of setup, here are a few things to watch out for:

  • Make sure the baud rates match up with Zigbee modules, the RPi serial port, and the field devices. This example has been tested with both 9600 and 19200 Baud, the most common baud rates for wired RS485 field installations
  • When programming the Zigbee modules, use a larger Packetization Timeout value (Serial Interfacing AT Command "RO"). The above example uses a value of 10
  • Most Modbus field devices require a bit of time to switch from "Receive" mode to "Transmit" mode and back. Even if data is just being written to a device as in  this example, the device will send an Acknowledgement. Leave enough time to receive data before moving on to the next step in your program, otherwise the Ack data sent by the field device will corrupt the transmit data sent by the controller.
  • When using Zigbee modules, there is a time delay in allowing the Zigbee modules to sync, transmit, and receive. Again, leave enough receive time for the communication to take place. In the above example, there is no CTS handshaking and the time delays used are 200 mSec per transmission for reliable communication.

The Wireless to RS485 converter module uses an automatic switch to detect when in transmit mode to switch the RS485 driver IC from Receive to Transmit. This circuit is based on a 555 timer chip, and has reliable operation at 9600 and 19200 Baud.

Distance between the Zigbee modules depends on the type of application (outdoor vs indoor) and the series of modules used - regular Series 2 or the PRO version.

We will be doing some testing with the 900 MHz version of these modules (PRO S3B) in the near future and will post the results as soon as we have them!



Leave a comment

Please note, comments must be approved before they are published