Node-red Modbus RTU Data types Convert (unsigned Int to float)

I got a project to read RS485 data using UART Modbus to Serial (UART TTL to RS485 Two-way Converter | Elecrow). before using node-red I use Arduino for this project and the project is succeed, I can read the data and converting it.

now I'm trying to using node-red and surprisingly I also got the data, but the problem is I can't convert the data in the program

this is the Raw value from the device (they say those data on FLOAT32 base on the datasheet)

image

the actual from the device is around 234,54.

and this is the Modbus register settings :
image

here's the converting program from Arduino, which I got it from (Modbus tips for Industruino | Industruino)

float f_2uint_float(unsigned int uint1, unsigned int uint2) {    // reconstruct the float from 2 unsigned integers

  union f_2uint {
    float f;
    uint16_t i[2];
  };

  union f_2uint f_number;
  f_number.i[0] = uint1;
  f_number.i[1] = uint2;

  return f_number.f;

}

Did anyone know how to convert the from the data from the device to the actual value?

node-red-contrib-buffer-parser (node) - Node-RED is designed for this very task.

1 Like

ah yes, thank you. it work flawlessly

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