Sajida
Hi ,
 
I have just started learning OpenPLC . Here I am trying to run a simple LED program on ESP32 dev board(ESP32-WROOM-32) from OpenPLC runtime. My OpenPLC runtime is running on windows (same thing I tried on Ubuntu as well). For this I have added a slave device on OpenPLC runtime.
 
[203128%2F9216420%2Fmceclip0]
 
The added slave device details as below:. The IP, I have assigned to ESP32 board using OpenPLC editor and Its in the same network as windows machine.
 
[203128%2F9216421%2Fmceclip0][203128%2F9216428%2Fmceclip0]
 
I can monitor the program and its using correct address for LED %QX100.0.
 
[203128%2F9216424%2Fmceclip0]
 
But it keeps on disconnecting and there are errors on Modbus register . I have run the Blank_project before on the ESP32 using the link. [203128%2F9216433%2Fmceclip0]
 
 
Runtime logs as below:
 
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device ESP32_Slave is disconnected. Attempting to reconnect...
Persistent Storage is empty
Connected to MB device ESP32_Slave
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued stop_dnp3() command
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage() command
Modbus Write Holding Registers failed on MB device ESP32_Slave: Connection timed out
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Modbus Read Input Registers failed on MB device ESP32_Slave: Connection timed out
Modbus Write Holding Registers failed on MB device ESP32_Slave: Bad file descriptor
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Server: Client accepted! Creating thread for the new client ID: 5...
Server: waiting for new client...
Server: Thread created for client ID: 5
Modbus Server: client ID: 5 has closed the connection
Terminating Modbus connections thread
Server: Client accepted! Creating thread for the new client ID: 8...
Server: waiting for new client...
Server: Thread created for client ID: 8
Modbus Server: client ID: 8 has closed the connection
Terminating Modbus connections thread
Server: Client accepted! Creating thread for the new client ID: 8...
Server: waiting for new client...
Server: Thread created for client ID: 8
Server: Client accepted! Creating thread for the new client ID: 5...
Server: waiting for new client...
Server: Thread created for client ID: 5
Modbus Server: client ID: 5 has closed the connection
Terminating Modbus connections thread
Server: Client accepted! Creating thread for the new client ID: 5...
Server: waiting for new client...
Server: Thread created for client ID: 5
Modbus Read Discrete Input Registers failed on MB device ESP32_Slave: Connection timed out
Modbus Write Coils failed on MB device ESP32_Slave: Bad file descriptor
Modbus Read Input Registers failed on MB device ESP32_Slave: Bad file descriptor
Modbus Write Holding Registers failed on MB device ESP32_Slave: Bad file descriptor
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Modbus Read Discrete Input Registers failed on MB device ESP32_Slave: Connection timed out
Modbus Write Coils failed on MB device ESP32_Slave: Bad file descriptor
Modbus Read Input Registers failed on MB device ESP32_Slave: Bad file descriptor
Modbus Write Holding Registers failed on MB device ESP32_Slave: Bad file descriptor
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Modbus Write Holding Registers failed on MB device ESP32_Slave: Connection timed out
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Modbus Read Input Registers failed on MB device ESP32_Slave: Connection timed out
Modbus Write Holding Registers failed on MB device ESP32_Slave: Bad file descriptor
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Modbus Write Holding Registers failed on MB device ESP32_Slave: Connection timed out
Device ESP32_Slave is disconnected. Attempting to reconnect...
Connected to MB device ESP32_Slave
Modbus Server: client ID: 8 has closed the connection
Terminating Modbus connections thread
 
##############################
 
I am not sure if I am doing something wrong. Can you please help here or point me to right links if there are any for such issues?
 
Thanks
Sajida
Reply 0 0
thiagoralves
Make sure you’ve programmed your ESP32 board properly (check compilation logs on the transfer to plc dialog) and that your windows machine can reach your board. Try using ping to see if the ESP32 is reachable. Then use a Modbus program like Radzio Modbus to test if you can read Modbus registers from your esp32
Reply 0 0
Sajida
Thanks Thiago for your reply.
 
Yes I can ping to the ESP32 from my windows. I tried Radzio modbus and I can see the reading of regsiters.
 
[203128%2F9216762%2Fmceclip0][203128%2F9216786%2Fmceclip0][203128%2F9216789%2Fmceclip0]
 
While programming ESP32 from openplc editor it was all fine with no error and I can see the LED blinking when I program directly from openplc editor.I have used the same blinky program which you have explained in one of the tutorial.
 
[203128%2F9216767%2Fmceclip0]
 
[203128%2F9216775%2Fmceclip0]
 
For running it as a slave device using OpenPLC Runtime I changed the address location to %QX100.0. Let me know if I am missing something.
 
Thanks
Sajida
Reply 0 0
thiagoralves
If the device is responding to Modbus packets it should work with the OpenPLC runtime. Double check your slave configuration on the runtime (IP, port, etc) and make sure there isn’t any firewall or other network protections in the way
Reply 0 0
Sajida
Hi Thiago,
 
Thanks for your reply. I have checked the configuration and it seems to be fine (there is not much TBH. I can change only IP for ESP32 device type. ). I have moved the deivce to different network and this time tried OpenPLC Runtime on ubuntu. Firewall is disabled. IP assigened to ESP32 is 192.168.1.131 and port is 502. I can ping ESP32 board from ubuntu machine. I cant change Slave ID in the config so I guess that does not matter. . Will it affect?
 
[203128%2F9224452%2Fmceclip0]
 
 
I have just modified LED blinking wait time from 100ms to 1000ms in the new program and I am running it from OpenPLC Runtime.
There are no error in connection as such but there are no logs for writing or reading registers. I also dont see any changes on the LED blinking pattern . So I am not sure if the program is running on the board or not.
 
############## logs #########
 
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device Slave_ESP32 is disconnected. Attempting to reconnect...
Persistent Storage is empty
Connected to MB device Slave_ESP32
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued stop_dnp3() command
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage() command
Server: Client accepted! Creating thread for the new client ID: 8...
Server: waiting for new client...
Server: Thread created for client ID: 8
######################
 
Let mw know how to debug this if there is any way?
 
Thanks
Sajida
Reply 0 0
thiagoralves
There are only logs for errors. If you don't see any error messages, then you're good. The Ubuntu runtime and the ESP32 are linked. If you don't see anything happening on the actual device, most likely you're using the wrong pin or your PLC program is incorrect.
Reply 0 0
Reply