We have performed several tests regarding Arduino integrating Arduino-PLC and Arduino-HMI Panasonic for Industrial applications, in this opportunity we have found other libraries for Arduino as Master Modbus RTU, which we will use only in Modules ESP8266, main advantages of the library has Easier facility regarding read and write log settings.
This time we will highlight the origin of these libraries and the contributions of a community called cooking-hacks.com which market and test platforms such as Arduino, Raspberry pi and Intel galileo, together libelium.com create modules for the integration of The previously mentioned platforms with some existing known protocols.
cooking-hacks : www.cooking-hacks.com
libelium : www.libelium.com
The ModbusMaster232.h library is under GNU (General Public License), in this page there are 2 versions available from this library RS232 and RS485, in this case we will use the RS232 version, since the other was created for a module with different hardware To the common Max485.
Documentation Api ModbusMaster232 : classModbusMaster232.
The test strategy performs two-way communication of Holding Registers records.
ESP8266 Slave Simulator
Holding Register <- 00005 (Control diode led -GPIO 04)
Holding Register 00006 -> int random (1 a 999 )
Holding Register 00007 -> Valor ADC0 (LDR- Photoresistor)
Note: ADC0 is valid in ESP versions with this pin available.
Video Tutorial NodeMCU ESP8266 12E Modbus RTU Master
Other Test Trialcommand.com
Initially when compiling the available ModbusMaster232.c librarian examples to download in the ESP8266 module from Arduino IDE, errors were generated in 2 native functions of the Atmega AVR (Atmel) AVR microcontroller architecture.
Note: Bottom Downloads, Modified Libraries.
Notepad ++ editor views.
1- Function created _crc16_update2 in replacement of library crc16.h function _crc16_update in charge of performing checksum modbus, source AVR Libc Reference Manual <util / crc16.h>
2- The makeWord function, which constructs 1 word from 2 byte, has been eliminated, the equivalent function in code has been implemented in each required site.
ADC(0) Signal Conditioning
You must be very careful when using ADC pin (0) of the module ESP8266 12E, TOUT, ADC (0) or pin 6 are some names by which this input will be identified, its resolution is 10 bits from 0 to 1.0V maximum, We have created a circuit based on a voltage divider and a diode to limit the input voltage in parallel to our light sensor, photoresist or LDR.
Components and materials required for testing
- Library ModbusMaster232 Arduino/ESP8266(Modified)
- Code Arduino IDE
- Library ModbusMaster232 Arduino (Original)
- Modbus RTU Master tests with Arduino via RS232 and PLC Panasonic FPX C14R
- Modbus RTU Master tests with Arduino via RS232 and screen Panasonic GT01
- ESP8266 Scada SVG Modbus RTU Display Oled PLC Panasonic FPX C14R