Don't forget the ground wire, and serial is now /dev/serial0

steelhead

New member
Here are my notes for setting up the Sequent industrial automation hat with raspi 3b+ running latest raspian, to communicate over the serial port via modbus-RTU.

make your user a member of the 'dialout' group, sudo usermod -a -G dialout pi

and grant ownership of /dev/serial (Raspian Bookworm). Do this on the pi, and on your linux laptop.

Clone and build the modbus-sniffer program https://github.com/alerighi/modbus-sniffer

Wire the sequent industrial board to the modbus slave, and daisy-chain to a USB-RS485 converter using FTDI chip, plugged to the linux laptop. Don't forget to connect a ground wire from the sequent board RS485 connector to the negative terminal of the slave power supply. The FTDI is not sensitive to floating inputs but the raspi/sequent board is and will not receive reliably without it, and you will see characters to the sniffer that raspi misses.

open a terminal and navigate to this directory. If capture.pcap doesn't exist then touch capture.pcap. Run:

./sniffer -o capture.pcap -p /dev/ttyUSB0 -l -t 2000

output should look something like this:

captured packet 53: length = 11, CRC: 89D4 = 89D4 [OK]
DUMP: 05 10 00 01 00 01 02 00 1F D4 89
captured packet 54: length = 8, CRC: 8D51 = 8D51 [OK]
DUMP: 05 10 00 01 00 01 51 8D
captured packet 55: length = 8, CRC: 58A4 = 58A4 [OK]
DUMP: 05 03 00 52 00 0B A4 58
captured packet 56: length = 27, CRC: 5520 = 5520 [OK]
DUMP: 05 03 16 00 00 41 98 D9 C1 42 B0 31 E5 41 02 CE 31 41 02 CE 31 00 00 00 00 20 55

with all CRC's OK and each packet has a payload and no error messages. -t parameter too short and wires reversed caused problems.

follow this video "Decoding Modbus RTU Captures in Wireshark"

In wireshark, go to Edit > Preferences > Protocols > DLT_USER Add a payload dissector and enter 'mbrtu'. Open the capture.pcap file and packets should appear parsed as modbus.

node-red-contrib-modbus did not work for me. These nodes return errors unless the packets are structured exactly to the modbus standard, and the sensor i am using included proprietary commands, which were quickly discovered by the magical wireshark. I used the serial-request node successfully.
 

alexburcea

Administrator
Staff member
Hi,

Thank you for shering your experience. We tested the Modbus implementation with a PC program called qModMaster and in Python using the pymodbus library, but we will try to accommodate Node-Red as well.

Alex
 
Top