# Modbus Array Readings and Conversion

**URL:** <https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228>\
**Category:** General\
**Created:** [6 August 2020 14:33 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228 "2020-08-06T14:33:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [6 August 2020 14:33 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228/1 "2020-08-06T14:33:14Z")

</div>

Hello,

So modbus serial reader node reads in the data as one big array line, it reads it in as a in 16 type. My issue is that the registers on my device are both int 16 and IEEE754 float. I can`t find a way exactly to read the specific registers at their correct value. Only all in in16. What I would like to do is take this in16 bit data and convert it into the right reading for IEEE754.

I`m not sure exactly how to do that - any ideas anyone?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 August 2020 14:52 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228/2 "2020-08-06T14:52:02Z")

</div>

I haven't used it but I have seen node-red-contrib-buffer-parser recommended for such situations.

---

<div class="post-metadata">

**Author:** ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)\
**Post date:** [6 August 2020 15:00 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228/3 "2020-08-06T15:00:51Z")

</div>

Hi Colin, thats the node I`m referring to, sadly the buffer parser takes the data and combines them into int 16 or at a certain length / offset the correct data type. Only problem is that its very difficult to locate the correct register. So ideally i want to take the buffer data in as all int16 and then convert the int 16 parts to the correct type myself.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 August 2020 15:16 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228/4 "2020-08-06T15:16:44Z")

</div>

So what exactly don't you know how to do? Convert two 16 bit ints to a float?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 August 2020 15:27 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228/5 "2020-08-06T15:27:26Z")

</div>

> [@edwardr](#):
>
> sadly the buffer parser takes the data and combines them into int 16 or at a certain length / offset the correct data type

It does byte, 16 bit, 32 bit, 64 bit, float, whatever you want, single items or arrays, output as one object or individual items with topics. It literally does all the heavy lifting.

> [@edwardr](#):
>
> Only problem is that its very difficult to locate the correct register

If you know the correct modbus register, it is very basic - please explain your issue.

> [@edwardr](#):
>
> So ideally i want to take the buffer data in as all int16 and then convert the int 16 parts to the correct type myself.

buffer parser can do that too.

If you can do the following, I can show you exactly how to setup...

1. provide a copy of the modbus output (using the copy button in the debug window)
2. provide a spec (e.g.
  - bytes 0~3 are a float called "temperature" and should be 13.423
  - bytes 4~5 are an int16 called "lux" & should be 54
  - bytes 44~47 make a float called "3ph-voltage" and should contain 415.23
  - etc

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 September 2020 13:27 UTC](https://discourse.nodered.org/t/modbus-array-readings-and-conversion/31228/6 "2020-09-17T13:27:00Z")

</div>

Closed on 17 September 2020 13:27 UTC

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