Skip to content

Commit 3fca360

Browse files
add RP2 and pyboard pin usage examples for RTU examples in documentation, relates to #7 and #17
1 parent 2ef05ef commit 3fca360

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

docs/EXAMPLES.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,22 @@ RTU (serial/UART) to a requesting host device.
2727
from umodbus.serial import ModbusRTU
2828

2929
# RTU Client/Slave setup
30-
# the following example is for an ESP32
30+
31+
# the following definition is for an ESP32
3132
rtu_pins = (25, 26) # (TX, RX)
33+
uart_id = 1
34+
35+
# the following definition is for a RP2
36+
# rtu_pins = (Pin(0), Pin(1)) # (TX, RX)
37+
# uart_id = 0
38+
#
39+
# rtu_pins = (Pin(4), Pin(5)) # (TX, RX)
40+
# uart_id = 1
41+
42+
# the following definition is for a pyboard
43+
# rtu_pins = (Pin(PB6), Pin(PB7)) # (TX, RX)
44+
# uart_id = 1
45+
3246
slave_addr = 10 # address on bus as client
3347

3448
client = ModbusRTU(
@@ -39,7 +53,7 @@ client = ModbusRTU(
3953
# stop_bits=1, # optional, default 1
4054
# parity=None, # optional, default None
4155
# ctrl_pin=12, # optional, control DE/RE
42-
# uart_id=1 # optional, see port specific documentation
56+
uart_id=uart_id # optional, default 1, see port specific documentation
4357
)
4458

4559
register_definitions = {
@@ -95,8 +109,21 @@ setting data at a RTU (serial/UART) client/slave.
95109
from umodbus.serial import Serial as ModbusRTUMaster
96110

97111
# RTU Host/Master setup
98-
# the following example is for an ESP32
112+
113+
# the following definition is for an ESP32
99114
rtu_pins = (25, 26) # (TX, RX)
115+
uart_id = 1
116+
117+
# the following definition is for a RP2
118+
# rtu_pins = (Pin(0), Pin(1)) # (TX, RX)
119+
# uart_id = 0
120+
#
121+
# rtu_pins = (Pin(4), Pin(5)) # (TX, RX)
122+
# uart_id = 1
123+
124+
# the following definition is for a pyboard
125+
# rtu_pins = (Pin(PB6), Pin(PB7)) # (TX, RX)
126+
# uart_id = 1
100127

101128
host = ModbusRTUMaster(
102129
pins=rtu_pins, # given as tuple (TX, RX)
@@ -105,7 +132,7 @@ host = ModbusRTUMaster(
105132
# stop_bits=1, # optional, default 1
106133
# parity=None, # optional, default None
107134
# ctrl_pin=12, # optional, control DE/RE
108-
# uart_id=1 # optional, see port specific documentation
135+
uart_id=uart_id # optional, default 1, see port specific documentation
109136
)
110137

111138
coil_status = host.read_coils(slave_addr=10, starting_addr=123, coil_qty=1)

0 commit comments

Comments
 (0)