A long time ago I found a group of people in forums.adafruit already had an advance and example have been implemented and improvements suggested by ibbba for the contribution.
The programming code for ESP8266 in this case was implemented in Arduino IDE versions 1.6.4 above. These 2 tutorials indicate connection and basic programming ESP8266 01 and 03 modules.
ESP8266 12E NodeMCU
Previous tests library ModbusTCPSlave
ESP8266 – 01 Modbus Slave TCP IP (Ethernet) for Industrial Applications
CONCLUSIONS
In previous tests with the library Original ModbusTCPSlave, it had two drawbacks of application:
Code Execution
properly functioning communication modbus tcp, but do not run the code in the routine void loop, as a temporary solution the library for ESP8266 amending stop the connection and reconnect again, the problem with this method is time reconnection can make the teacher while accepting the data indicate error in data reception.
Serial port
Originally ESP8266 the serial port was used as a debug port in hexadecimal, I have made changes to the library so that Serial can be used freely.
Updated March 2017 from Trialcommand.com
Tutorial Complete Modbus TCP/IP Trialcommand
Version September 2016
VIDEO Update ESP8266 Industrial Modbus TCP IP V2.0
Version December 2016
Video Tutorial NodeMCU ESP8266 12E Modbus TCP/IP Control I/O ADC PWM
IMPROVEMENTS
Ticker
Important note: When creating tickers consider not create any delay would affect both modbus communication protocol, such as the execution of that function.
TESTING
CODE DESCRIPTION
Mb.MBHoldingRegister[0] = Holding Registers 1
Mb.MBHoldingRegister[1] = Holding Registers 2
Mb.MBHoldingRegister[0] send a random(0,51) value to the Modbus Master and validate the upgrade value.
modbus routine Mb.Run(); is executed; and execute the Ticker Parada.attach_ms(25,valor); every 25ms doing the value created in the function.
Taking this example as a basis, they could perform management functions for I / O similar and digital, load and others, taking only into account not implement any delay.
POSSIBLE INDUSTRIAL APPLICATIONS
TUTORIAL
Industrial software integration with OPTO 22
Arduino + ESP8266 + Software Opto22 example Scada Industrial
Where to buy ?
Downloads Github
Code ESP8266_Industrial_ModbusTCP_V2
Improved version for ADC and PWM I / O control
Code & Library Arduino IDE ESP8266 Control I/O
References
Arduino Mega 2560 Oled Display I2C Master Modbus RTU Scada Industrial Connection
Arduino + ESP8266 + Software Opto22 example Scada Industrial
Hello I'm looking solusion to connect esp8266 witch modbus on bard witch codesys and I cant configure it. In modbu docementation Holding regisers start from 40001 and You in Yours example seve random value to 0 register. Can you give me some advice how to configure it.
Hi, The modbus protocol usually has a variation in their records or an offset position registration example 40001 = [0] or 40001 = [1] the 40001 can be located in any of the records [0] or [1 ] is an offset of +/- 1 record almost all devices occurs, I suggest try some TCP modbus simulator.
Holding Register [0] === 40001
Holding Register [1] === 40002
Holding Register [2] === 40003
or
Holding Register [1] === 40001
Holding Register [2] === 40002
Holding Register [3] === 40003
regards