Update ESP8266 Industrial Modbus TCP IP V2.0

 There have been numerous applications in the ESP8266, I have taken as a goal to integrate this module into one of the industrial protocols most commonly used Modbus TCP IP, it would be good to have a node or sensor that sends data or a driver, OPC, PAC, PLC, HMI or SCADA.

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.

TUTORIAL

Programming ESP8266 01 with Arduino IDE 

TUTORIAL

Programming ESP8266 03 with Arduino IDE 

ESP8266 12E NodeMCU

PLC Panasonic ESP8266 pdacontrol

 

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.

Update September  2016
VIDEO Update ESP8266  Industrial Modbus TCP IP   V2.0

Update December 2016

Video Tutorial NodeMCU  ESP8266 12E   Modbus TCP/IP Control I/O  ADC PWM

IMPROVEMENTS

With the new modifications it has been omitted disconnection allowing a constant flow of communication if stop the connection between the ESP8266 and modbus tcp master mandatory.

Ticker

He has implemented Ticker library created and documented by igrr, it is an object to call a given function with a certain period. Each Ticker calls a function. You can have as many as you like tickers, the only memory limitation.

Important note: When creating tickers consider not create any delay would affect both modbus communication protocol, such as the execution of that function.

 

TESTING

the connection between the ESP8266 and a simulator configured as master Modbus tcp was made.
-initially The Ticker Parada is created.

CODE DESCRIPTION

call the function value is created and defined 2 Holding Registers:

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.

 Mb.MBHoldingRegister[1]  is used for reading a value sent from the Modbus Master and from the serial terminal validate the update.

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

Youtube Channel

PDAControl

You may also like...

2 Responses

  1. Unknown says:

    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.

    • PDAControl says:

      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

Leave a Reply