Converting an uint32sw value (2 read modbus registers) to float


I am getting information via Modbus from my pv inverter. The value "total_power_export" is stored in 2 registers as uint32sw.

How can i parse this information in a float value?

I tried a function with some codes from the internet, but none of them does work.

Thank you !


  • List item

Many folk use node-red-contrib-buffer-parser for this type of task.


i also tried that ... i couldn't get it work ...
maybe an exampel for me ?

If you provide sample data and the value you expect it to be, sure.


This is the output in a textbox:

Do you need more ?


I am not going to second guess the format of the data.

Also, does the devices manual give an example of this (e.g. [123,456] === 1.23455) and/or any details on how they compute the float from 32bit data?


Is that how you want it to look? Or is that the value read from Modbus?

I need an example of modbus data (e.g. [123,456]) and how you expect it to be parsed (e.g. 1.23456)

as well as any info from the manual you can find

That's the value how it is transmitted via modbus.
The output after parsing should be like: 1200 (Watts) or 1533 (Watts) ...

I think Steve needs to know exactly what number that value represents (or show us a different value and exactly what it represents).

The closes I can get that to is:

And that was only achieved by byte swapping the data (swap16) and using the UINT32le datatype type. Typically (but not always), Modbus data is packed in be (Big Endian)

I suspect 1 or more things

  1. Your read request is off by 1 (i.e. it should be [5178,0])
  2. The data is being reversed by your computer/server
  3. You have processed the data (perhaps in a function) or the way the modbus node packed the data buffer into an integer array has manipulated it - and that is what you are showing us.

To be certain, you should read 7 registers from address 5010 and output the result to a debug node - then capture the FULL payload using the "Copy Value" button

Then tell me what they SHOULD be.


register buffer should be
5010 [xx, yy] 110.1
5011 [xx, yy] 110.6
5012 [xx, yy] 110.2
5013 [xx, yy] 12.5
5016 [nn, oo, pp, qq] 5000

Besides any how, you should be reading more than 1 item at a time and using the buffer-parser to convert everything in one go (helps with data consistency and reduced traffic) - see this article for details

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