ESP8266 Slave Modbus RTU (RS232)
In this case we will test with a Module ESP8266 12E Node MCU Lolin, we will use modbus slave libraries implemented in previous tutorials with Arduino Mega 2560 R3, have made new modifications to Modbus libraries to operate by a port created with the SoftwareSerial, That we will visualize in the serial terminal the data received via modbus, we will add the SoftwareSerial library for ESP8266 which creates a second serial port for our module.
- The main serial port will be used for programming, debugging and visualization of data.
- The second serial port created with SoftwareSerial will be destined for the protocol Modbus RTU slave.
References
We will use an additional Max232 chip to convert the modbus protocol of ttl voltages to 5v to RS232, although this converter is sold normally we have decided to assemble it (MAX232 DIY) so as not to lose the tradition of manufacturing PCBs.
Tests
The following addresses have been configured in the ESP8266 module:
- 10 Holding Read Registers for display on the ESP8266 serial terminal.
- 10 Holding Writing Registers in which we will send Random values to validate the changes in the Modbus Master (Simulator).
ESP8266 Slave Modbus RTU (RS232)
Connections
ESP8266 12E NodeMCU Lolin – SoftwareSerial Ports
Converter MAX232 DIY – SoftwareSerial Port
Conclusions
- This is an initial basic test, in the next tutorials we will use WIFI the main property of our module mixing modbus with other protocols and industrial integrations.
- This application is valid in cases of requiring your ESP8266 module to perform monitoring and control of Modbus Master RTU devices.
- In this case we have used an ESP8266 12E but this library works correctly in ESP8266 01 without problems.
Recommendations
- In this test the ESP8266 has 5V from the USB, the ESP8266 feeds the MAX232, although it works well, it is recommended to feed the MAX232 independently and unify lands.
- Set up maximum to 9600 bauds, of course they can be configured at higher speeds but at low speeds we guarantee stable communication.
References
Downloads