Skip to content

Commit 9cdcdb5

Browse files
committed
Screenshot, Readme
1 parent f1c9cd0 commit 9cdcdb5

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Change settings of your Arduino-based Modbus RTU to Modbus TCP/UDP gateway via w
5959

6060
**Reboot**.
6161

62-
**EEPROM Health**. Keeps track of EEPROM write cycles (persistent, never cleared during factory resets)
62+
**EEPROM Health**. Keeps track of EEPROM write cycles (this counter is persistent, never cleared during factory resets). Replace your Arduino once you reach 100 000 write cycles (with 6 hours EEPROM_INTERVAL you have more than 50 years lifespan).
6363

6464
**Ethernet Sockets**. Max number of usable sockets. See Limitations bellow. One socket is reserved for Modbus UDP, remaining sockets are shared between Modbus TCP and WebUI.
6565

@@ -165,11 +165,16 @@ Get the hardware (cheap clones from China are sufficient) and connect together:
165165
Rx0 <-> RO
166166
Pin 6 <-> DE,RE
167167

168-
Here is my setup:
168+
Here is my HW setup:
169169
Terminal shield + Arduino Nano + W5500 ethernet shield (RobotDyn) + TTL to RS485 module (HW automatic flow control)
170170
<img src="/pics/HW.jpg" alt="01" style="zoom:100%;" />
171171

172-
Download this repository (all *.ino files) and open arduino-modbus-rtu-tcp-gateway.ino in Arduino IDE. Download all required libraries (they are available in "library manager"). If you want, you can check the default factory settings (can be later changed via web interface) and advanced settings (can only be changed in the sketch). Compile and upload your program to Arduino. Connect your Arduino to ethernet, connect your Modbus RTU slaves to MAX485 module. Use your web browser to access the web interface on default IP http://192.168.1.254 Enjoy :-)
172+
You can either:
173+
- ** Download and flash my pre-compiled firmware** from "Releases".
174+
- **Compile your own firmware**. Download this repository (all *.ino files) and open arduino-modbus-rtu-tcp-gateway.ino in Arduino IDE. Download all required libraries (they are available in "library manager"). If you want, you can check the default factory settings (can be later changed via web interface) and advanced settings (can only be changed in the sketch). Compile and upload your program to Arduino.
175+
176+
Connect your Arduino to ethernet and use your web browser to access the web interface on default IP: http://192.168.1.254
177+
Enjoy :-)
173178

174179
## Where can I learn more about Modbus protocols?
175180

@@ -206,7 +211,7 @@ The number of used sockets is determined (by the Ethernet.h library) based on mi
206211

207212
#### Memory
208213

209-
Not everything could fit into the limited flash memory of Arduino Nano / Uno. If you have a microcontroller with more memory (such as Mega), you can enable extra settings in the main sketch by defining ENABLE_DHCP and/or ENABLE_EXTRA_DIAG in the sketch.
214+
Not everything could fit into the limited flash memory of Arduino Nano / Uno. If you have a microcontroller with more memory (such as Mega), you can enable extra settings in the main sketch by defining ENABLE_DHCP and/or ENABLE_EXTRA_DIAG in advanced settings.
210215

211216
## Version history
212217

arduino-modbus-rtu-tcp-gateway/04-webserver.ino

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ const byte POST_SIZE = 24; // a smaller buffer for single post parameter + key
2424

2525
// Actions that need to be taken after saving configuration.
2626
enum action_type : byte {
27-
NONE,
28-
FACTORY, // Load default factory settings (but keep MAC address)
29-
MAC, // Generate new random MAC
30-
REBOOT, // Reboot the microcontroller
31-
RESET_ETH, // Ethernet reset
32-
RESET_SERIAL, // Serial reset
33-
SCAN, // Initialize RTU scan
34-
RESET_STATS, // Reset Modbus Statistics
35-
CLEAR_REQUEST, // Clear Modbus Request form
36-
WEB // Restart webserver
27+
ACT_NONE,
28+
ACT_FACTORY, // Load default factory settings (but keep MAC address)
29+
ACT_MAC, // Generate new random MAC
30+
ACT_REBOOT, // Reboot the microcontroller
31+
ACT_RESET_ETH, // Ethernet reset
32+
ACT_RESET_SERIAL, // Serial reset
33+
ACT_SCAN, // Initialize RTU scan
34+
ACT_RESET_STATS, // Reset Modbus Statistics
35+
ACT_CLEAR_REQUEST, // Clear Modbus Request form
36+
ACT_WEB // Restart webserver
3737
};
3838
enum action_type action;
3939

@@ -151,7 +151,7 @@ void recvWeb(EthernetClient &client) {
151151
}
152152
}
153153
// Actions that require "please wait" page
154-
if (action == WEB || action == MAC || action == RESET_ETH || action == REBOOT || action == FACTORY) {
154+
if (action == ACT_WEB || action == ACT_MAC || action == ACT_RESET_ETH || action == ACT_REBOOT || action == ACT_FACTORY) {
155155
reqPage = PAGE_WAIT;
156156
}
157157
// Send page
@@ -160,7 +160,7 @@ void recvWeb(EthernetClient &client) {
160160
// Do all actions before the "please wait" redirects (5s delay at the moment)
161161
if (reqPage == PAGE_WAIT) {
162162
switch (action) {
163-
case WEB:
163+
case ACT_WEB:
164164
for (byte s = 0; s < maxSockNum; s++) {
165165
// close old webserver TCP connections
166166
if (EthernetClient(s).localPort() != localConfig.tcpPort) {
@@ -169,23 +169,23 @@ void recvWeb(EthernetClient &client) {
169169
}
170170
webServer = EthernetServer(localConfig.webPort);
171171
break;
172-
case MAC:
173-
case RESET_ETH:
172+
case ACT_MAC:
173+
case ACT_RESET_ETH:
174174
for (byte s = 0; s < maxSockNum; s++) {
175175
// close all TCP and UDP sockets
176176
disconSocket(s);
177177
}
178178
startEthernet();
179179
break;
180-
case REBOOT:
181-
case FACTORY:
180+
case ACT_REBOOT:
181+
case ACT_FACTORY:
182182
resetFunc();
183183
break;
184184
default:
185185
break;
186186
}
187187
}
188-
action = NONE;
188+
action = ACT_NONE;
189189
}
190190

191191
// This function stores POST parameter values in localConfig.
@@ -237,7 +237,7 @@ void processPost(EthernetClient &client) {
237237
break;
238238
case POST_IP ... POST_IP_3:
239239
{
240-
action = RESET_ETH; // this RESET_ETH is triggered when the user changes anything on the "IP Settings" page.
240+
action = ACT_RESET_ETH; // this RESET_ETH is triggered when the user changes anything on the "IP Settings" page.
241241
// No need to trigger RESET_ETH for other cases (POST_SUBNET, POST_GATEWAY etc.)
242242
localConfig.ip[paramKeyByte - POST_IP] = byte(paramValueUint);
243243
}
@@ -276,7 +276,7 @@ void processPost(EthernetClient &client) {
276276
{
277277
if (paramValueUint != localConfig.webPort && paramValueUint != localConfig.tcpPort) { // continue only of the value changed and it differs from Modbus TCP port
278278
localConfig.webPort = paramValueUint;
279-
action = WEB;
279+
action = ACT_WEB;
280280
}
281281
}
282282
break;
@@ -288,7 +288,7 @@ void processPost(EthernetClient &client) {
288288
break;
289289
case POST_BAUD:
290290
{
291-
action = RESET_SERIAL; // this RESET_SERIAL is triggered when the user changes anything on the "RTU Settings" page.
291+
action = ACT_RESET_SERIAL; // this RESET_SERIAL is triggered when the user changes anything on the "RTU Settings" page.
292292
// No need to trigger RESET_ETH for other cases (POST_DATA, POST_PARITY etc.)
293293
localConfig.baud = paramValueUint;
294294
byte minFrameDelay = byte((frameDelay() / 1000UL) + 1);
@@ -329,7 +329,7 @@ void processPost(EthernetClient &client) {
329329
}
330330
}
331331
switch (action) {
332-
case FACTORY:
332+
case ACT_FACTORY:
333333
{
334334
byte tempMac[3];
335335
memcpy(tempMac, localConfig.macEnd, 3); // keep current MAC
@@ -338,21 +338,21 @@ void processPost(EthernetClient &client) {
338338
resetStats();
339339
break;
340340
}
341-
case MAC:
341+
case ACT_MAC:
342342
generateMac();
343343
break;
344-
case RESET_STATS:
344+
case ACT_RESET_STATS:
345345
resetStats();
346346
break;
347-
case RESET_SERIAL:
347+
case ACT_RESET_SERIAL:
348348
clearQueue();
349349
startSerial();
350350
break;
351-
case SCAN:
351+
case ACT_SCAN:
352352
scanCounter = 1;
353353
memset(&slaveStatus, 0, sizeof(slaveStatus)); // clear all status flags
354354
break;
355-
case CLEAR_REQUEST:
355+
case ACT_CLEAR_REQUEST:
356356
requestLen = 0;
357357
responseLen = 0;
358358
break;

arduino-modbus-rtu-tcp-gateway/05-pages.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ void contentInfo(ChunkedPrint &chunked) {
195195
chunked.print(VERSION[0]);
196196
chunked.print(F("."));
197197
chunked.print(VERSION[1]);
198-
tagButton(chunked, F("Load Default Settings"), FACTORY);
198+
tagButton(chunked, F("Load Default Settings"), ACT_FACTORY);
199199
tagDivClose(chunked);
200200
tagLabelDiv(chunked, F("Microcontroller"));
201201
chunked.print(BOARD);
202-
tagButton(chunked, F("Reboot"), REBOOT);
202+
tagButton(chunked, F("Reboot"), ACT_REBOOT);
203203
tagDivClose(chunked);
204204
tagLabelDiv(chunked, F("EEPROM Health"));
205205
chunked.print(eepromWrites);
@@ -231,7 +231,7 @@ void contentInfo(ChunkedPrint &chunked) {
231231
chunked.print(hex(macBuffer[i]));
232232
if (i < 5) chunked.print(F(":"));
233233
}
234-
tagButton(chunked, F("Generate New MAC"), MAC);
234+
tagButton(chunked, F("Generate New MAC"), ACT_MAC);
235235
tagDivClose(chunked);
236236

237237
#ifdef ENABLE_DHCP
@@ -284,7 +284,7 @@ void contentStatus(ChunkedPrint &chunked) {
284284
chunked.print(F("'>"));
285285
}
286286
chunked.print(F("h (without CRC) <input type=submit value=Send>"));
287-
tagButton(chunked, F("Clear"), CLEAR_REQUEST);
287+
tagButton(chunked, F("Clear"), ACT_CLEAR_REQUEST);
288288
tagDivClose(chunked);
289289
chunked.print(F("</form><form method=post>"));
290290
tagLabelDiv(chunked, F("Modbus RTU Response"));
@@ -294,14 +294,14 @@ void contentStatus(ChunkedPrint &chunked) {
294294
tagSpan(chunked, JSON_QUEUE);
295295
tagDivClose(chunked);
296296
tagLabelDiv(chunked, F("Modbus Statistics"));
297-
tagButton(chunked, F("Reset Stats"), RESET_STATS);
297+
tagButton(chunked, F("Reset Stats"), ACT_RESET_STATS);
298298
tagSpan(chunked, JSON_STATS);
299299
tagDivClose(chunked);
300300
tagLabelDiv(chunked, F("Modbus Masters"));
301301
tagSpan(chunked, JSON_TCP_UDP_MASTERS);
302302
tagDivClose(chunked);
303303
tagLabelDiv(chunked, F("Modbus Slaves"));
304-
tagButton(chunked, F("Scan Slaves"), SCAN);
304+
tagButton(chunked, F("Scan Slaves"), ACT_SCAN);
305305
tagSpan(chunked, JSON_SLAVES);
306306
tagDivClose(chunked);
307307
}

pics/modbus1.png

0 Bytes
Loading

0 commit comments

Comments
 (0)