Cannot read data by MODBUS RTU

Sensor manual

The sensor manual is shared above. I want to communicate with it through Modbus RTU node. My code is given below:

[{"id":"5f61c311.3e5d1c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b3e619e4.41ca08","type":"modbus-read","z":"5f61c311.3e5d1c","name":"","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":true,"unitid":"1","dataType":"InputRegister","adr":"1","quantity":"1","rate":"30","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"1c521864.046078","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":340,"y":140,"wires":[["94edf5aa.8613a8"],["3bf738d0.3f1648"]]},{"id":"3bf738d0.3f1648","type":"debug","z":"5f61c311.3e5d1c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":140,"wires":[]},{"id":"94edf5aa.8613a8","type":"modbus-response","z":"5f61c311.3e5d1c","name":"","registerShowMax":"10","x":660,"y":40,"wires":[]},{"id":"1c521864.046078","type":"modbus-client","z":"","name":"","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":false,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

I am getting error message which says: Error: Data length error, expected 7 got 2

Please help me out!! :cry: :cry:

I was playing with a PZEM-016 last Saturday. It was pretty straightforward to enable the communication. I still could make a quick dashboard (a couple of errors pending to correct though) to make it more fun. I will check your flow tomorrow (going out in few minutes). Please edit your message to reformat the code between backticks (click this link for instructions), otherwise i wont be able to test.

energy-meter

2 Likes

Can't import your 'server' settings. What are your serial settings?

[{"id":"76274d8e.fd5214","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"174978cb.b7da67","type":"modbus-read","z":"76274d8e.fd5214","name":"","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":true,"unitid":"1","dataType":"InputRegister","adr":"1","quantity":"1","rate":"30","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"4099da6.7419b24","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":340,"y":140,"wires":[["e4d6becf.7d167"],["942f710f.4b0c1"]]},{"id":"942f710f.4b0c1","type":"debug","z":"76274d8e.fd5214","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":140,"wires":[]},{"id":"e4d6becf.7d167","type":"modbus-response","z":"76274d8e.fd5214","name":"","registerShowMax":"10","x":660,"y":40,"wires":[]},{"id":"4099da6.7419b24","type":"modbus-client","z":"","name":"","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":false,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

I have tried with T/x and R/x opposite connection. T/x and R/x LED are also blinking in both side

i have uploaded the flow

I have uploaded the flow

I can´t see what is wrong. I share my config and suggest you to change the serial mode in the server config from RTU to RTU-Buffered, for testing purposes.

1 Like

In the last flow you included, you are reading only 1 register, but it looks like they need to be read in pairs at least. I'd just read all the registers every poll. Without that specific device, it's hard to say what the issue may be. I know my most recent install had a long, less than ideal serial bus. I had to increase the queue delay (for multiple reads on the same slave) to account for some delay time on the bus response. Another thing that gets overlooked, grounding. You NEED to have a good ground, using a 3rd conductor that is not a shield. For short cables, you generally don't need a shield or can use a shield for ground.

2 Likes

I couldn't fix the issue with the MODBUS node and PZE004T.
So to fix it, i have written a program in python using modbus library. And the executed the program in powershell node of node red. I is working fine and i am getting the data..

Can anyone help me with resetting the energy value of PZE004T??

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