RS485 | Node Network

Sensor-NetworkI’m a huge fan of Arduino, JeeNode, ESP8266. A few of them connected in a network is one of the best solutions to distribute sensors data, relays command and status, LCDs and so on. But what should we use for networking the nodes? Wifi is built into the ESP8266 so that’s a no-brainer. JeeNode has an RF12b working on 868Mhz, but what if you don’t want to use wireless? What if you want to use wired sensors and supply power to them over the same wire? I have looked at RS232 and Ethernet. RS232 is low cost but in its standard form best suited for point to point connections. Ethernet is much better, Ethernet Cards and libraries are easily available for the Arduino. Cost wise, it’s not the best solution, though.

RS485-shieldEnter stage left, RS485? It’s being used for DMX and Modbus and used in Industrial and medical environments so it will certainly be enough for a Home Node network.

Using an RS485 or DMX shield or even an MAX485 IC makes it easy to add RS485 to a project. But RS485 only describes the physical layer, not the protocol used. So in search of a suitable protocol I’m looked at Modbus, JeeNode’s protocol, XAP, XPL, and others. What I wanted to do is pre-define the data in a standard C Type Definition. A typedef may be used to simplify the declaration of a compound type (struct, union) or pointer type. For example:

struct MyStruct {
int data1;
char data2;
};

This is also used a lot in JeeNode sketches I came across and I have been using it ever since. The only thing missing was a header, checksum, and end of a transmission. Enter stage right Inter-Chip Serial Communications. It turned out the be the missing part needed to encode and decode the data into usable data packets. Using the RS485 hardware and Inter-Chip Serial library I build myself a reliable RS485 Sensor network. I also hacked together a version that works with SoftwareSerial. At the moment the network consists of:

It also supplies 12v power to the MQTT OneWire Weather Station and MQTT Light Sensor using the DMX512 wiring standard.

RJ45-Pinout

  • Pin 1 | RS485 Data +
  • Pin 2 | RS485 Data –
  • Pin 3 | N/C
  • Pin 4 |+12v
  • Pin 5 |+12v
  • Pin 6 | N/C
  • Pin 7 | GND
  • Pin 8 | GND

IMG_1583

On my RJ45 patch panel, I have made a patchable RS485 bus.

IMG_1584Simply by connecting all the same colored pins together.

Leave a Reply

Your email address will not be published. Required fields are marked *