# ModbusRTU and ModbusTCP Library for ESP8266/ESP32
|If the library is helpful for your projects you can support it by a glass of beer|[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Z38SLGAKGM93S&source=url)|
|---|---|
Visit [Releases](https://github.com/emelianov/modbus-esp8266/releases) page for stable one.
---
This library allows your ESP8266/ESP32 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.
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).
For more information about Modbus see:
* [Modbus (From Wikipedia, the free encyclopedia)](http://pt.wikipedia.org/wiki/Modbus)
* [MODBUS APPLICATION PROTOCOL SPECIFICATION
V1.1b](http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf)
* [MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE
V1.0b](http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf)
* [MODBUS over Serial Line
Specification and Implementation Guide
V1.02](http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
## Features
* Supported platforms are
* ESP8266
* ESP32
* STM32F103 and probably others (Modbus RTU only)
* Operates in any combination of multiple instances of
* ModbusRTU slave
* ModbusRTU master
* ModbusTCP server
* ModbusTCP client
* Reply exception messages for all supported functions
* Modbus functions supported:
* 0x01 - Read Coils
* 0x02 - Read Input Status (Read Discrete Inputs)
* 0x03 - Read Holding Registers
* 0x04 - Read Input Registers
* 0x05 - Write Single Coil
* 0x06 - Write Single Register
* 0x0F - Write Multiple Coils
* 0x10 - Write Multiple Registers
* Callbacks for
* Client connect (ModbusTCP)
* Server/Client disconnect (ModbusTCP)
* Read specific Register
* Write specific Register
* Slave transaction finish
## Notes
1. 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) 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](http://www.chipkin.com/products/software/modbus-software/cas-modbus-scanner/) offsets are 1-based, so a register configured as 100 in library should be 101 in this software.
2. For API refer [API.md](https://github.com/emelianov/modbus-esp8266/blob/master/API.md)
3. ModbusRTU maximum incoming frame size is determinated by HardwareSerial buffer size. For SoftwareSerial buffer must be set to 256 bytes.
4. Probably it's possible to use ModbusRTU with other AVR boards using <vector> from [ArduinoSTL](https://github.com/mike-matera/ArduinoSTL).
5. RS-485 transivers based on MAX-485 is working on at least up to 115200. XY-017/XY-485 working only up to 9600 for some reason.
## Last Changes
```diff
// 3.0.3
+ ModbusRTU: Add inverse logic support for transmit control
// 3.0.2
+ ModbusTCP Client: ESP32 fix unexpected transaction timeout
// 3.0.1
+ ModbusRTU: ESP32 possible send\receive failure fix
+ ModbusRTU: Non-ESP devices support
+ Restriction to registers count removed
+ Added bridge example
// 3.0.0
+ ModbusRTU Slave
+ ModbusRTU Master
+ Registers are now shared between Modbus* instances by default
+ Fix functions register count limits to follow Modbus specification (or RX buffer limitations)
+ ModbusRTU: Examples added
+ Test multiple Modbus* instances
+ Change to 'uint32_t eventSource()'. Implemented for ModbusRTU and ModbusIP both
+ Client: Allow to specify local TCP port (default is 502)
+ Server: Allow to specify TCP remote port for connection (default is 502)
+ Master\Client: Fix crash on Write Multiple Hregs
+ Master\Client: Fix crash on no callback function on read\write remote
+ Tests added
// ToDo later
- 0x14 - Read File Records function
- 0x15 - Write File Records function
- 0x16 - Write Mask Register function
- 0x17 - Read/Write Registers function
- ModbusIP: Support for non-ESP boards (using W5x00)
```
## Contributions
https://github.com/emelianov/modbus-esp8266
a.m.emelianov@gmail.com
Original version:
https://github.com/andresarmento/modbus-esp8266
https://github.com/andresarmento/modbus-arduino
prof (at) andresarmento (dot) com
## License
The code in this repo is licensed under the BSD New License. See LICENSE.txt for more info.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
ArduinoIDE上开发的ESP8266建立的Wifi Modbus TCP服务器与客户端例程并已经完成了回环测试和一个ESP8266当Modbus服务器两个ESP8266当客户端的服务器连续读写测试读写速率大于100hz可以作为初学的参考或者实际应用的例子快速的使用Modbus TCP进行可靠的数据传输
资源推荐
资源详情
资源评论
收起资源包目录
Arduino_ESP8266_MouBus_TCP服务器客户端.zip (47个子文件)
MODBUS TCP调试工具
ModbusTCP_Master用来调试服务器
ModbusTCP_Master.exe 666KB
Snipaste_2018-08-14_10-38-08.png 88KB
Snipaste_2018-08-14_10-35-24.png 75KB
Snipaste_2018-08-14_10-35-00.png 73KB
Snipaste_2018-08-14_10-35-58.png 72KB
Snipaste_2018-08-14_10-37-08.png 88KB
Snipaste_2018-08-14_10-37-32.png 91KB
Snipaste_2018-08-14_10-36-46.png 60KB
Snipaste_2018-08-14_10-35-40.png 75KB
Snipaste_2018-08-14_10-37-56.png 17KB
Snipaste_2018-08-14_10-36-25.png 61KB
ModbusTCP_Client用来调试客户端
ClientTester.exe 84KB
ESP8266_MODBUS_TCPCLIENT
Serialfunction.cpp 5KB
Serialfunction.h 838B
ESP8266_MODBUS_TCPCLIENT.ino 10KB
ESP8266_MODBUS_TCPSERVER
Serialfunction.cpp 5KB
Serialfunction.h 838B
ESP8266_MODBUS_TCPSERVER.ino 4KB
库函数
modbus-esp8266
LICENSE.txt 2KB
src
ModbusRTU.h 4KB
Modbus.cpp 19KB
Modbus.h 11KB
ModbusIP_ESP8266.cpp 15KB
ModbusRTU.cpp 14KB
ModbusIP_ESP8266.h 6KB
keywords.txt 2KB
examples
IP-client-WriteMultiple
IP-client-WriteMultiple.ino 2KB
IP-server-HoldingReg
IP-server-HoldingReg.ino 1KB
IP-server-Callback
IP-server-Callback.ino 2KB
IP-server-MassOperations
IP-server-MassOperations.ino 2KB
IP-bridge
IP-bridge.ino 582B
IP-server-Led
IP-server-Led.ino 1KB
IP-client-SimpleRead
IP-client-SimpleRead.ino 1KB
IP-server-SwitchStatus
IP-server-SwitchStatus.ino 1KB
RTU-master
RTU-Master.ino 1KB
IP-server-MultipleHRegDebug
IP-server-MultipleHRegDebug.ino 2KB
RTU-slave
RTU-slave.ino 636B
IP-server-AnalogInput
IP-server-AnalogInput.ino 1KB
IP-client-Pull
IP-client-Pull.ino 2KB
README.md 5KB
API.md 13KB
library.properties 511B
tests
tests.ino 2KB
common.h 895B
README.md 223B
write.h 5KB
read.h 4KB
共 47 条
- 1
咸蛋超人口渴了
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页