Skip to content

Commit 34b7530

Browse files
committed
ESP32 compatibility (not tested)
1 parent 1841474 commit 34b7530

File tree

8 files changed

+39
-27
lines changed

8 files changed

+39
-27
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
Modbus Library for ESP8266
2-
==========================
1+
# Modbus Library for ESP8266/ESP32
32

4-
This library allows your ESP8266 to communicate via Modbus protocol. The Modbus is a master-slave protocol
3+
This library allows your ESP8266/ESP32 to communicate via Modbus protocol. The Modbus is a master-slave protocol
54
used in industrial automation and can be used in other areas, such as home automation.
65

76
The Modbus generally uses serial RS-232 or RS-485 as physical layer (then called Modbus Serial) and TCP/IP via Ethernet or WiFi (Modbus IP).
@@ -11,12 +10,13 @@ In the current version the library allows the ESP8266 operate as a slave, suppor
1110
http://pt.wikipedia.org/wiki/Modbus http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
1211
http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf
1312

14-
Features
15-
========
13+
## Features
14+
15+
Keep alive and ESP32 support added to original library. This features is under testing.
1616

1717
<ul>
1818
<li>Operates as a slave</li>
19-
<li>Supports Modbus IP (TCP, not keep-alive)</li>
19+
<li>Supports Modbus IP (TCP)</li>
2020
<li>Reply exception messages for all supported functions</li>
2121
<li>Modbus functions supported:</li>
2222
<ul>
@@ -33,7 +33,7 @@ Features
3333

3434
<b>Notes:</b>
3535

36-
1. When using Modbus IP the transport protocol is TCP (port 502) and the connection is terminated to each transmitted message, that is, is not a keep-alive type connection.
36+
1. When using Modbus IP the transport protocol is TCP (port 502).
3737

3838
2. The offsets for registers are 0-based. So be careful when setting your supervisory system or your testing software. For example, in ScadaBR (http://www.scadabr.com.br)
3939
offsets are 0-based, then, a register configured as 100 in the library is set to 100 in ScadaBR. On the other hand, in the CAS Modbus Scanner
@@ -54,23 +54,23 @@ Thus, only the following functions are supported:
5454
</ul>
5555

5656

57-
How to
58-
======
57+
## How to
5958

6059
```
6160
This README is under development, for now, see the examples of the library.
6261
```
6362

64-
Contributions
65-
=============
63+
## Contributions
64+
6665
https://github.com/emelinov/modbus-esp8266
66+
6767
6868

6969
Original version:
7070
http://github.com/andresarmento/modbus-esp8266<br>
7171
prof (at) andresarmento (dot) com
7272

73-
License
74-
=======
73+
## License
74+
7575
The code in this repo is licensed under the BSD New License. See LICENSE.txt for more info.
7676

TODO.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/TestAnalogInput/TestAnalogInput.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
https://github.com/emelianov/modbus-esp8266
1111
*/
1212

13-
#include <ESP8266WiFi.h>
13+
#ifdef ESP8266
14+
#include <ESP8266WiFi.h>
15+
#else
16+
#include <WiFi.h>
17+
#endif
1418
#include <ModbusIP_ESP8266.h>
1519

1620
//Modbus Registers Offsets (0-9999)

examples/TestHoldingReg/TestHoldingReg.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
https://github.com/emelianov/modbus-esp8266
1212
*/
1313

14-
#include <ESP8266WiFi.h>
14+
#ifdef ESP8266
15+
#include <ESP8266WiFi.h>
16+
#else
17+
#include <WiFi.h>
18+
#endif
1519
#include <ModbusIP_ESP8266.h>
1620

1721
// Modbus Registers Offsets (0-9999)

examples/TestLed/TestLed.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
https://github.com/emelianov/modbus-esp8266
1111
*/
1212

13-
#include <ESP8266WiFi.h>
13+
#ifdef ESP8266
14+
#include <ESP8266WiFi.h>
15+
#else
16+
#include <WiFi.h>
17+
#endif
1418
#include <ModbusIP_ESP8266.h>
1519

1620
//Modbus Registers Offsets (0-9999)

examples/TestSwitchStatus/TestSwitchStatus.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
https://github.com/emelianov/modbus-esp8266
1111
*/
1212

13-
#include <ESP8266WiFi.h>
13+
#ifdef ESP8266
14+
#include <ESP8266WiFi.h>
15+
#else
16+
#include <WiFi.h>
17+
#endif
1418
#include <ModbusIP_ESP8266.h>
1519

1620
//Modbus Registers Offsets (0-9999)

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sentence=Modbus Library for ESP8266
66
paragraph=This library allows your ESP8266 to communicate via Modbus protocol. The Modbus is a master-slave protocol used in industrial automation and can be used in other areas, such as home automation.
77
category=Communication
88
url=https://github.com/emelianov/modbus-esp8266
9-
architectures=esp8266
9+
architectures=esp8266,esp32

src/ModbusIP_ESP8266.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
2017 Alexander Emelianov ([email protected])
55
*/
66
#include <Modbus.h>
7-
#include <ESP8266WiFi.h>
7+
#ifdef ESP8266
8+
#include <ESP8266WiFi.h>
9+
#else
10+
#include <WiFi.h>
11+
#endif
812

913
#ifndef MODBUSIP_ESP8266_H
1014
#define MODBUSIP_ESP8266_H

0 commit comments

Comments
 (0)