How to do a proper Modbus Data Acquisition and display

Node-RED version : v.0.15.3

Hello to everybody,

Beginner in Nodered, I am currently working on a Modbus data acquisition system with Nodered.
First of all, I managed to get the address of a counter, and to build a modbus frame according to the Modbus protocol (RS485).
Secondly, I managed to display on the debug the values of the modbus frame and to display them.

I would like to be able to recover the payload object that it sends us (the multi serial) in a table.
I wanna be able to cut and keep only the values between the brackets and delete the rest (here my registers refer to the kwH) (Screen below). And then allow to convert the hexadecimal values of the frame into decimal on the display tab

Does anyone know how to do this? And is it possible to create a global variable?

Excuse me, I think that my "fonction de test" node must contain a lot of errors.

Here is my flow code :

[{"id":"c2d776a2.9ebe68","type":"tab","label":"Node TEST"},{"id":"1d132f6a.05eaa1","type":"function","z":"c2d776a2.9ebe68","name":"write trame","func":"var buf=Buffer([0x02,0x03,0xC6,0x52,0x00,0x02,0x59,0x61]);\nmsg.payload=buf;\nreturn msg;\n","outputs":1,"noerr":0,"x":408,"y":194,"wires":[["a06d32f3.fd2b2","9b3b4bb1.74b2b8"]]},{"id":"44ec0cf0.b63024","type":"inject","z":"c2d776a2.9ebe68","name":"payload","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":150,"y":195,"wires":[["1d132f6a.05eaa1"]]},{"id":"95fea1ef.6353b","type":"debug","z":"c2d776a2.9ebe68","name":"","active":true,"console":"false","complete":"true","x":744,"y":423,"wires":[]},{"id":"a06d32f3.fd2b2","type":"debug","z":"c2d776a2.9ebe68","name":"","active":true,"console":"false","complete":"payload","x":746,"y":194,"wires":[]},{"id":"a05ecf98.bcd35","type":"multi serial in","z":"c2d776a2.9ebe68","name":"","accessoryport":"2","mode":"rs485hd","serialbaud":"9600","datatype":"readbytes","flowcontrol":"disabled","xonxoff":null,"rtscts":null,"dsrdtr":null,"startstopchars":"false","databits":8,"stopbits":1,"timeout":"1","bytecount":"1","parity":"none","x":136.10000610351562,"y":420,"wires":[["95fea1ef.6353b"]]},{"id":"9b3b4bb1.74b2b8","type":"multi serial out","z":"c2d776a2.9ebe68","name":"","accessoryport":"2","mode":"rs485hd","serialbaud":"9600","datatype":"readbytes","flowcontrol":"disabled","xonxoff":null,"rtscts":null,"dsrdtr":null,"startstopchars":"false","databits":8,"stopbits":1,"parity":"none","x":742.1000747680664,"y":326.0000066757202,"wires":[]},{"id":"2990e6d1.4bf94a","type":"function","z":"c2d776a2.9ebe68","name":"fonction test","func":"var count=global.get('msg.payload') || 0;\nvar payload=context.get('msg.payload') || {};\nif (payload.count===undefined)//test exists\n{\n  payload.count=0;\n}\npayload.count +=1;\nglobal.set('msg.payload',count);\nmsg.payload=\"msg.payload \"+msg.payload+\" \"+payload.count;\ncontext.set('msg.payload',payload);\nreturn msg.payload;\n\n\n//var payload=msg.payload;\n//var trame = {};\n/*global.set(\"Message Payload\",msgpayload);\nmsg.payload = global.get(\"payload\");\n\nreturn msg;\n*/","outputs":1,"noerr":0,"x":350.16668701171875,"y":492.3333740234375,"wires":[[]]},{"id":"834f70a2.655b","type":"function","z":"c2d776a2.9ebe68","name":"","func":"return payload;","outputs":1,"noerr":0,"x":451,"y":366,"wires":[[]]}]

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

https://nodered.org/docs/user-guide/messages

I don't have the appearance of buttons under my mouse pointer when i over hover a debug message.

I mentionned the version of my NodeRED at the top of my topic which is versions away in my opinion of the version you got, giving the possibility to do this.

I wanna have more information to know how to acquire the hexa variable i've put in a buffer that i wanna turn into a global variable so i can split the informations contained in the Modbus frame and display them properly instead of having values in brackets .

Can you not upgrade node-red? That is quite old and you are missing out on some great features.

There is a contrib node called node-red-contrib-buffer-parser that's perfect for turning all your modbus raw data into nicely formatted values but I am going to guess from your very old version of node-red that your node version is also too old.

What does node -v report?

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