Modbus serial with Node-RED

This provides a simple example of using the Rio to read Modbus data using serial Modbus RTU.

OVERVIEW

The Modbus device is connected to the Rio USB port through a RS232 to USB Adapter. A small NodeRed flow reads the Modbus registers.
image

USB

The RS232 to USB Adapter is a Belkin Model: F5U409.

The Rio is good at recognizing various USB adapters, so this specific model is probably not necessary. Here are a few others: RS232 and RS485 SERIAL ADAPTERS FOR RIO
Gearmo Model: GM-FTDI-A12
Sabrent USB to Serial converter
Aluratek Model: AUS100

Verify the adapter is recognized by the Rio using groovManage: System, then Serial Devices.

You should show a serial device similar to below. The device name displayed, /dev/ttySer0 , will be entered into Nodered as a serial device.
image
NODERED

Using Nodered Manage Palette, install the node-red-contrib-serial-modbus node.

Place a modbusSerialIN node and a debug node of the flow and connect them.
image

Double click the Modbus node, and click the pencil icon next to the Port setting, to add a serial device.

Enter the properties for the serial device and click Update.
image

Enter the Modbus register settings into the Modbus node. This example reads the first 3 holding registers. Click Done.
image

Click Deploy to send the flow to the Rio. Click the Debug Messages Icon to see the output of the Modbus node, which shows the holding register values.
image

Here is the NodeRed Flow.

[{"id":"a11d31ab.f68ac","type":"tab","label":"Modbus Serial","disabled":false,"info":""},{"id":"f509d4a.9024528","type":"modbusSerial in","z":"a11d31ab.f68ac","port":"3e468e22.842a02","slaves":"1","start":"1","count":"3","dtype":"holding","period":"10","topic":"","name":"Read Holding Regs 1-3","x":200,"y":200,"wires":[["aeb3845a.ae6e38"]]},{"id":"aeb3845a.ae6e38","type":"debug","z":"a11d31ab.f68ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":410,"y":200,"wires":[]},{"id":"3e468e22.842a02","type":"modbusSerialConfig","z":"","port":"/dev/ttySer0","baud":"19200","data":"8","parity":"none","stop":"1","name":""}]

MODBUS SLAVE SIMULATOR

I cheated a bit since I did not have a real Modbus Serial RTU device available.

A utility called Simply Modbus Slave was used on the PC to simulate the Modbus device.
image

MODBUS SERIAL ON RIO WITH NODERED.zip (180.3 KB)

6 Likes

Nice Post! Thanks for all the good info.

21 posts were split to a new topic: Troubleshooting Node-RED Modbus issues

A post was merged into an existing topic: Troubleshooting Node-RED Modbus issues