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.
Arduino IDE
The test strategy performs two-way communication of Holding Registers records.
ESP8266 Slave Simulator
Holding Register[4] <- 00005 (Control diode led -GPIO 04)
Holding Register[5] 00006 -> int random (1 a 999 )
Holding Register[6] 00007 -> Valor ADC0 (LDR- Photoresistor)
Note: ADC0 is valid in ESP versions with this pin available.
Materials and where to buy cheap!
Other Recommended
– ESP32
– ESP32 + 0.96″ Oled
– Arduino Nano V3 Clone
– Arduino Mega 2560 R3 Clone
– Raspberry pi 3
– Raspberry pi zero w
– Meter PZEM-004 with Display
– Meter PZEM-004T Module
-LoRa RFM95, 915.0 MHz
– Meter PZEM-016 + CT (0-100A)
– PLC LE3U FK3U FX3U 14MR
– Power Supply 5v (rail)
Tutorial
The following video tutorial will explain the modifications made to work on ESP8266 and a small test of Communication Master (ESP8266) – Slave (Yes ModbusRTU).
Video Tutorial NodeMCU ESP8266 12E Modbus RTU Master
Modifications
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.
Function CRC16
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>
-Implementation
Function makeWord
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.
Available Functions
- node.readHoldingRegisters(,)
- node.writeSingleRegister(,)
- node.readInputRegisters(,)
- node.writeSingleCoil(,)
- node.readWriteMultipleRegisters(,,,)
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
Connections
Downloads Github
- Library ModbusMaster232 Arduino/ESP8266(Modified)
- Code Arduino IDE
- Library ModbusMaster232 Arduino (Original)
References
- 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
Youtube Channel