Node-red on iot2050 not working

Hi,
I am working on a student project involve using iot2050 and Node-red to poll data.
So I connected my laptop to the iot2050 with an ethernet cable.I try to poll some number from a slave simulation program ( Modbus Slave) on my lap with a simple flow but it did not work.
My flow

[{"id":"4b33b8e7.cd2418","type":"tab","label":"TEST 2","disabled":false,"info":""},{"id":"761d864e.aa0488","type":"inject","z":"4b33b8e7.cd2418","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":180,"wires":[["ec566e06.f820d"]]},{"id":"2cc1b935.4b8ff6","type":"modbus-flex-getter","z":"4b33b8e7.cd2418","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"659784ca.45dbcc","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":450,"y":180,"wires":[["c3e59b32.af2cb8"],["2d01a806.3793f8"]]},{"id":"c3e59b32.af2cb8","type":"modbus-response","z":"4b33b8e7.cd2418","name":"","registerShowMax":20,"x":690,"y":160,"wires":[]},{"id":"ec566e06.f820d","type":"function","z":"4b33b8e7.cd2418","name":"function 1","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 1, \n    'address': 0, \n    'quantity': 10 } \nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":240,"wires":[["2cc1b935.4b8ff6"]]},{"id":"2d01a806.3793f8","type":"debug","z":"4b33b8e7.cd2418","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":660,"y":220,"wires":[]},{"id":"659784ca.45dbcc","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.200.5","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","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}]

I set my lap ip address to 192.168.200.5 and set Modbus Slave to listen to server 192.168.200.5 port 502.
I am very new to iot and Node-red in general so I do not know if the problem is node-red, hardware setup or outside factor.
If it is inappropriate to ask such problem here then I apologize.
Any help is appreciated.

Edit 1: I turned on error msg on the modbus-flex-getter node and in the Debug window, it said: "Error: Client Not Ready To Read At State init". Hope it provides some infomation.

First thing would be to setup different IP addresses. Right now your laptops network card IP is the same as IOT2050. So change one of those.

I've never worked IOT2050, but from this video Siemens SIMATIC IOT2050 First Look - Industrial Internet of Things Gateway powered by Debian Linux - YouTube I see that it is very similar to IOT2040. After making changes you should try and ping your Modbus server to see if connection is established.

There are tons of examples in nodered forum and also in siemens forum if you like

Thank you for the reply. But the iot2050 ip address is 192.168.200.1 at the moment, and I was able to ping it with no problem.
The Modbus-flex-getter gave error message "Error: Client Not Ready To Read At State init", Do you have any ideas why that error occurs?

Honestly never seen it, but here are the issue raised with similar problem

it seems that this issue is related to Modbus Flex Getter, why don't you use simple Modbus Read node?

Thank you. I have read the issue that you mentioned, however mine never worked in the first place so I think the problem might be different.
I used Modbus-read node as your suggestion, the same error happened. I was able to see the status of the node: Registered => Reconnecting after 2000ms => Initialized => Reconnecting after 2000ms then repeat; when I inject the node, the same error message happens. Is this behaviour normal?
My flow:

[{"id":"16606710.e0a2e9","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ca63c4f8.9a3958","type":"modbus-response","z":"16606710.e0a2e9","name":"","registerShowMax":20,"x":570,"y":140,"wires":[]},{"id":"cbaa3344.253f5","type":"debug","z":"16606710.e0a2e9","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":200,"wires":[]},{"id":"5d50ee8b.8a6ba","type":"modbus-read","z":"16606710.e0a2e9","name":"","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":true,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"10","rate":"1","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"7248280a.ff4248","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":230,"y":160,"wires":[["ca63c4f8.9a3958"],["cbaa3344.253f5"]]},{"id":"7248280a.ff4248","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.200.5","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"250","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Are these your current settings?

This is an example from energy meter:
image

You should check addresses (do you have address table?) and you should reduce polling rate to 1-10s range

I am currently polling from a simulated slave using Modbus slave on my laptop so I expected the Modbus Response to be an array of 10 0s.
I have changed the poll rate per your suggestion but the problem is not solved.

What simulation tool are you using?

Maybe please and follow this guide? ModBus, Node-Red and MQTT -Video 1 - YouTube

I was using https://www.modbustools.com/modbus_slave.html
I have watched the video you suggested, my original flow was after I followed the instruction in the video.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.