Modbus TCP NodeMCU ESP8266 12-E Master Slave Communication

by electrocoder in Teachers > Robotics

10785 Views, 1 Favorites, 0 Comments

Modbus TCP NodeMCU ESP8266 12-E Master Slave Communication

mese-modbus-nodemcu (0).png
mese-modbus-nodemcu (9).png
mese-modbus-nodemcu (11).png

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

mese-modbus-nodemcu (14).png
mese-modbus-nodemcu (12).png

mese-modbus-nodemcu (0).png
mese-modbus-nodemcu (1).png
mese-modbus-nodemcu (2).png

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.

mese-modbus-nodemcu (2).png

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.

mese-modbus-nodemcu (3).png

We entered our modem name and password in Wifi.begin on line 47.

mese-modbus-nodemcu (4).png
mese-modbus-nodemcu (5).png
mese-modbus-nodemcu (6).png

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.

mese-modbus-nodemcu (7).png

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.

mese-modbus-nodemcu (8).png

In the 21st line of our Arduino code, the address 100 is defined for LED_COIL.

mese-modbus-nodemcu (9).png

We wrote this 100 Address in the Modbus Poll Address field.

mese-modbus-nodemcu (10).png

We turn our led on and off with the Value On/Off radio buttons below the Modbus Poll Adress field.

mese-modbus-nodemcu (11).png

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.


MB_Modbus_TCP_Test_GUI DOWNLOAD