Here is a sample how to ESP8266 communicate with Siemens LOGO PLC by MODBUS
The sample show how to read input signal in LOGO and send to ESP8266 and also sent boolean value from ESP8266 to relay output in LOGO PLC. That is send by modbus protocoll by WIFI.
ESP8266 act as a slave/server (listen) and LOGO is master/client (sending). It is ESP8266 that have the list of "coils". It is LOGO that contact ESP8266 and read/write coils. I try it on EPS32, but it not work there.
This little PLC have 8 inputs and 4 relay outputs.
This is the program in LOGO PLC. In top is sender that sends coil 10 evry seconds. Next section test coil 11 and connect it to relay 1 in LOGO.
LOGO have IP 192.168.0.3 in this case but it not important. Coilnumbers are not same in Arduino-world and LOGO-world. Coil 9 in Arduino is coil 10 in LOGO-world. (Little bit confusing)
LOGO!Soft Comfort is the program for LOGO PLC
modbus-esp8266
https://github.com/emelianov/modbus-esp8266