# Node-red-contrib-modbus with RTU 485 device over PI 485 shield

**URL:** <https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734>\
**Category:** Industrial\
**Created:** [18 December 2020 23:21 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734 "2020-12-18T23:21:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mellis](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mellis/32/27014_2.png) [@mellis](https://discourse.nodered.org/u/mellis)\
**Post date:** [18 December 2020 23:21 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734/1 "2020-12-18T23:21:50Z")

</div>

I installed a Seeed RS-485 Shield for Raspberry Pi on a new raspberry Pi4, ran sudo raspi-config, selected “3” interface options, selected P6 serial port, disabled shell, enabled serial port hardware.  
I goto into node-red on the pi and am using the node-red-contrib-modbus “modbus read node” and it now finds dev/ttyS0 which I believe is the 485 shield.  
The debug msg below shows my errors.

I know my slave settings (baud, data bit, stop bit, parity) are good as I have another modbus master which which works fine with this slave.

Debug msg.  
12/18/2020, 4:18:16 PMnode: 88a2045f.091c28  
polling : msg : Object  
object  
topic: "polling"  
from: ""  
payload: ""  
queueLengthByUnitId: object  
unitId: 1  
queueLength: 0  
queueUnitId: 1  
unitId: 1  
error: object  
name: "TransactionTimedOutError"  
message: "Timed out"  
errno: "ETIMEDOUT"  
nodeStatus: "timeout"  
\_msgid: "626fb5ee.5115ac"

any helpful ideas? I'd love to make this work & I'm really stumped here.

thank you in advance.

this test does nothing.

```auto
[{"id":"d32d366e.2f8c88","type":"serial in","z":"d7b3fdd7.b470a","name":"","serial":"28624537.d44aca","x":250,"y":280,"wires":[["492b1c0d.d20e24"]]},{"id":"9c8b9130.8e265","type":"serial out","z":"d7b3fdd7.b470a","name":"","serial":"28624537.d44aca","x":510,"y":420,"wires":[]},{"id":"492b1c0d.d20e24","type":"debug","z":"d7b3fdd7.b470a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":280,"wires":[]},{"id":"214e3fea.bc61e","type":"inject","z":"d7b3fdd7.b470a","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello World","payloadType":"str","x":240,"y":420,"wires":[["9c8b9130.8e265"]]},{"id":"28624537.d44aca","type":"serial-port","serialport":"/dev/ttyS0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"0x0d","bin":"false","out":"char","addchar":"","responsetimeout":"10000"}]

```

this is my modbus code, gives error

```auto
[{"id":"db4ad0d4.09fa7","type":"modbus-read","z":"d7b3fdd7.b470a","name":"","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"InputRegister","adr":"1019","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"3e181657.796eda","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"x":190,"y":280,"wires":[["88a2045f.091c28"],["88a2045f.091c28"]]},{"id":"3e181657.796eda","type":"modbus-client","name":"","clienttype":"serial","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyS0","serialType":"RTU","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

This is another modbus master (hardware and software) configured and tested on the same ModBus slave tied to tied Pi w NodeRed. Obviously not at the same time. It works fine, I'm sharing it to show a successful configuration.

 ![modbus_network](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/3/d336802faa2ea994f747731d6445d053e2c22146.png) ![modbus_point](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c1930b36e6925cd7110caa0c4969b1fbce72ebd8.png) ![modbus_slaveDevice](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c74594a90790b89e8b2f4068e4817e402580b2d0.png)

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [19 December 2020 07:16 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734/2 "2020-12-19T07:16:53Z")

</div>

I would have thought that an add-on shield would not have the designation of ttyS0 - would have thought it would be higher up.

Have you checked the permissions on that object - ensured that your user that is starting up NR on the PI has rights to the correct tty object ?

Craig

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [19 December 2020 08:45 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734/3 "2020-12-19T08:45:04Z")

</div>

I have a Pi with a RS485 shield that works, If I am correct this article was helpful

> **[Configuring The GPIO Serial Port On Raspbian Jessie and Stretch Including Pi...](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3-4/)**
>
> The Raspberry Pi GPIO serial port configuration has changed under Jessie / Stretch / Buster and also with the Raspberry PI 3 / 4. How to set it up.

---

<div class="post-metadata">

**Author:** ![mellis](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mellis/32/27014_2.png) [@mellis](https://discourse.nodered.org/u/mellis)\
**Post date:** [20 December 2020 14:09 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734/4 "2020-12-20T14:09:48Z")

</div>

Thank you mtoko, the link you provided took me in directions I would have never though of.  
Here is what I did:

this was already in /boot/config.txt  
enable\_uart=1

but I added both:  
dtoverlay=pi3-miniuart-bt  
dtoverlay=pi3-disable-bt

now here is what I extracted from $ ls -l /dev  
lrwxrwxrwx 1 root root 7 Dec 19 21:44 serial0 -\> ttyAMA0  
lrwxrwxrwx 1 root root 5 Dec 19 21:44 serial1 -\> ttyS0

even thought I had disabled getty through raspi-config, I ran:  
sudo systemctl stop serial-getty@ttyAMA0.service  
sudo systemctl disable serial-getty@ttyAMA0.servic  
sudo systemctl stop serial-getty@ttyS0.service  
sudo systemctl disable serial-getty@ttyS0.service

On the 485 shield doc it mentions that gpio 18 is an enable so I added to the flow a rpi gpio out set to PIN 12. now when nodeRed polls my modbus slave I get a com light flash. Maybe this is progress?

> **[RS-485 Shield for Raspberry Pi - Seeed Wiki](https://wiki.seeedstudio.com/RS-485_Shield_for_Raspberry_Pi/)**

unfortunately I getting this on every poll:

12/20/2020, 6:51:36 AM[node: e2df6ea2.8bc99](http://192.168.50.86:1880/#)msg : TransactionTimedOutError

and

"TransactionTimedOutError: Timed out"

12/20/2020, 6:51:46 AM[node: e2df6ea2.8bc99](http://192.168.50.86:1880/#)msg : string[60]

"Modbus Failure On State sending Get More About It By Logging"

My current flow is below.

```auto
[{"id":"339d575c.8c9728","type":"rpi-gpio out","z":"ce39ceab.35ce","name":"","pin":"12","set":true,"level":"1","freq":"","out":"out","x":650,"y":280,"wires":[]}]

```

I'm sure this can be made to work, as you mentioned your able to do it. I'm missing something here, it's frustrating but I'm motivated to get this up and running. Any other advise would be highly appreciated.

"TransactionTimeout" I get but I don't know what "Modbus Failure on State sending" is telling me.  
I'm a little new to this, but I've made it my mission to get educated. Thanks to folks like yourself, I'm usually able to get over the roadblocks.

---

<div class="post-metadata">

**Author:** ![mellis](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mellis/32/27014_2.png) [@mellis](https://discourse.nodered.org/u/mellis)\
**Post date:** [7 January 2021 05:59 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734/5 "2021-01-07T05:59:14Z")

</div>

I used one of these instead;  
[https://vetco.net/products/usb-to-rs-485-converter-rs485](https://vetco.net/products/usb-to-rs-485-converter-rs485)  
worked perfectly!

---

<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:** [21 January 2021 05:59 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-with-rtu-485-device-over-pi-485-shield/37734/6 "2021-01-21T05:59:17Z")

</div>

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