# Reading Modbus TCP data

**URL:** <https://discourse.nodered.org/t/reading-modbus-tcp-data/59842>\
**Category:** General\
**Created:** [14 March 2022 12:58 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842 "2022-03-14T12:58:53Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)\
**Post date:** [14 March 2022 12:58 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/1 "2022-03-14T12:58:53Z")

</div>

Hi

I want to read some data from Modbus TCP, but it didn't work and I don't know where the problem is

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/4/64a6b34a9d526f1b4cefa63fe92e392b4a0ed900.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5c0a8265781cccbb603fbcfb7557fa0b6421d0c3.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/783148e5ea4ec23ced7f4818e2235902a96c53cd.png)

```auto
[{"id":"9a63982dc9dc282c","type":"modbus-read","z":"6b9454ad03aaa289","name":"Voltage","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"61","dataType":"HoldingRegister","adr":"0","quantity":"46","rate":"10","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"62a4b715be1f5c5b","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":210,"y":260,"wires":[["bbd8805693f01e58"],[]]},{"id":"bbd8805693f01e58","type":"buffer-parser","z":"6b9454ad03aaa289","name":"test","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item2","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item3","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item4","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item5","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item6","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item7","offset":24,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item8","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item9","offset":32,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item10","offset":36,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item11","offset":40,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item12","offset":44,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item13","offset":48,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item14","offset":52,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item15","offset":56,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item16","offset":60,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item17","offset":64,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item18","offset":68,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item19","offset":72,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item20","offset":76,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item21","offset":80,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item22","offset":84,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item23","offset":88,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":390,"y":260,"wires":[["6ac769f038435cd4"]]},{"id":"6ac769f038435cd4","type":"debug","z":"6b9454ad03aaa289","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":260,"wires":[]},{"id":"62a4b715be1f5c5b","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"Smappee5130007388","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"61","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

---

<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:** [14 March 2022 13:16 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/2 "2022-03-14T13:16:28Z")

</div>

> [@Milanovic](#):
>
> but it didn't work and I don't know where the problem is

Since we cannot see inside your node-red flows, dont have connection to your network or devices and we have no idea what devices you are using, you will need to provide more info.

- Is the node-red server connected to the same network as the device?

- Can you ping `Smappee513007388` from node-red (use node-red-node-ping)?

- Are the settings correct?

- Are you seeing errors?

- What node package is this?

- What versions of node-red and node-js are you using?

---

<div class="post-metadata">

**Author:** ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)\
**Post date:** [14 March 2022 13:25 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/3 "2022-03-14T13:25:02Z")

</div>

I can ping to it

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87182e0fc7ff23d1b3a369f41213f1cc50292dcb.png)

---

<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:** [14 March 2022 13:38 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/4 "2022-03-14T13:38:56Z")

</div>

1. That is not what I asked. I said "Can you ping `Smappee513007388` from node-red (use node-red-node-ping)?"

2. what about the 5 other questions?

---

<div class="post-metadata">

**Author:** ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)\
**Post date:** [14 March 2022 13:56 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/5 "2022-03-14T13:56:41Z")

</div>

- The settings are correct

- I don't see any error

- node-red-contrib-modbus

- 5.21.0

- The ping works in node-red also

---

<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:** [14 March 2022 14:32 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/6 "2022-03-14T14:32:51Z")

</div>

- What are the nodejs and node-red versions?

- What OS are you running node-red on?

- Is the firewall blocking port 502?

- How are you starting node-red (as a service or from a terminal)?

---

<div class="post-metadata">

**Author:** ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)\
**Post date:** [14 March 2022 14:33 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/7 "2022-03-14T14:33:39Z")

</div>

The modbus getter is directly active..  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d1507cad8c64edbf34eb66f014dc7c1762e8e6b.png)

---

<div class="post-metadata">

**Author:** ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)\
**Post date:** [14 March 2022 14:36 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/8 "2022-03-14T14:36:11Z")

</div>

nodejs version: v16.14.0  
OS : opdrachtprompt  
I don't know, it already worked once  
as a service, I do 'node-red' and enter

---

<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:** [14 March 2022 14:39 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/9 "2022-03-14T14:39:53Z")

</div>

> [@Milanovic](#):
>
> as a service, I do 'node-red' and enter

That is not a service. A service is a program that runs even after you log off. You are running from command prompt. In which case, what (if anything) do you see in the command prompt (terminal) when you operate the "Modbus Read"?

Q: Is the Modbus Read always displaying "waiting"

Q2: Can you attach a debug node to BOTH outputs of the modbus nodes (set the debug nodes to show the complete message) - do you see any messages in the debug sidebar?

---

<div class="post-metadata">

**Author:** ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)\
**Post date:** [14 March 2022 14:43 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/10 "2022-03-14T14:43:13Z")

</div>

Ok,

Yes it's constantly displaying 'waiting'

If I set the debug nodes, there comes nothing in the debug sidebar

---

<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:** [14 March 2022 15:25 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/11 "2022-03-14T15:25:30Z")

</div>

This looks like either a firewall issue (blocking port 502) or the device is simply not responding (settings changed? device crashed?)

---

<div class="post-metadata">

**Author:** ![StrongTown](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@StrongTown](https://discourse.nodered.org/u/StrongTown)\
**Post date:** [18 March 2022 15:59 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/12 "2022-03-18T15:59:29Z")

</div>

Quick Q. I'm a little surprised to see that your (starting register) `Address` for the read is` 0` (zero). If you do connect, your setup will try to read registers 0 to 45. Is that what you seek?

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [18 March 2022 21:05 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/13 "2022-03-18T21:05:42Z")

</div>

You can test your configuration with this free tool that will help you confirm or not your actual configuration.

[Modbus Doctor](https://www.kscada.com/modbusdoctor.html) free.

---

<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 May 2022 21:06 UTC](https://discourse.nodered.org/t/reading-modbus-tcp-data/59842/14 "2022-05-17T21:06:05Z")

</div>

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