Receiving NaN when reading float registers from energy meter

Hi Node Red community,

I'm trying to read some values of the energy meter (Float32) in Node-Red. Interestingly, I can read some accurate values, but they are also some of the values for which I receive "NaN".
The configuration consists of a Schneider A9MEM3350 energy meter with a RS485 serial interface, a Modbus TCP gateway and Node Red running on a Raspberry Pi 3.
Initially I had used an Arduino with RS485 transciever to read the values, with exactly the same result. In the following lines I attach some pictures and Node Red example flow, maybe someone can help me figure out what is wrong.

NodeRed

```js [{"id":"788a1b70.8a44a4","type":"function","z":"1faa546d.dcd77c","name":"FC3 - I2: phase 2 current","func":"msg.payload = {\n    'fc': 3, \n    'unitid': 2, \n    'address': 3002, \n    'quantity': 2 \n}; \nreturn msg;","outputs":1,"noerr":0,"x":370,"y":80,"wires":[["1b9bebc8.6b6614"]]},{"id":"68fb9ce2.83d234","type":"modbus-response","z":"1faa546d.dcd77c","name":"","registerShowMax":20,"x":610,"y":240,"wires":[]},{"id":"4938af43.b6975","type":"function","z":"1faa546d.dcd77c","name":"","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer).swap16();\n\n// Represent these bytes as Float32\nconst value = buf.readFloatLE().toFixed(2);\n\n// save the value\nmsg.payload = value;\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":40,"wires":[["9113bce6.bab6c","4bd66b40.ec2424"]]},{"id":"9113bce6.bab6c","type":"ui_gauge","z":"1faa546d.dcd77c","name":"L1","group":"fbce3164.ebb78","order":0,"width":"2","height":"2","gtype":"compass","title":"L1","label":"A","format":"{{value | number:2 }}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1310,"y":40,"wires":[]},{"id":"c3177dab.69072","type":"function","z":"1faa546d.dcd77c","name":"","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer).swap16();\n\n// Represent these bytes as Float32\nconst value = buf.readFloatLE().toFixed(2);\n\n// save the value\nmsg.payload = value;\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":80,"wires":[["fa027e26.53958","a00fa66b.b7a5d8"]]},{"id":"751f4017.88405","type":"function","z":"1faa546d.dcd77c","name":"","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer).swap16();\n\n// Represent these bytes as Float32\nconst value = buf.readFloatLE().toFixed(2);\n\n// save the value\nmsg.payload = value;\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":120,"wires":[["21ae7ef0.3b84f2","32401ab7.44bee6"]]},{"id":"12fadbc5.393184","type":"function","z":"1faa546d.dcd77c","name":"","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer).swap16();\n\n// Represent these bytes as Float32\nconst value = buf.readFloatLE().toFixed(2);\n\n// save the value\nmsg.payload = value;\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":160,"wires":[["8985b39f.3726d","b61745c4.fa9eb8"]]},{"id":"fa027e26.53958","type":"ui_gauge","z":"1faa546d.dcd77c","name":"L2","group":"fbce3164.ebb78","order":0,"width":"2","height":"2","gtype":"compass","title":"L2","label":"A","format":"{{value | number:2 }}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1310,"y":80,"wires":[]},{"id":"21ae7ef0.3b84f2","type":"ui_gauge","z":"1faa546d.dcd77c","name":"L3","group":"fbce3164.ebb78","order":0,"width":"2","height":"2","gtype":"compass","title":"L3","label":"A","format":"{{value | number:2 }}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1310,"y":120,"wires":[]},{"id":"8985b39f.3726d","type":"ui_gauge","z":"1faa546d.dcd77c","name":"Current Avg.","group":"fbce3164.ebb78","order":0,"width":"6","height":"4","gtype":"compass","title":"Average current","label":"A","format":"{{value | number:2 }}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1290,"y":160,"wires":[]},{"id":"26a18739.d0a098","type":"modbus-flex-getter","z":"1faa546d.dcd77c","name":"I1: phase 1 current","showStatusActivities":true,"showErrors":false,"server":"675fd2c6.3dfa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":610,"y":40,"wires":[[],["4938af43.b6975"]]},{"id":"c058e06d.a3159","type":"function","z":"1faa546d.dcd77c","name":"FC3 - I1: phase 1 current","func":"msg.payload = {\n    'fc': 3, \n    'unitid': 2, \n    'address': 3000, \n    'quantity': 2 \n}; \nreturn msg;","outputs":1,"noerr":0,"x":370,"y":40,"wires":[["26a18739.d0a098"]]},{"id":"1b9bebc8.6b6614","type":"modbus-flex-getter","z":"1faa546d.dcd77c","name":"I2: phase 2 current","showStatusActivities":true,"showErrors":false,"server":"675fd2c6.3dfa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":610,"y":80,"wires":[[],["c3177dab.69072"]]},{"id":"a38d5c4c.fbe27","type":"modbus-flex-getter","z":"1faa546d.dcd77c","name":"I3: phase 3 current","showStatusActivities":true,"showErrors":false,"server":"675fd2c6.3dfa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":610,"y":120,"wires":[[],["751f4017.88405"]]},{"id":"af608401.50f618","type":"modbus-flex-getter","z":"1faa546d.dcd77c","name":"Current Avg","showStatusActivities":true,"showErrors":false,"server":"675fd2c6.3dfa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":590,"y":160,"wires":[[],["68fb9ce2.83d234","12fadbc5.393184"]]},{"id":"e8bb19f5.9a5a98","type":"function","z":"1faa546d.dcd77c","name":"FC3 - I2: phase 2 current","func":"msg.payload = {\n    'fc': 3, \n    'unitid': 2, \n    'address': 3004, \n    'quantity': 2 \n}; \nreturn msg;","outputs":1,"noerr":0,"x":370,"y":120,"wires":[["a38d5c4c.fbe27"]]},{"id":"bb9fa83f.baf8d8","type":"function","z":"1faa546d.dcd77c","name":"FC3 - Current Avg","func":"msg.payload = {\n    'fc': 3, \n    'unitid': 2, \n    'address': 3010, \n    'quantity': 2 \n}; \nreturn msg;","outputs":1,"noerr":0,"x":350,"y":160,"wires":[["af608401.50f618"]]},{"id":"e9cd218c.1680b","type":"inject","z":"1faa546d.dcd77c","name":"1 sec","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["c058e06d.a3159","788a1b70.8a44a4","e8bb19f5.9a5a98","bb9fa83f.baf8d8"]]},{"id":"b61745c4.fa9eb8","type":"modbus-response","z":"1faa546d.dcd77c","name":"","registerShowMax":20,"x":970,"y":240,"wires":[]},{"id":"4bd66b40.ec2424","type":"modbus-response","z":"1faa546d.dcd77c","name":"","registerShowMax":20,"x":1250,"y":240,"wires":[]},{"id":"a00fa66b.b7a5d8","type":"modbus-response","z":"1faa546d.dcd77c","name":"","registerShowMax":20,"x":1250,"y":280,"wires":[]},{"id":"32401ab7.44bee6","type":"modbus-response","z":"1faa546d.dcd77c","name":"","registerShowMax":20,"x":1250,"y":320,"wires":[]},{"id":"fbce3164.ebb78","type":"ui_group","z":"","name":"Current","tab":"8e5db1d7.c63a7","order":1,"disp":true,"width":"6","collapse":false},{"id":"675fd2c6.3dfa3c","type":"modbus-client","z":"","name":"iEM3350","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.1.1","tcpPort":"10502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"2","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"8e5db1d7.c63a7","type":"ui_tab","z":"","name":"Power meter","icon":"dashboard","order":3}]

So you are trying to post something that is "Not A Number" i.e NAN

You could try writing the values to a file, or send it to a debug to allow you to determine what it is being received to then allow you to filter them out.

Normally the modbus response node should be connected to the second output of a modbus read/write node.

In your flow the response node is connected to a function node. I am not sure if this will work.

What do you get if you replace the modbus response node by the regular debug node ?

Thank you @ukmoose and @Andrei, I have made some readings to a file, in first example I connected the output to the first output (up) of the modbus node:

L1.txt (3.4 KB)
L2.txt (3.4 KB)
L3.txt (3.4 KB)
Avg.txt (18.2 KB)

And in the second example is the output of the second connection of the modbus node (down) as shown in the image:

L1-2.txt (10.3 KB)
L2-2.txt (10.5 KB)
L3-2.txt (10.6 KB)
Avg-2.txt (10.6 KB)