# Modbustcp-read Function Script

**URL:** https://discourse.nodered.org/t/modbustcp-read-function-script/71034
**Category:** General
**Tags:** function-node
**Created:** [22 November 2022 08:00 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034 "2022-11-22T08:00:48Z")
**Posts on this page:** 20
**Page:** 4

<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: [26 November 2022 17:34 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/61 "2022-11-26T17:34:19Z")

</div>

> [@Cupra85](#):
>
> no debug output.

Nothing? No values? No Error?

Did you deploy? Perhaps you have the debug pane filtered?

Make sure "All Nodes" is set  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/2/d2e61e3096d54e75ed8b4c95103950c897940df2.png)

Check the ModBus config is ticked to log failures...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8b6edd095052ff5102b7da98c615cf4bca350f4.png)

Lastly, put something (anything) in the inject node (should not matter but you never know). I would suggest add a `payload` of `true` and `topic` of `read`

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [26 November 2022 19:50 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/62 "2022-11-26T19:50:15Z")

</div>

now reaction

26.11.2022, 20:46:03[node: Top output](http://192.168.178.108/addons/red/#)read : msg : Object  
object  
topic: "read"  
messageId: "63826cfb1445cdc448be33d3"  
payload: array[77]  
queueLengthByUnitId: object  
queueUnitId: 1  
unitId: 1  
modbusRequest: object  
responseBuffer: object  
msgid: "6eb367ed.aedee8"

26.11.2022, 20:46:03[node: Bottom Output](http://192.168.178.108/addons/red/#)read : msg : Object  
object  
topic: "read"  
messageId: "63826cfb1445cdc448be33d3"  
payload: object  
queueLengthByUnitId: object  
queueUnitId: 1  
unitId: 1  
modbusRequest: object  
values: array[77]  
msgid: "6eb367ed.aedee8"

---

<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: [26 November 2022 20:00 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/63 "2022-11-26T20:00:05Z")

</div>

You need to use the copy value button. And you need to put it in a code block

> [@Steve-Mcl](#):
>
> Also, "Copy Value" and paste into a codeblock...  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd4b471e4dd7f137de53526954ecc60db5ba9d4e.png)

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [26 November 2022 20:00 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/64 "2022-11-26T20:00:36Z")

</div>

if i put this trigger and modbus getter in front of a function, the chlorine will show up on my CCU. 😃

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [26 November 2022 20:01 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/65 "2022-11-26T20:01:44Z")

</div>

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"responseBuffer":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"_msgid":"6eb367ed.aedee8"}

```

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"values":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"_msgid":"6eb367ed.aedee8"}

```

---

<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: [26 November 2022 20:19 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/66 "2022-11-26T20:19:51Z")

</div>

ok. so as I was trying to explain yesterday...

> [@Steve-Mcl](#):
>
> Since the op is requesting registers between 100 and 176, The better solution would be to have one single poll of 78 items from address 100 and then grab & convert the values from the returned buffer in one go. That's 1 single poll & guaranteed data consistency.
> 
> The flow would simply become...
> 
> Inject \> read fc3 from address 100 x78 \> buffer-parser
> 
> That's it. All values would be extracted and parsed and named in the object.
> 
> If I get a chance tomorrow I'll provide a demo.
> 
> Alternatively, see this previous thread: [Need some help with float numbers - #2 by Steve-Mcl](https://discourse.nodered.org/t/need-some-help-with-float-numbers/48292/2)

Now that you have data arriving, I can demonstrate what I meant...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c1618929ef643112651d257d834fd4f8ff642499.png)

```auto
[{"id":"9b982f6b6b8d11e1","type":"inject","z":"e4f0ea06.4e5b38","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":440,"wires":[["3b6ecb12fbe3cde8"]]},{"id":"3b6ecb12fbe3cde8","type":"function","z":"e4f0ea06.4e5b38","name":"Fake ModBus","func":"const top = {\n \"topic\": \"read\",\n \"messageId\": \"63826cfb1445cdc448be33d3\",\n \"payload\": {\n \"data\": [\n 15651,\n 26477,\n 27695,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16256,\n 13107,\n 16179,\n 0,\n 0,\n 62915,\n 16600,\n 18544,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16512,\n 0,\n 16656,\n 13107,\n 16611,\n 0,\n 0,\n 16384,\n 17499,\n 22125,\n 0,\n 0,\n 0,\n 0,\n 0,\n 17352,\n 0,\n 17505,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 39322,\n 16617,\n 17328\n],\n \"buffer\": [\n 61,\n 35,\n 103,\n 109,\n 108,\n 47,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 63,\n 128,\n 51,\n 51,\n 63,\n 51,\n 0,\n 0,\n 0,\n 0,\n 245,\n 195,\n 64,\n 216,\n 72,\n 112,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 64,\n 128,\n 0,\n 0,\n 65,\n 16,\n 51,\n 51,\n 64,\n 227,\n 0,\n 0,\n 0,\n 0,\n 64,\n 0,\n 68,\n 91,\n 86,\n 109,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 67,\n 200,\n 0,\n 0,\n 68,\n 97,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 60,\n 0,\n 70,\n 28,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 60,\n 0,\n 70,\n 28,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 153,\n 154,\n 64,\n 233,\n 67,\n 176\n]\n },\n \"queueLengthByUnitId\": {\n \"unitId\": 1,\n \"queueLength\": 0\n },\n \"queueUnitId\": 1,\n \"unitId\": 1,\n \"modbusRequest\": {\n \"value\": \"true\",\n \"unitid\": \"1\",\n \"fc\": 3,\n \"address\": \"100\",\n \"quantity\": \"77\",\n \"messageId\": \"63826cfb1445cdc448be33d3\"\n },\n \"values\": [\n 15651,\n 26477,\n 27695,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16256,\n 13107,\n 16179,\n 0,\n 0,\n 62915,\n 16600,\n 18544,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16512,\n 0,\n 16656,\n 13107,\n 16611,\n 0,\n 0,\n 16384,\n 17499,\n 22125,\n 0,\n 0,\n 0,\n 0,\n 0,\n 17352,\n 0,\n 17505,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 39322,\n 16617,\n 17328\n],\n \"_msgid\": \"6eb367ed.aedee8\"\n}\n\nconst bottom = {\n \"topic\": \"read\",\n \"messageId\": \"63826cfb1445cdc448be33d3\",\n \"payload\": [\n 15651,\n 26477,\n 27695,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16256,\n 13107,\n 16179,\n 0,\n 0,\n 62915,\n 16600,\n 18544,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16512,\n 0,\n 16656,\n 13107,\n 16611,\n 0,\n 0,\n 16384,\n 17499,\n 22125,\n 0,\n 0,\n 0,\n 0,\n 0,\n 17352,\n 0,\n 17505,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 39322,\n 16617,\n 17328\n],\n \"queueLengthByUnitId\": {\n \"unitId\": 1,\n \"queueLength\": 0\n },\n \"queueUnitId\": 1,\n \"unitId\": 1,\n \"modbusRequest\": {\n \"value\": \"true\",\n \"unitid\": \"1\",\n \"fc\": 3,\n \"address\": \"100\",\n \"quantity\": \"77\",\n \"messageId\": \"63826cfb1445cdc448be33d3\"\n },\n \"responseBuffer\": {\n \"data\": [\n 15651,\n 26477,\n 27695,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16256,\n 13107,\n 16179,\n 0,\n 0,\n 62915,\n 16600,\n 18544,\n 0,\n 0,\n 0,\n 0,\n 0,\n 16512,\n 0,\n 16656,\n 13107,\n 16611,\n 0,\n 0,\n 16384,\n 17499,\n 22125,\n 0,\n 0,\n 0,\n 0,\n 0,\n 17352,\n 0,\n 17505,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 15360,\n 17948,\n 0,\n 0,\n 0,\n 0,\n 39322,\n 16617,\n 17328\n],\n \"buffer\": [\n 61,\n 35,\n 103,\n 109,\n 108,\n 47,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 63,\n 128,\n 51,\n 51,\n 63,\n 51,\n 0,\n 0,\n 0,\n 0,\n 245,\n 195,\n 64,\n 216,\n 72,\n 112,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 64,\n 128,\n 0,\n 0,\n 65,\n 16,\n 51,\n 51,\n 64,\n 227,\n 0,\n 0,\n 0,\n 0,\n 64,\n 0,\n 68,\n 91,\n 86,\n 109,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 67,\n 200,\n 0,\n 0,\n 68,\n 97,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 60,\n 0,\n 70,\n 28,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 60,\n 0,\n 70,\n 28,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 153,\n 154,\n 64,\n 233,\n 67,\n 176\n]\n },\n \"_msgid\": \"6eb367ed.aedee8\"\n}\n\n\nreturn [top, bottom]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1460,"y":440,"wires":[["6baca02393f91069"],["7a7155e33e5a7852","576c4564f2231d89"]]},{"id":"7a7155e33e5a7852","type":"buffer-parser","z":"e4f0ea06.4e5b38","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"chlor_wert","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"ph_wert","offset":15,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"redox_wert","offset":30,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"temp","offset":75,"length":1,"offsetbit":0,"scale":"/1000","mask":""},{"type":"floatbe","name":"cl_soll","offset":11,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"ph_soll","offset":26,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item7","offset":13,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item8","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":true,"setTopic":true,"outputs":8,"x":1670,"y":520,"wires":[["d9f3de12.3a2ee"],["c045f3ba.6deb1"],["3d44e72ce57e05ce"],["fac4119b3456ef55"],[],[],[],[]]},{"id":"d9f3de12.3a2ee","type":"debug","z":"e4f0ea06.4e5b38","name":"chlor_wert","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1990,"y":380,"wires":[]},{"id":"c045f3ba.6deb1","type":"debug","z":"e4f0ea06.4e5b38","name":"ph_wert","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1980,"y":440,"wires":[]},{"id":"3d44e72ce57e05ce","type":"debug","z":"e4f0ea06.4e5b38","name":"redox_wert","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1990,"y":500,"wires":[]},{"id":"6baca02393f91069","type":"debug","z":"e4f0ea06.4e5b38","name":"data top","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1660,"y":380,"wires":[]},{"id":"576c4564f2231d89","type":"debug","z":"e4f0ea06.4e5b38","name":"data bottom","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1670,"y":440,"wires":[]},{"id":"fac4119b3456ef55","type":"debug","z":"e4f0ea06.4e5b38","name":"temp","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1970,"y":560,"wires":[]}]

```

NOTES...

1. You will need to install `node-red-buffer-parser`
2. I have no idea what the specification of your data is (so I guessed in the buffer-parser)

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [26 November 2022 20:32 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/67 "2022-11-26T20:32:08Z")

</div>

Chlor\_wert debug ok  
PH\_wert debug false  
Redox\_wert false (ph\_wert)  
temp false (51grad Celsius)

data top

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"values":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"_msgid":"32af9396.fb658c"}

```

data bottom

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"responseBuffer":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"_msgid":"32af9396.fb658c"}

```

---

<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: [26 November 2022 21:44 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/68 "2022-11-26T21:44:24Z")

</div>

> [@Cupra85](#):
>
> PH\_wert debug false  
> Redox\_wert false (ph\_wert)

As I said, I have no idea what the data is supposed to look like (do you have a manual?)

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [26 November 2022 22:42 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/69 "2022-11-26T22:42:58Z")

</div>

> **[Modbus Tcp Interface - Evoqua WALLACE & TIERNAN 700 P Instruction Manual...](https://www.manualslib.com/manual/2102186/Evoqua-Wallace-And-Tiernan-700-P.html?page=46#manual)**
>
> Evoqua WALLACE & TIERNAN 700 P Manual Online: Modbus Tcp Interface. From software version 1.31 onward, the integrated Ethernet inter- face also supports data communication via Modbus TCP protocol. Various data points are available for data...

Site 46

---

<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: [26 November 2022 23:04 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/70 "2022-11-26T23:04:10Z")

</div>

Ok, so you now have all the info you need right?

 ![Screenshot_20221126-230311](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/512e3da1e686c9fe4bf25d8fafa0a2da60b410d7.png)

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [27 November 2022 08:01 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/71 "2022-11-27T08:01:12Z")

</div>

yes, I had that before. All registers I need and data types. Nevertheless, at offset 15, for example, the wrong PH value comes out.

Can't I make a flex getter for each value?

---

<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: [27 November 2022 08:36 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/72 "2022-11-27T08:36:59Z")

</div>

> [@Cupra85](#):
>
> Nevertheless, at offset 15, for example, the wrong PH value comes out

Sometimes the modbus implementation is off by 1. For example it may be you need offset 16 or offset 14. Sometimes they don't tell you a value is byte swapped etc.

What I'm saying is try stuff.

I can also assist but you would need to provide another "copy value" & a list of values you expect. Without knowing what numbers you are expecting I can not assist further.

What value do you expect from offset 15?

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [27 November 2022 09:08 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/73 "2022-11-27T09:08:50Z")

</div>

> [@Steve-Mcl](#):
>
> What value do you expect from offset 15?

register 115 target value 6.7 (is 8.8)  
I'll try it out

PS:offset 14/16 does not work

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [27 November 2022 10:01 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/74 "2022-11-27T10:01:28Z")

</div>

Data top output

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"values":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"_msgid":"11489ad9.274d35"}

```

Data bottom output

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"responseBuffer":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"_msgid":"11489ad9.274d35"}

```

the first value at data top output is: data and only then values

In addition, not all 77 registers have the same data format and bit size.

---

<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: [27 November 2022 13:41 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/75 "2022-11-27T13:41:36Z")

</div>

> [@Cupra85](#):
>
> In addition, not all 77 registers have the same data format and bit size

I am not certain why you point that out? I am well aware of how devices pack data into 16bit ModBus registers - that is why I proposed you use the buffer-parser since it parses the buffer into whatever shape you need. It extracts either a bit, a byte, a WORD, a Double, a BigInt from whatever position in the input data you specify by the offset.

The manual states, for address 115 that it is a **"FLOAT 4"** value. It goes on to state _ **"The Float or Real values are transferred in accordance with the IEEE754 Standard Format for 32-bit values"** _. This is exactly what the Buffer Parser does (JavaScript/NodeJS adheres to IEEE754 format

HOWEVER, many times, what the manual says and what the firmware does are not the same. For example, often, a value is a UINT32/1000 or it is an INT16/10, sometimes the value is 16 or 32 bit swapped etc etc etc etc.

You have the data, you have the tools, all I can suggest is try different ways of parsing the data. Also, have you tried adding other items to the buffer parser (e.g. offset 26

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [27 November 2022 13:50 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/76 "2022-11-27T13:50:21Z")

</div>

I've already tried, but everything came to the wrong result.

Is it correct that data top output outputs the first value data and then values?

---

<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: [27 November 2022 14:13 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/77 "2022-11-27T14:13:41Z")

</div>

> [@Cupra85](#):
>
> Is it correct that data top output outputs the first value data and then values?

Read the built in help - it explains what each output does.

> [@Cupra85](#):
>
> I've already tried, but everything came to the wrong result.

I can help you but I need very precise info. For example, I need a snapshot of the data (from "Copy Value") AND the EXACT values they should be at the exact time the "Copy Value" was taken.

  

### You need to provide something like ...
  

## Snapshot of data taken at 15:22:37

```auto
*1 [the captured data "Copy Value" output of top + bottom]

```

## Actual values on the device when above snapshot was taken at 15:22:37

| Item | Register | Value on the pool meter when the snapshot was taken |
| --- | --- | --- |
| Chlor Measure Value | 100 | 0.512 &nbsp; &nbsp; `**2` |
| Chlor Setpoint | 111 | 0.500 &nbsp; &nbsp; `**2` |
| pH Measure Value | 115 | 6.8 &nbsp; &nbsp; `**2` |
| pH Setpoint | 126 | 7.2 &nbsp; &nbsp; `**2` |
| Total chlorine Measure Value | 145 | 0.999 &nbsp; &nbsp; `**2` |
| Total chlorine Setpoint | 156 | 0.789 &nbsp; &nbsp; `**2` |
| Temperature Measure Value | 175 | 21.2 &nbsp; &nbsp; `**2` |
| Temperature Lower range | 182 | 19.5 &nbsp; &nbsp; `**2` |
| Temperature Upper range | 184 | 24.5 &nbsp; &nbsp; `**2` |

`*1` &nbsp; Provide "Copy Value" data from modbus  
`**2` Provide REAL values from the Pool Meter - written down at the exact moment that `*1` was done

* * *

Without this I cannot help further.

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [27 November 2022 14:31 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/78 "2022-11-27T14:31:54Z")

</div>

![Unbenannt-2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7faeb284e0059a1dd93d8bb512141604952efeb.jpeg)

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"values":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"_msgid":"f8fc404e.664e4"}

```

```auto
{"topic":"read","messageId":"63826cfb1445cdc448be33d3","payload":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"value":"true","unitid":"1","fc":3,"address":"100","quantity":"77","messageId":"63826cfb1445cdc448be33d3"},"responseBuffer":{"data":[15651,26477,27695,0,0,0,0,0,0,16256,13107,16179,0,0,62915,16600,18544,0,0,0,0,0,16512,0,16656,13107,16611,0,0,16384,17499,22125,0,0,0,0,0,17352,0,17505,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,0,0,0,0,0,0,0,0,0,15360,17948,0,0,0,0,39322,16617,17328],"buffer":[61,35,103,109,108,47,0,0,0,0,0,0,0,0,0,0,0,0,63,128,51,51,63,51,0,0,0,0,245,195,64,216,72,112,0,0,0,0,0,0,0,0,0,0,64,128,0,0,65,16,51,51,64,227,0,0,0,0,64,0,68,91,86,109,0,0,0,0,0,0,0,0,0,0,67,200,0,0,68,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,70,28,0,0,0,0,0,0,0,0,153,154,64,233,67,176]},"_msgid":"f8fc404e.664e4"}

```

---

<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: [27 November 2022 14:35 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/79 "2022-11-27T14:35:29Z")

</div>

No, not good enough I'm afraid. If you want further help, please do respond exactly as I requested.

---

<div class="post-metadata">

### Author: ![Cupra85](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Cupra85](https://discourse.nodered.org/u/Cupra85)
#### Post date: [27 November 2022 14:47 UTC](https://discourse.nodered.org/t/modbustcp-read-function-script/71034/80 "2022-11-27T14:47:30Z")

</div>

you have all the information

[Previous page](https://discourse.nodered.org/t/modbustcp-read-function-script/71034.md?page=3)

[Next page](https://discourse.nodered.org/t/modbustcp-read-function-script/71034.md?page=5)
