Troubleshooting Node-RED Modbus issues

Great information on getting the Modbus data into Node-Red. In my case, when I used a Modbus scanner like CAS Modbus Scanner, I got the following:


which correctly showed the value I was after (1143).
However, when I read the same data in Node-RED using the method outlined above, I got the following:

I have since learned that (for my particular device, which is an atmosphere controller) Node-Red is outputting as 16 bit registers, but the debug is showing each byte as decimal. So the first number has ms byte 4 and ls byte 119, which is 4*256 + 119 = 1143 which is exactly what was expected. This node will help do the conversion.

1 Like

I have discovered an issue whereby I am getting a “Timed Out” message after about 10-12 hours of readings (taken every 30 sec). It happens regardless of the controller that I am reading from. When I redeploy, it works fine again (like it is waiting to be “manually” restarted). My solution would be to put an Inject node that runs whenever a Timed Out message is detected , but where can I put an Inject Node if there are no wire connections on the Modbus Serial In node? See my flow below which shows the message I get on one of the controllers (again, it happens on the other one, but it not depicted here).

Very odd error… And after 10-12 hours. Phew, this is going to be ‘fun’ to debug…

Is this on a RIO?
Is it using a USB to Serial adapter? If so, are you using a USB hub?

What does the Node-RED log show? Often there is more information in the log than in the debug tab.

It’s running on a Raspberry Pi with this adapter. If I had a Rio, I would hook it up and try it with that. We have an EPIC that I could use next week, but not sure if the above USB adapter will play nice with the EPIC.

Huh, never seen an adapter in that form factor before. But yeah, I don’t think the EPIC is going to like it, seem like its not FTDI compatible or even using that chip set. Might work on RIO as it is more flexible in what USB to serial converters it will work with (but we still highly recommend FTDI).

That aside, I would still be checking the Node-RED console log to see if there is any other helpful error reporting.

Not to get too deep into the weeds here, but my Error Log (shown by following the path below) does not have any information whatsoever. Is this something that needs to be turned on?
EventLogNodeRed

Yeah, the event log will be blank. I mean the console log.
Where you start Node-RED, that will show whats really going on blow-by-blow.

Thank you. I will check that out and report back what I find.

Returning to the subject of modbus serial with Node-RED using a USB-to-RS485 adapter plugged into the Rio (or EPIC), we have been successful in getting modbus data using node-red-contrib-serial-modbus
image

using these settings:


image

But since the above node has not been touched by the creator in over 2 years, I wanted to try the suite of modbus nodes in node-red-contrib-modbus:

specifically, the Modbus Read node is not able to connect

Here is how I have it configured:

I do not think it matters, but I do have the same node running successfully on another flow, but that is using Modbus TCP (whereas the above is using Modbus RTU).
image

Does anyone here have a working flow of the above node (Modbus Read) working with a Rio or EPIC? If yes, can you post your settings?

Hi @grant1 I am using those nodes with a USB to serial adapter on an EPIC to read a ModbusRTU power meter (Wattnode).

Here is how I have it configured:

I am surprised that you don’t have a Unit-ID here in this config.
I might be wrong in needing to have the Unit-ID in both locations, but I did find that you need it where you don’t have it.

The next config is thus:

They look pretty good. I don’t think selecting RTU-Buffered is a make or break thing.

Hope that helps.

Thanks Ben. The slave address of my device is 11, so I set that as the Unit-Id on both settings screens. I know they mention ‘1’ and ‘set to empty’ in the Help, but I tried that as well.

Also, while you are using an EPIC and I am using a Rio, I noticed a few differences. I changed them both to match yours, and still no change in my debug pane.

#1: you are outputting the message from the second output (whereas I am outputting from the first output) of the modbus read node
#2: our serial port paths are different. Yours is /dev/ttyUSB0 and mine is /dev/ttySer0.

I think I got it. While setting up a brand new Rio, I did NOT have the old node-red-contrib-serial-modbus installed, and I am able to get the ‘green’ connection now. When it IS installed (but not even being used in a flow), it seems that both nodes are fighting over the serial / USB connection.

On a Rio or EPIC, how do I completely uninstall a node (or set of nodes) that are no longer needed? On a Pi or Debian box, I believe that is done thru terminal. Do I need to get SSH running to my Rio?

Removing nodes is the same as adding.
Just make sure they are not in any flows or have any configuration and then go into the node-red menu and remove them via the manage palette.

Thanks Ben. I knew to look to the Manage Palette menu, but the remove option was not there. I eventually got the remove button to appear by manually disabling in the menu shown in the second screenshot. All is good now and the node-red-contrib-modbus node is working its Modbus Magic.


image

Hello,

you have an example in the script, I try to write with function 16 to a single register, but, when executing it, it shows the error:
“TransactionTimedOutError: timed out”

Can you give us a little more information about what you are looking to do?
There is no script as I recall. Just a modbus node and a debug node.
Since you are getting a timeout error, your device address etc sound wrong, ie it cant access the modbus device.
Are you using serial or TCP?

I am using node-red in a groov RIO, I use a modbus reading node, I manage to read the value I want, but the refresh time is not stable, sometimes it takes a long time to read. these are the messages when starting the flow.

after a while, you can see the reading, but as I said before, time is not constant.

when trying to write a data in a register it generates an error,

this is my write node configuration:

can you help me how to write to a modbus register.

I also have this node installed, the result is the same, correct reading, but the writing fails.

2022-04-29_17h26_07

this is my connection node configuration:

and the reading node:

I’m not seeing any errors in your debug output for your read nodes, seems fine.

Your write node is configured to write to 40006. Are you sure this is correct? Seems like just 6 would do the job based on your read node. If you have the debug nodes for the write display the full msg object you will probably see modbus error code 2 in there somewhere for invalid address.

1 Like

hi,

You are right, it should be written in register 6 and not 40006, I don’t know what I was thinking at that moment, in the read register I wrote it correctly. but now the modbus 2 error appears and it is clearly an invalid or incompatible function.

I am using the other node, which, reading works perfectly. but writing throws me the following error.