You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-15Lines changed: 12 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Modbus RTU ⇒ Modbus TCP/UDP Gateway
2
-
Arduino-based Modbus RTU to Modbus TCP/UDP gateway with web interface. Allows you to connect Modbus RTU slaves (such as sensors, energy meters, HVAC devices) to Modbus TCP/UDP masters (such as home automation systems). You can adjust settings through web interface.
2
+
Arduino-based Modbus RTU to Modbus TCP/UDP gateway with web interface. Build your own Modbus gateway from off-the-shelf components (Arduino + ethernet shield + TTL to RS485 module). The gateway allows you to connect Modbus RTU slaves (sensors, energy meters, HVAC devices, etc.) to Modbus TCP/UDP masters (such as home automation systems). Once you have your Modbus gateway up and running, you can adjust its settings through web interface.
@@ -23,7 +23,7 @@ Arduino-based Modbus RTU to Modbus TCP/UDP gateway with web interface. Allows yo
23
23
24
24
# What is it good for?
25
25
26
-
Allows you to connect your Modbus devices (such as sensors, energy meters, HVAC devices) to monitoring systems and home automation systems (such as Loxone, Home Assistant, OpenHAB and other). You do not need commercial Modbus gateways. Arduino (with an ethernet shield and a cheap TTL to RS485 module) can do the job! You can easily change settings of your Arduino Modbus gateway via web interface, your settings are automatically stored in EEPROM.
26
+
Allows you to connect your Modbus devices (sensors, energy meters, HVAC devices, etc.) to monitoring systems and home automation systems (such as Loxone, Home Assistant, OpenHAB and other). You do not need commercial Modbus gateways, build your own Modbus gateway from off-the-shelf components (Arduino + ethernet shield + TTL to RS485 module)! Once you have your Modbus gateway up and running, you can easily change its settings via web interface, your settings are automatically stored in EEPROM.
27
27
28
28
# Technical specifications
29
29
@@ -60,23 +60,20 @@ Allows you to connect your Modbus devices (such as sensors, energy meters, HVAC
60
60
- requests to responding slaves are prioritized over requests to non-responding slaves
61
61
- queue size configured in advanced settings (sketch)
62
62
* user settings:
63
-
- can be changed via web interface (see screenshots bellow)
63
+
- can be changed via web interface (see screenshots bellow), all web UI inputs have proper validation
64
64
- stored in EEPROM
65
65
- retained during firmware upgrade (only in case of major version change, Arduino loads factory defaults)
66
-
- all web interface inputs have proper validation
67
-
- factory defaults for user settings can be specified in advanced_settings.h
68
-
- settings marked \* are only available if ENABLE_DHCP is defined in the sketch
69
-
- settings marked \*\* are only available if ENABLE_EXTENDED_WEBUI is defined in the sketch
66
+
- factory defaults for user settings can be changed in advanced_settings.h
70
67
* advanced settings:
71
-
- can be changed in sketch (advanced_settings.h)
68
+
- can be changed in sketch before comnpilation (advanced_settings.h)
72
69
- stored in flash memory
73
70
74
71
# Hardware
75
-
Get the hardware (cheap clones from China are sufficient) and connect together:
72
+
Get the hardware and connect together:
76
73
77
74
***Arduino Nano, Uno or Mega** (and possibly other boards with ATmega chips).<br>On Mega you have to configure Serial in advanced settings in the sketch.
78
75
***Ethernet shield with WIZnet chip (W5100, W5200 or W5500)**.<br>The ubiquitous W5100 shield for Uno/Mega is sufficient. If available, I recommend W5500 Ethernet Shield. You can also use combo board MCU + ethernet (such as ATmega328 + W5500 board from Keyestudio).<br>ATTENTION: Ethernet shields with ENC28J60 chip will not work !!!
79
-
***TTL to RS485 module with an automatic flow direction control**.<br>You can buy cheap modules with MAX3485, MAX13487, SP485 or SP3485 chips (some of these modules are branded as "XY-017", "XY-485", "XY-G485", etc.) from Aliexpress and other marketplaces.<br>ATTENTION: Modules with MAX485 chip will work (use pin 6 for DE+RE), but are NOT recommended (no auto-direction, no ESD protection, no hot-swap protection) !!!
76
+
***TTL to RS485 module with an automatic flow direction control**.<br>You can buy cheap modules with MAX485, MAX3485, MAX13487, SP485 or SP3485 chips (some of these modules are branded as "XY-017", "XY-485", "XY-G485", etc.) from Aliexpress and other marketplaces.<br>ATTENTION: Some TTL module manufacturers invert TX and RX !!! If you experience problems, try to swap TXD and RXD.<br>ATTENTION: Avoid those ubiquitous MAX485 modules with manual direction control (DE and RE pins). They will work (use Arduino pin 6 for DE+RE), but are NOT recommended (no auto-direction, no ESD protection, no hot-swap protection) !!!
80
77
***External power supply**.<br>Use regulated 5V external power supply for both the Arduino (+ the ethernet shield) and the RS485 module.<br>ATTENTION: By using the 5V pin, you are bypassing Arduino's built-in voltage regulator and reverse-polarity protection curcuit. Make sure your external power supply does not exceed 5,5V !!!
81
78
82
79
<imgsrc="pics/fritzing.png"alt="fritzing" />
@@ -131,9 +128,9 @@ Enjoy :-)
131
128
***Slave Responded with Error (Codes 1~8)**. Slave responded, but with an error. For the list of error codes see [Wikipedia](https://en.wikipedia.org/wiki/Modbus#Exception_responses).
132
129
***Gateway Overloaded (Code 10)**. Request queue is full (either the number of bytes stored or the number of requests stored). Request was dropped and the gateway responded with an error code 10.
133
130
***Slave Failed to Respond (Code 11)**. Slave is not responding. Response timeouts have passed, all attempts have failed. The gateway responded with an error code 11.
134
-
***Invalid TCP/UDP Request**. Invalid request was received via TCP or UDP. Request was dropped, no response was sent by the gateway. Validation criteria depends on the Modbus mode:
131
+
***Invalid TCP/UDP Request**. Invalid request was received via TCP or UDP. Request was dropped, no response was sent by the gateway. Validation criteria depend on the Modbus mode:
135
132
- Modbus TCP/UDP: MBAP header (protocol identifier is 0x0000, length is < 255 and corresponds to the number of bytes in the remainder of the Modbus request)
136
-
- Modbus RTU over TCP/UDP: CRC ckeck
133
+
- Modbus RTU over TCP/UDP: CRC check
137
134
***Invalid RTU Response**. Invalid data were recieved via RS485. Could be caused by wrong Modbus RTU settings, short response timeout (any response arriving after timeout is invalid) or Arduino delays in processing the response. Validation criteria:
138
135
- silence between individual bytes is shorter than char timeout specified in Modbus RTU standards
139
136
- CRC check
@@ -145,13 +142,13 @@ Enjoy :-)
145
142
***UDP**. Only the last Modbus UDP master is shown, because all UDP masters connect to the same socket.
146
143
***TCP**. All connected Modbus TCP masters are shown. Each Modbus TCP connection occupies one socket.
147
144
148
-
**Modbus Slaves**. Shows the slave address (in hex) and the last status (error) for all slaves who responded to a slave scan or who were recipients of a Modbus request.
145
+
**Modbus Slaves**. Shows slave addresses (in hex) and last statuses (errors) for all slaves which responded to a slave scan or which were recipients of a Modbus request.
149
146
150
147
**Scan Slaves**. An attempt is made to find Modbus RTU slaves connected to the RS485 interface:
151
148
- scan is launched automaticaly after boot or manualy
152
149
- scans all slave addresses 1 - 247
153
150
- dummy requests are sent to each slave address for two different Modbus functions (configured in advanced settings)
154
-
- fixed response timeout (very short, configured in advanced settings), only one attempt
151
+
- fixed response timeout is ised (very short, configured in advanced settings), only one attempt is made
155
152
- gateway marks the slave as "Slave Responded" if any response is sent by the slave (even error)
**Load Default Settings**. Loads default settings (see DEFAULT_CONFIG in advanced settings). MAC address is retained.
202
+
**Load Default Settings**. Erases user settings stored in EEPROM (only **EEPROM Health** and **MAC Address** are retained). Loads default settings from flash memory (see DEFAULT_CONFIG in advanced_settings.h).
0 commit comments