# Modbus tcp data type real

**URL:** <https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400>\
**Category:** General\
**Tags:** modbus, function-node\
**Created:** [13 August 2022 15:41 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400 "2022-08-13T15:41:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dalen98](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Dalen98](https://discourse.nodered.org/u/Dalen98)\
**Post date:** [13 August 2022 15:41 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/1 "2022-08-13T15:41:15Z")

</div>

Hello everyone, I was learning about the modbus nodes for node red and as you will see in the images if I can make a communication, I am working with a siemens s7 1200 plc

 ![foro 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/edb595280c123e49bf367e6de1de1293fa699363.png)  
 ![foto2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e3a26c41405960a13bb31a549121fc40bac2f34.png)  
up to there everything perfect, but that is when my modbus registers are integers (int) as you see in the image, but I want to put registers with floating point values ​​(Real)  
 ![foto3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c9e224d145ef72e790f2ff6afed284afebb2f086.png)  
but what I get when reading the logs is this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/cc7eb5b2881dafff52ffb22ace6084c475d3f8a0.png)  
 ![foto5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b0cc291caf618beb219d8e43ce6cdc803283983.png)  
I obviously want to obtain the values ​​(12.4564 and 3.456) in the red node, which are the real type values ​​that I placed.  
Maybe it's because now my registers are 32 bits instead of 16 bits, but I'm not sure.  
I hope I made myself understood, thanks in advance

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 August 2022 15:58 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/2 "2022-08-13T15:58:29Z")

</div>

> [@Dalen98](#):
>
> siemens s7 1200 plc

Have you tried the S7 node ? maybe you can read those variables directly without having to send them over modbus ?

> **[node-red-contrib-s7](https://flows.nodered.org/node/node-red-contrib-s7)**
>
> A Node-RED node to interact with Siemens S7 PLCs

---

<div class="post-metadata">

**Author:** ![Dalen98](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Dalen98](https://discourse.nodered.org/u/Dalen98)\
**Post date:** [13 August 2022 16:07 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/3 "2022-08-13T16:07:48Z")

</div>

Of course I have used that node, but let's say I have that inconvenience, of course with the s7 node it is much easier, but I also want to learn modbus communication well to be able to use a schneider plc for example 🙂

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 August 2022 16:18 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/4 "2022-08-13T16:18:12Z")

</div>

I see .. In that case .. yes Float values are usually 32bit .. and you read 2 x 16bit registers and use a handy node like [node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser) to convert them

I dont know anything about Siemens or how you can send the values in 2 mob. registers  
.. but if you already have that set then add a Debug node ( **set to complete msg object** ) after your Modbus Flex getter node, capture a msg and share it in a post, tell us what the expected value should be to help you convert it.

---

<div class="post-metadata">

**Author:** ![Dalen98](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Dalen98](https://discourse.nodered.org/u/Dalen98)\
**Post date:** [13 August 2022 16:44 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/5 "2022-08-13T16:44:47Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b1e7618d435e8894c57901563998996575ca5d1f.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1fd98e6e674d1ece167eb8a513dc5a6f5b5b6121.png)

in this case I am reading 16 modbus registers since my variables are real and each one is equivalent to 2 registers, am I correct?

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 August 2022 16:51 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/6 "2022-08-13T16:51:23Z")

</div>

> [@Dalen98](#):
>
> each one is equivalent to 2 registers, am I correct?

yeap 😉 .. and here is a flow with buffer-parser that makes it into a float  
i used a buffer-maker to simulate data coming from your modbus node

```auto
[{"id":"5e512e1cfc7214dc","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":3700,"wires":[["0f6fb6f8c466c8b4"]]},{"id":"0f6fb6f8c466c8b4","type":"buffer-maker","z":"54efb553244c241f","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"int16be","length":1,"dataType":"num","data":"16711"},{"name":"item2","type":"int16be","length":1,"dataType":"num","data":"19818"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":450,"y":3700,"wires":[["8f91c7f34ad3bde6","e406862c9e6c737c"]]},{"id":"b4e162de82a6fcdb","type":"debug","z":"54efb553244c241f","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":3700,"wires":[]},{"id":"8f91c7f34ad3bde6","type":"buffer-parser","z":"54efb553244c241f","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":810,"y":3700,"wires":[["b4e162de82a6fcdb"]]},{"id":"e406862c9e6c737c","type":"debug","z":"54efb553244c241f","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":3620,"wires":[]},{"id":"273ac606199b13dd","type":"comment","z":"54efb553244c241f","name":"From Modbus node","info":"","x":470,"y":3760,"wires":[]}]

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/057e3b39c9de1f537a2326e38056d5a0c3b40f6f.png)

---

<div class="post-metadata">

**Author:** ![Dalen98](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Dalen98](https://discourse.nodered.org/u/Dalen98)\
**Post date:** [13 August 2022 17:03 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/7 "2022-08-13T17:03:46Z")

</div>

thanks, I was analyzing the flow, I changed the data and look what came out :c

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7bc51490729d48697246da1336e21477f4d21495.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/dadb16de4b7d31d72230f87651c828dee0e69747.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 August 2022 17:13 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/8 "2022-08-13T17:13:26Z")

</div>

wait .. your weren't meant to use the buffer-maker for your setup .. that was just to create the buffer to simulate your data .. since i dont have your device  
just use the **Buffer-parser** node right after your Modbus node, set to convert to float(be)

**[EDIT]**

my mistake .. after looking at the error a bit more closely it was the buffer-maker that was out of range .. meaning the 2 x 16bit values should have been configured as unisigned UInt16

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e6d0efa43775da2db6bd35d2f548a2e4d6218c2.png)

---

<div class="post-metadata">

**Author:** ![Dalen98](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Dalen98](https://discourse.nodered.org/u/Dalen98)\
**Post date:** [15 August 2022 13:53 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/9 "2022-08-15T13:53:34Z")

</div>

now it works great and i can see the real data of my plc, thank you very much for taking your time and helping me 🙂

---

<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:** [29 August 2022 13:54 UTC](https://discourse.nodered.org/t/modbus-tcp-data-type-real/66400/10 "2022-08-29T13:54:01Z")

</div>

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