Modbus TCP NodeMCU ESP8266 12-E Master Slave Communication
by electrocoder in Teachers > Robotics
11097 Views, 1 Favorites, 0 Comments
Modbus TCP NodeMCU ESP8266 12-E Master Slave Communication
Modbus is a common protocol used in the communication of Industrial Machines. In this project, we will perform Modbus Master Slave communication using Modbus TCP/IP.
Supplies
NodeMCU ESP8266 12-E Modbus library: https://github.com/emelianov/modbus-esp8266
Modbus Poll GUI: https://www.modbustools.com/modbus_poll.html
Modbus Poll program is licensed software. You can download it from its website and use it for free for a certain period of time. I tried the alternatives but I couldn't get any results. It didn't work well. It gave a connection error, it didn't work and so on. Maybe we will write the open source version. I do not know. If I find an open source alternative, I'll share it.
In this project, our aim is to turn the led on the NodeMCU ESP8266 12-E on and off.
For this, we used the modbus-esp8266 library from the library tab of the Arduino editor. We did not write an application for Arduino. We opened the example named onSet from the examples in the modbus-esp8266 library.
We entered our modem name and password in Wifi.begin on line 47.
We uploaded the code to Nodemcu. We saw that the nodemcu was connected to the network from the serial monitor and wrote the IP address by opening the Modbus Poll program.
We wrote Nodemcu's IP address 192.168.1.192 in the Node Name section and started the connection by pressing the OK button.
We entered the Modbuss Poll -> Functions and 05 Write Single Coin menu.
In the 21st line of our Arduino code, the address 100 is defined for LED_COIL.
We wrote this 100 Address in the Modbus Poll Address field.
We turn our led on and off with the Value On/Off radio buttons below the Modbus Poll Adress field.
We wish you good work.
Note: If you do not want to use Modbus Poll, I am attaching the exe file of the C# project named MB_Modbus_TCP_Test_GUI that we made for testing.