How to get modbus float from register?

I want to get the true value of my MODBUS exit, but I don't know how to do that, and I try differents ways to get frecuency, but I don't know if my configuration are OK, or my connection, or my registers









Hi. Can you copy from debug (use the copy button that appears when you hover the payload in debug window), the value that comes out of your modbus node paste it into a reply.

Also, provide the (final) values you expect.

Lastly export your flow and paste it in the reply.

I'll take a look for you.

To update, I was made a little changes like 3 differents ways to read the frequency, this should be 60Hz but the results gives different.

[{"id":"f36ea9b3.c1f848","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"ccb8d916.673918","type":"modbus-response","z":"f36ea9b3.c1f848","name":"","registerShowMax":"20","x":830,"y":140,"wires":},{"id":"82ed37e6.fbd608","type":"debug","z":"f36ea9b3.c1f848","name":"Value","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":980,"y":280,"wires":},{"id":"51b46ff.e5af79","type":"function","z":"f36ea9b3.c1f848","name":"DECODE","func":"m = msg.payload.data;\nreturn {payload: m};","outputs":1,"noerr":0,"x":560,"y":220,"wires":[["dbeccd4a.de895","9c830e95.b7a2b","3e194060.1472f","bdda5464.b6f248"]]},{"id":"dbeccd4a.de895","type":"buffer-parser","z":"f36ea9b3.c1f848","name":"none","data":"payload","dataType":"msg","specification":"{"options":{"byteSwap":false,"resultType":"buffer","msgProperty":"payload"}}","specificationType":"json","x":790,"y":220,"wires":[["82ed37e6.fbd608","dad37ba4.f55178"]]},{"id":"dad37ba4.f55178","type":"function","z":"f36ea9b3.c1f848","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, "1735" "0x02045789" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === "number") {\n intValue = msg.payload;\n} else if (typeof msg.payload === "string") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 4) {\n // four byte array or buffer\n intValue = (((((msg.payload[0] << 8) + msg.payload[1]) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn("Unrecognised payload type or length");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":1010,"y":220,"wires":[["91e172c.1fcd09"]]},{"id":"91e172c.1fcd09","type":"debug","z":"f36ea9b3.c1f848","name":"Value ","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1220,"y":280,"wires":},{"id":"6e024185.78f7d","type":"modbus-response","z":"f36ea9b3.c1f848","name":"","registerShowMax":"20","x":830,"y":80,"wires":},{"id":"6122db38.51e614","type":"modbus-read","z":"f36ea9b3.c1f848","name":"Lectura","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"InputRegister","adr":"40017","quantity":"2","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"7fa95da6.411994","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":390,"y":80,"wires":[["6e024185.78f7d"],["ccb8d916.673918","51b46ff.e5af79"]]},{"id":"3e194060.1472f","type":"function","z":"f36ea9b3.c1f848","name":"CHIDO","func":"const a = msg.payload;\nconst a1 = (a[0] >> 8) & 255;\nconst a2 = a[0] & 255;\nconst a3 = (a[1] >> 8) & 255;\nconst a4 = a[1] & 255;\nconst buf = Buffer.from([a4,a3,a2,a1]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":360,"wires":[["171da40f.106ffc"]]},{"id":"171da40f.106ffc","type":"debug","z":"f36ea9b3.c1f848","name":"Resultadito1","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1040,"y":360,"wires":},{"id":"9c830e95.b7a2b","type":"debug","z":"f36ea9b3.c1f848","name":"Value","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":800,"y":280,"wires":},{"id":"bdda5464.b6f248","type":"function","z":"f36ea9b3.c1f848","name":"CHIDO","func":"const a = msg.payload;\nconst a1 = (a[0] >> 8) & 255;\nconst a2 = a[0] & 255;\nconst a3 = (a[1] >> 8) & 255;\nconst a4 = a[1] & 255;\nconst buf = Buffer.from([a1,a2,a3,a4]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":420,"wires":[["6bc8c57f.0cd24c"]]},{"id":"6bc8c57f.0cd24c","type":"debug","z":"f36ea9b3.c1f848","name":"Resultadito2","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1040,"y":420,"wires":},{"id":"7fa95da6.411994","type":"modbus-client","z":"","name":"EQUALIZER","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"14502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

[{"id":"f36ea9b3.c1f848","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"ccb8d916.673918","type":"modbus-response","z":"f36ea9b3.c1f848","name":"","registerShowMax":"20","x":830,"y":140,"wires":},{"id":"82ed37e6.fbd608","type":"debug","z":"f36ea9b3.c1f848","name":"Value","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":980,"y":280,"wires":},{"id":"51b46ff.e5af79","type":"function","z":"f36ea9b3.c1f848","name":"DECODE","func":"m = msg.payload.data;\nreturn {payload: m};","outputs":1,"noerr":0,"x":560,"y":220,"wires":[["dbeccd4a.de895","9c830e95.b7a2b","3e194060.1472f","bdda5464.b6f248"]]},{"id":"dbeccd4a.de895","type":"buffer-parser","z":"f36ea9b3.c1f848","name":"none","data":"payload","dataType":"msg","specification":"{"options":{"byteSwap":false,"resultType":"buffer","msgProperty":"payload"}}","specificationType":"json","x":790,"y":220,"wires":[["82ed37e6.fbd608","dad37ba4.f55178"]]},{"id":"dad37ba4.f55178","type":"function","z":"f36ea9b3.c1f848","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, "1735" "0x02045789" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === "number") {\n intValue = msg.payload;\n} else if (typeof msg.payload === "string") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 4) {\n // four byte array or buffer\n intValue = (((((msg.payload[0] << 8) + msg.payload[1]) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn("Unrecognised payload type or length");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":1010,"y":220,"wires":[["91e172c.1fcd09"]]},{"id":"91e172c.1fcd09","type":"debug","z":"f36ea9b3.c1f848","name":"Value ","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1220,"y":280,"wires":},{"id":"6e024185.78f7d","type":"modbus-response","z":"f36ea9b3.c1f848","name":"","registerShowMax":"20","x":830,"y":80,"wires":},{"id":"6122db38.51e614","type":"modbus-read","z":"f36ea9b3.c1f848","name":"Lectura","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"InputRegister","adr":"40017","quantity":"2","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"7fa95da6.411994","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":390,"y":80,"wires":[["6e024185.78f7d"],["ccb8d916.673918","51b46ff.e5af79"]]},{"id":"3e194060.1472f","type":"function","z":"f36ea9b3.c1f848","name":"CHIDO","func":"const a = msg.payload;\nconst a1 = (a[0] >> 8) & 255;\nconst a2 = a[0] & 255;\nconst a3 = (a[1] >> 8) & 255;\nconst a4 = a[1] & 255;\nconst buf = Buffer.from([a4,a3,a2,a1]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":360,"wires":[["171da40f.106ffc"]]},{"id":"171da40f.106ffc","type":"debug","z":"f36ea9b3.c1f848","name":"Resultadito1","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1040,"y":360,"wires":},{"id":"9c830e95.b7a2b","type":"debug","z":"f36ea9b3.c1f848","name":"Value","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":800,"y":280,"wires":},{"id":"bdda5464.b6f248","type":"function","z":"f36ea9b3.c1f848","name":"CHIDO","func":"const a = msg.payload;\nconst a1 = (a[0] >> 8) & 255;\nconst a2 = a[0] & 255;\nconst a3 = (a[1] >> 8) & 255;\nconst a4 = a[1] & 255;\nconst buf = Buffer.from([a1,a2,a3,a4]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":420,"wires":[["6bc8c57f.0cd24c"]]},{"id":"6bc8c57f.0cd24c","type":"debug","z":"f36ea9b3.c1f848","name":"Resultadito2","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1040,"y":420,"wires":},{"id":"7fa95da6.411994","type":"modbus-client","z":"","name":"EQUALIZER","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"14502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Hi. None of your exports are usable. Please go back and edit your posts after reading this...

... it is important to post code between two sets of three backticks - ``` - see this post for more details - How to share code or flow json

Thanks Steve, it´s here my code

[{"id":"f36ea9b3.c1f848","type":"tab","label":"Flow 3","disabled":false,"info":"``[{\"id\":\"f36ea9b3.c1f848\",\"type\":\"tab\",\"label\":\"Flow 3\",\"disabled\":false,\"info\":\"``\"},{\"id\":\"ccb8d916.673918\",\"type\":\"modbus-response\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"\",\"registerShowMax\":\"20\",\"x\":830,\"y\":140,\"wires\":[]},{\"id\":\"82ed37e6.fbd608\",\"type\":\"debug\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"View Value1\",\"active\":false,\"tosidebar\":true,\"console\":true,\"tostatus\":true,\"complete\":\"payload\",\"targetType\":\"msg\",\"x\":1000,\"y\":280,\"wires\":[]},{\"id\":\"51b46ff.e5af79\",\"type\":\"function\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"DATA\",\"func\":\"m = msg.payload.data;\\nreturn {payload: m};\",\"outputs\":1,\"noerr\":0,\"x\":550,\"y\":220,\"wires\":[[\"dbeccd4a.de895\",\"9c830e95.b7a2b\",\"3e194060.1472f\",\"bdda5464.b6f248\"]]},{\"id\":\"dbeccd4a.de895\",\"type\":\"buffer-parser\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"to buffer\",\"data\":\"payload\",\"dataType\":\"msg\",\"specification\":\"{\\\"options\\\":{\\\"byteSwap\\\":false,\\\"resultType\\\":\\\"buffer\\\",\\\"msgProperty\\\":\\\"payload\\\"}}\",\"specificationType\":\"json\",\"x\":800,\"y\":220,\"wires\":[[\"82ed37e6.fbd608\",\"dad37ba4.f55178\"]]},{\"id\":\"dad37ba4.f55178\",\"type\":\"function\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"IEEE-754 to float\",\"func\":\"/* Converts from an number, string, buffer or array representing an IEEE-754 value\\n * to a javascript float.\\n * The following may be given in msg.payload:\\n *      A string representing a number, which may be hex or binary\\n *        examples, \\\"1735\\\"  \\\"0x02045789\\\"  0b01000000010010010000111111011011\\n *      An integer value\\n *      A four element array or buffer of 8 bit values, most significant byte first.\\n*/ \\n// first make a number from the given payload if necessary\\nlet intValue;\\nif (typeof msg.payload === \\\"number\\\") {\\n    intValue = msg.payload;\\n} else if (typeof msg.payload === \\\"string\\\") {\\n    intValue = Number(msg.payload);\\n} else if (msg.payload.length == 4) {\\n    // four byte array or buffer\\n    intValue = (((((msg.payload[0] << 8) + msg.payload[1]) << 8) + msg.payload[2]) << 8) + msg.payload[3];\\n} else {\\n    node.warn(\\\"Unrecognised payload type or length\\\");\\n}\\n\\nmsg.payload = Int2Float32(intValue);\\nreturn msg;\\n\\nfunction Int2Float32(bytes) {\\n    var sign = (bytes & 0x80000000) ? -1 : 1;\\n    var exponent = ((bytes >> 23) & 0xFF) - 127;\\n    var significand = (bytes & ~(-1 << 23));\\n\\n    if (exponent == 128) \\n        return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\\n\\n    if (exponent == -127) {\\n        if (significand === 0) return sign * 0.0;\\n        exponent = -126;\\n        significand /= (1 << 22);\\n    } else significand = (significand | (1 << 23)) / (1 << 23);\\n\\n    return sign * significand * Math.pow(2, exponent);\\n}\",\"outputs\":1,\"noerr\":0,\"x\":1010,\"y\":220,\"wires\":[[\"91e172c.1fcd09\"]]},{\"id\":\"91e172c.1fcd09\",\"type\":\"debug\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"Result 3\",\"active\":false,\"tosidebar\":true,\"console\":true,\"tostatus\":true,\"complete\":\"payload\",\"targetType\":\"msg\",\"x\":1230,\"y\":280,\"wires\":[]},{\"id\":\"6e024185.78f7d\",\"type\":\"modbus-response\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"\",\"registerShowMax\":\"20\",\"x\":830,\"y\":60,\"wires\":[]},{\"id\":\"6122db38.51e614\",\"type\":\"modbus-read\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"READ FRECUENCY\",\"topic\":\"\",\"showStatusActivities\":false,\"logIOActivities\":false,\"showErrors\":false,\"unitid\":\"\",\"dataType\":\"InputRegister\",\"adr\":\"17\",\"quantity\":\"2\",\"rate\":\"5\",\"rateUnit\":\"s\",\"delayOnStart\":false,\"startDelayTime\":\"\",\"server\":\"7fa95da6.411994\",\"useIOFile\":false,\"ioFile\":\"\",\"useIOForPayload\":false,\"emptyMsgOnFail\":false,\"x\":430,\"y\":80,\"wires\":[[\"6e024185.78f7d\"],[\"ccb8d916.673918\",\"51b46ff.e5af79\"]]},{\"id\":\"3e194060.1472f\",\"type\":\"function\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"Other way \",\"func\":\"const a =  msg.payload;\\nconst a1 = (a[0] >> 8) & 255;\\nconst a2 = a[0] & 255;\\nconst a3 = (a[1] >> 8) & 255;\\nconst a4 = a[1] & 255;\\nconst buf = Buffer.from([a4,a3,a2,a1]);\\nmsg.payload = buf.readFloatBE(0);\\nreturn msg;\",\"outputs\":1,\"noerr\":0,\"x\":810,\"y\":360,\"wires\":[[\"171da40f.106ffc\"]]},{\"id\":\"171da40f.106ffc\",\"type\":\"debug\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"Result 1\",\"active\":false,\"tosidebar\":true,\"console\":true,\"tostatus\":true,\"complete\":\"payload\",\"targetType\":\"msg\",\"x\":1030,\"y\":360,\"wires\":[]},{\"id\":\"9c830e95.b7a2b\",\"type\":\"debug\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"View Value 2\",\"active\":false,\"tosidebar\":true,\"console\":true,\"tostatus\":true,\"complete\":\"payload\",\"targetType\":\"msg\",\"x\":800,\"y\":280,\"wires\":[]},{\"id\":\"bdda5464.b6f248\",\"type\":\"function\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"Other way\",\"func\":\"const a =  msg.payload;\\nconst a1 = (a[0] >> 8) & 255;\\nconst a2 = a[0] & 255;\\nconst a3 = (a[1] >> 8) & 255;\\nconst a4 = a[1] & 255;\\nconst buf = Buffer.from([a1,a2,a3,a4]);\\nmsg.payload = buf.readFloatBE(0);\\nreturn msg;\",\"outputs\":1,\"noerr\":0,\"x\":810,\"y\":420,\"wires\":[[\"6bc8c57f.0cd24c\"]]},{\"id\":\"6bc8c57f.0cd24c\",\"type\":\"debug\",\"z\":\"f36ea9b3.c1f848\",\"name\":\"Result 2\",\"active\":false,\"tosidebar\":true,\"console\":true,\"tostatus\":true,\"complete\":\"payload\",\"targetType\":\"msg\",\"x\":1030,\"y\":420,\"wires\":[]},{\"id\":\"7fa95da6.411994\",\"type\":\"modbus-client\",\"z\":\"\",\"name\":\"EQUALIZER\",\"clienttype\":\"serial\",\"bufferCommands\":true,\"stateLogEnabled\":true,\"queueLogEnabled\":true,\"tcpHost\":\"127.0.0.1\",\"tcpPort\":\"14502\",\"tcpType\":\"DEFAULT\",\"serialPort\":\"/dev/ttyUSB0\",\"serialType\":\"RTU-BUFFERD\",\"serialBaudrate\":\"19200\",\"serialDatabits\":\"8\",\"serialStopbits\":\"1\",\"serialParity\":\"none\",\"serialConnectionDelay\":\"100\",\"unit_id\":\"1\",\"commandDelay\":\"1\",\"clientTimeout\":\"1000\",\"reconnectOnTimeout\":true,\"reconnectTimeout\":\"2000\",\"parallelUnitIdsAllowed\":true}```"},{"id":"ccb8d916.673918","type":"modbus-response","z":"f36ea9b3.c1f848","name":"","registerShowMax":"20","x":830,"y":140,"wires":[]},{"id":"82ed37e6.fbd608","type":"debug","z":"f36ea9b3.c1f848","name":"View Value1","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1000,"y":280,"wires":[]},{"id":"51b46ff.e5af79","type":"function","z":"f36ea9b3.c1f848","name":"DATA","func":"m = msg.payload.data;\nreturn {payload: m};","outputs":1,"noerr":0,"x":550,"y":220,"wires":[["dbeccd4a.de895","9c830e95.b7a2b","3e194060.1472f","bdda5464.b6f248"]]},{"id":"dbeccd4a.de895","type":"buffer-parser","z":"f36ea9b3.c1f848","name":"to buffer","data":"payload","dataType":"msg","specification":"{\"options\":{\"byteSwap\":false,\"resultType\":\"buffer\",\"msgProperty\":\"payload\"}}","specificationType":"json","x":800,"y":220,"wires":[["82ed37e6.fbd608","dad37ba4.f55178"]]},{"id":"dad37ba4.f55178","type":"function","z":"f36ea9b3.c1f848","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n *      A string representing a number, which may be hex or binary\n *        examples, \"1735\"  \"0x02045789\"  0b01000000010010010000111111011011\n *      An integer value\n *      A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === \"number\") {\n    intValue = msg.payload;\n} else if (typeof msg.payload === \"string\") {\n    intValue = Number(msg.payload);\n} else if (msg.payload.length == 4) {\n    // four byte array or buffer\n    intValue = (((((msg.payload[0] << 8) + msg.payload[1]) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n    node.warn(\"Unrecognised payload type or length\");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n    var sign = (bytes & 0x80000000) ? -1 : 1;\n    var exponent = ((bytes >> 23) & 0xFF) - 127;\n    var significand = (bytes & ~(-1 << 23));\n\n    if (exponent == 128) \n        return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n    if (exponent == -127) {\n        if (significand === 0) return sign * 0.0;\n        exponent = -126;\n        significand /= (1 << 22);\n    } else significand = (significand | (1 << 23)) / (1 << 23);\n\n    return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":1010,"y":220,"wires":[["91e172c.1fcd09"]]},{"id":"91e172c.1fcd09","type":"debug","z":"f36ea9b3.c1f848","name":"Result 3","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1230,"y":280,"wires":[]},{"id":"6e024185.78f7d","type":"modbus-response","z":"f36ea9b3.c1f848","name":"","registerShowMax":"20","x":830,"y":60,"wires":[]},{"id":"6122db38.51e614","type":"modbus-read","z":"f36ea9b3.c1f848","name":"READ FRECUENCY","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"InputRegister","adr":"17","quantity":"2","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"7fa95da6.411994","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":430,"y":80,"wires":[["6e024185.78f7d"],["ccb8d916.673918","51b46ff.e5af79"]]},{"id":"3e194060.1472f","type":"function","z":"f36ea9b3.c1f848","name":"Other way ","func":"const a =  msg.payload;\nconst a1 = (a[0] >> 8) & 255;\nconst a2 = a[0] & 255;\nconst a3 = (a[1] >> 8) & 255;\nconst a4 = a[1] & 255;\nconst buf = Buffer.from([a4,a3,a2,a1]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":360,"wires":[["171da40f.106ffc"]]},{"id":"171da40f.106ffc","type":"debug","z":"f36ea9b3.c1f848","name":"Result 1","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1030,"y":360,"wires":[]},{"id":"9c830e95.b7a2b","type":"debug","z":"f36ea9b3.c1f848","name":"View Value 2","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":800,"y":280,"wires":[]},{"id":"bdda5464.b6f248","type":"function","z":"f36ea9b3.c1f848","name":"Other way","func":"const a =  msg.payload;\nconst a1 = (a[0] >> 8) & 255;\nconst a2 = a[0] & 255;\nconst a3 = (a[1] >> 8) & 255;\nconst a4 = a[1] & 255;\nconst buf = Buffer.from([a1,a2,a3,a4]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":420,"wires":[["6bc8c57f.0cd24c"]]},{"id":"6bc8c57f.0cd24c","type":"debug","z":"f36ea9b3.c1f848","name":"Result 2","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1030,"y":420,"wires":[]},{"id":"7fa95da6.411994","type":"modbus-client","z":"","name":"EQUALIZER","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"14502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

EDIT By Steve-Mcl - I wrapped the code correctly as described in the link

```
this is how you wrap code!
```

my problem is the way to get the float result and I don't know, whether is the way to get the float or the registers that I write ...

Carlos,

Add a debug like this...
image

Set the debug like this...
image

then copy the result like this...
image

Then paste it back into a reply between three back ticks...
```
paste between backticks like this
```

Also, please tell me what value to actually expect it to be
(e.g. modbus returns [123,456] but I expect it to be 45.784)

Hi Steve, the result is this I expect 60.04 hz and modbus returns [0,14656]

{"topic":"polling","payload":[0,14656],"responseBuffer":{"data":[0,14656],"buffer":[0,0,57,64]},"input":{"topic":"polling","from":"READ FRECUENCY","payload":{"unitid":"","fc":4,"address":"17","quantity":"2","messageId":"5f05d2baf9034ea2d876585d"},"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1},"sendingNodeId":"6122db38.51e614","_msgid":"d2fa4546.b77ec8"}

Are you 100% certain you are reading the correct register?

I cannot get 60.04 from [0,14656] ([0,0,57,64])

closest I get is

  • 2.890625 (floatle) or 14656 (int32be) or 1077477376 (int32le)
  • after swap16
    • i get 0.00018310546875 (floatle) or 16441 (int32be) or 960495616 (int32le)

Do any of those look like modbus values in other registers?

Perhaps you might want to read 20 items starting at register 1 - then we can look for value 60.04

We use this software called "simply Modbus Master" and we want to do the same in Node red, but we are beginners in Node red

this is the behavior of this software ... and we want to replicate this in node red

Register 17 may not be 40017 (modbus std is all over the place - sometimes addresses are zero based)

so try asking for register 15 - and get 6 values

then tell me what the data is (like before) and what it should be.

using your screen shot above for register 40017...
image

I took the byte values [0x42,0x47,0xf4,0x0] and faked a modbus reply...

As you can see - I get the expected value (below) - that leads me to suspect the values in your previous are incorrect or you are out by 1 register (the offset problem)...

The flow i used...

[{"id":"96dab12c.71f16","type":"buffer-parser","z":"45e696b4.b511b8","name":"","data":"responseBuffer.buffer","dataType":"msg","specification":"{\"options\":{\"byteSwap\":[],\"resultType\":\"object\",\"msgProperty\":\"payload\",\"singleResult\":true,\"setTopic\":true},\"items\":[{\"name\":\"frequeuncy\",\"type\":\"floatbe\",\"offset\":0}]}","specificationType":"json","x":830,"y":80,"wires":[["a1889b2c.de8a28"]]},{"id":"102736e7.2a06e9","type":"inject","z":"45e696b4.b511b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":500,"y":80,"wires":[["27efbf42.fd082"]]},{"id":"27efbf42.fd082","type":"function","z":"45e696b4.b511b8","name":"fake modbus","func":"\nreturn {\n\n    \"responseBuffer\":{\n        \"buffer\": Buffer.from([0x42,0x47,0xf4,0x0]),\n    }\n    \n};","outputs":1,"noerr":0,"x":650,"y":80,"wires":[["96dab12c.71f16"]]},{"id":"a1889b2c.de8a28","type":"debug","z":"45e696b4.b511b8","name":"Result 1","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":990,"y":80,"wires":[]},{"id":"b1e179f7.02ef98","type":"buffer-parser","z":"45e696b4.b511b8","name":"","data":"responseBuffer.buffer","dataType":"msg","specification":"{\"options\":{\"byteSwap\":[\"swap16\"],\"resultType\":\"object\",\"msgProperty\":\"payload\",\"singleResult\":true,\"setTopic\":true},\"items\":[{\"name\":\"frequeuncy\",\"type\":\"floatbe\",\"offset\":0}]}","specificationType":"json","x":850,"y":160,"wires":[["bf4a585b.ddc5d8"]]},{"id":"65d1ed7b.d5a7a4","type":"inject","z":"45e696b4.b511b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":520,"y":160,"wires":[["f7557446.d3c018"]]},{"id":"f7557446.d3c018","type":"function","z":"45e696b4.b511b8","name":"fake modbus","func":"//data is byte reversed in this one\nreturn {\n\n    \"responseBuffer\":{\n        \"buffer\": Buffer.from([0x47, 0x42, 0x0, 0xf4]),\n    }\n    \n};","outputs":1,"noerr":0,"x":670,"y":160,"wires":[["b1e179f7.02ef98"]]},{"id":"bf4a585b.ddc5d8","type":"debug","z":"45e696b4.b511b8","name":"Result 1","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1010,"y":160,"wires":[]}]