I've got a problem connecting to a Modbus device using the Modbus Getter modules of node-red-contrib-modbus https://github.com/BiancoRoyal/node-red-contrib-modbus
I have tested the device with a USB RS485 interface to confirm that the device works and the comms settings are correct. On the RPi I am using the serial port through a RS485 HAT by Sequent Microsystems https://sequentmicrosystems.com/products/industrial-raspberry-pi
Frustratingly, I actually had this working, but had to swap out the RPi and now it's not connecting.
Here's my flow:
[{"id":"99d353920c8761df","type":"modbus-getter","z":"e1a2a3efb3ac0e30","name":"","showStatusActivities":false,"showErrors":true,"logIOActivities":false,"unitid":"1","dataType":"HoldingRegister","adr":"104","quantity":"2","server":"57ec3042daf1c12f","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":false,"x":420,"y":260,"wires":[["a0b674413829da6e"],["77f76722937b798d"]]},{"id":"5e887a415d1cd97a","type":"inject","z":"e1a2a3efb3ac0e30","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":260,"wires":[["99d353920c8761df"]]},{"id":"a0b674413829da6e","type":"debug","z":"e1a2a3efb3ac0e30","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":220,"wires":[]},{"id":"77f76722937b798d","type":"modbus-response","z":"e1a2a3efb3ac0e30","name":"","registerShowMax":20,"x":650,"y":300,"wires":[]},{"id":"57ec3042daf1c12f","type":"modbus-client","name":"","clienttype":"serial","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/serial0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]
And here is the debug output using:
DEBUG=contribModbus:read*,contribModbus:core:client,modbus-serial,serial node-red -v
Welcome to Node-RED
===================
3 Oct 12:16:49 - [info] Node-RED version: v2.0.6
3 Oct 12:16:49 - [info] Node.js version: v12.22.1
3 Oct 12:16:49 - [info] Linux 5.10.17-v7+ arm LE
3 Oct 12:16:50 - [info] Loading palette nodes
3 Oct 12:16:55 - [info] Dashboard version 2.30.0 started at /ui
3 Oct 12:16:55 - [info] Settings file : /home/pi/.node-red/settings.js
3 Oct 12:16:55 - [info] HTTP Static : /home/pi/node-red-static
3 Oct 12:16:55 - [info] Context store : 'default' [module=memory]
3 Oct 12:16:55 - [info] Context store : 'persistent' [module=localfilesystem]
3 Oct 12:16:55 - [info] User directory : /home/pi/.node-red
3 Oct 12:16:55 - [info] Projects directory: /home/pi/.node-red/projects
3 Oct 12:16:55 - [info] Server now running at http://127.0.0.1:1880/admin/
3 Oct 12:16:55 - [info] Active project : LouvreController
3 Oct 12:16:55 - [info] Flows file : /home/pi/.node-red/projects/LouvreController/flows_louvrecontroller.json
3 Oct 12:16:55 - [info] +-----------------------------------------------------
3 Oct 12:16:55 - [info] | uibuilder v4.1.1 initialised
3 Oct 12:16:55 - [info] | root folder: /home/pi/.node-red/projects/LouvreController/uibuilder
3 Oct 12:16:55 - [info] | Using Node-RED's webserver at:
3 Oct 12:16:55 - [info] | http://127.0.1.1:1880/ or http://localhost:1880/
3 Oct 12:16:55 - [info] | Installed packages:
3 Oct 12:16:55 - [info] | jquery, socket.io, vue, bootstrap
3 Oct 12:16:55 - [info] | bootstrap-vue
3 Oct 12:16:55 - [info] +-----------------------------------------------------
3 Oct 12:16:56 - [info] Starting flows
contribModbus:core:client Client -> initialized +0ms
3 Oct 12:16:56 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm init state after new
3 Oct 12:16:56 - [warn] [modbus-client:57ec3042daf1c12f] Client -> first fsm init in 500 ms Serial@/dev/serial0:9600bit/s default Unit-Id: 1
3 Oct 12:16:56 - [info] Started flows
3 Oct 12:16:56 - [info] [inject:65de767577e91594] repeat = 300000
contribModbus:core:client Client -> RTU buffered port serial Serial@/dev/serial0:9600bit/s default Unit-Id: 1 +829ms
contribModbus:core:client Client -> time to open Unit 1 Serial@/dev/serial0:9600bit/s default Unit-Id: 1 +120ms
modbus-serial modbus connection opened +0ms
3 Oct 12:16:57 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm connected after state opened Get More About It By Logging Serial@/dev/serial0:9600bit/s default Unit-Id: 1
3 Oct 12:16:57 - [info] [inject:Every 2 min] repeat = 120000
3 Oct 12:16:57 - [info] [inject:Every 1 Sec] repeat = 1000
3 Oct 12:16:57 - [info] [inject:Every 30 Seconds] repeat = 120000
modbus-serial {
modbus-serial action: 'send serial rtu buffered',
modbus-serial data: <Buffer 01 03 00 68 00 02 45 d7>,
modbus-serial unitid: 1,
modbus-serial functionCode: 3,
modbus-serial length: 9
modbus-serial } +0ms
modbus-serial modbusErrorHandling:Timed out +15s
3 Oct 12:17:12 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm failed state after sending Get More About It By Logging Serial@/dev/serial0:9600bit/s default Unit-Id: 1
3 Oct 12:17:12 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm broken state after failed Get More About It By Logging Serial@/dev/serial0:9600bit/s default Unit-Id: 1
3 Oct 12:17:12 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm reconnect state after broken Get More About It By Logging Serial@/dev/serial0:9600bit/s default Unit-Id: 1
3 Oct 12:17:14 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm init state after reconnecting Serial@/dev/serial0:9600bit/s default Unit-Id: 1
3 Oct 12:17:14 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm init in 2000 ms Serial@/dev/serial0:9600bit/s default Unit-Id: 1
contribModbus:core:client Client -> connection close sent Serial@/dev/serial0:9600bit/s default Unit-Id: 1 +19s
contribModbus:core:client Client -> RTU buffered port serial Serial@/dev/serial0:9600bit/s default Unit-Id: 1 +2ms
contribModbus:core:client Client -> connection closed Serial@/dev/serial0:9600bit/s default Unit-Id: 1 +6ms
contribModbus:core:client Client -> time to open Unit 1 Serial@/dev/serial0:9600bit/s default Unit-Id: 1 +103ms
modbus-serial modbus connection opened +4s
3 Oct 12:17:16 - [warn] [modbus-client:57ec3042daf1c12f] Client -> fsm connected after state opened Get More About It By Logging Serial@/dev/serial0:9600bit/s default Unit-Id: 1
I'm assuming the problem is
modbus-serial modbusErrorHandling:Timed out
I have ensured that /dev/serial0 is not being used by the console by removing “console=serial0,115200” from /boot/cmdline.txt.
Is there any way to get any further level of debug info? The debug message says "Get More About It By Logging Serial@/dev/serial0:9600" but I'm not sure how to do that.
Cheers for any suggestions!
Peter