tobby
Hi, I have some questions about ESP32 pin:
 
1. ESP32 have 3 Serial(Serial0, Serial1, Serial2) with each default pin number respectively. How do we assign, for example Serial2(Rx:GPIO16, Tx:17), other pins to be Rx and Tx just like using HardwareSerial library in Arduino IDE?
 
2.How do we extend more Digital Input or Digital Output through modifying Physical Addressing Table?
 
Thanks!
Reply 0 0
thiagoralves
1. For this you will have to edit the source code of the runtime (editor/arduino/src).
 
2. On the upload dialog UI, click on IO Config and change pins as you'd like.
Reply 0 0
tobby
Got it! I really appreciate that!
 
By the way, I have another question that can we use PL2303HX USB to TTL adapter and plug USB side into Raspberry Pi, and connect TTL side(Rx,Tx) of adapter to GPIO16 17 of ESP32 to fulfill Modbus RTU?
 
Thanks!
 
PL2303HX USB to TTL adapter:
Reply 0 0
thiagoralves
Yes, that should work. Most ESP32 boards already come with a chip like that for Serial
Reply 0 0
tobby
Thanks very much!
Reply 0 0
tobby
Recently I'm developing project about using modbus RTU as communication between Raspberry Pi and esp32 MH-ET Live minikit. USB side of PL2303HX USB to TTL adapter is plugged in Raspberry Pi, and TTL side(TX,RX,GND) connected with esp32 GPIO10(RX) and 9(TX). However, the log shows that "Modbus Write Coils failed on MB device esp: Invalid CRC" and "Modbus Write Coils failed on MB device esp: Response not from requested slave". Is there any misunderstanding about using esp32 Serial1?
Reply 0 0
thiagoralves
It seems that ESP32 UART is a bit complicated. You might need to patch the runtime to make it work correctly. Check this: https://quadmeup.com/arduino-esp32-and-3-hardware-serial-ports/
Reply 0 0
tobby
Which means uart setup codes in OpenPLC related to ESP32 need to be added?OpenPLC only support SoftwareSerial(Serial1,2..) for Arduino so far ?
Reply 0 0
thiagoralves
Yes, you will have to change the OpenPLC Runtime firmware for the ESP32 (/editor/arduino/src and /editor/arduino/examples/Baremetal). OpenPLC uses Arduino Serial (not SoftwareSerial). But it seems that, different than all other boards, ESP32 doesn't play nice with that and requires you to use this particular HardwareSerial class.
Reply 0 0
tobby
Yes, you will have to change the OpenPLC Runtime firmware for the ESP32 (/editor/arduino/src and /editor/arduino/examples/Baremetal). OpenPLC uses Arduino Serial (not SoftwareSerial). But it seems that, different than all other boards, ESP32 doesn't play nice with that and requires you to use this particular HardwareSerial class.
Got it! I try for that. Thanks you very much for answering!
Reply 0 0
tobby
Hi Thiagoralves, I've modified OpenPLC Runtime Firmware for the ESP32 about 2 places in Baremetal.ino(ModifyCode1.png) and 1 place in ModbusSlave.cpp(ModifyCode2.png). Compilation is pass. However, the ModbusRTU communication fail, too.
1. Is there any suggestion about my modification for OpenPLC Runtime Firmware?
2. According to the fail log(FailLog_modifycode.txt), it seems like the modbus slave(esp32 mh-et live minikit) isn't answering the master?
Reply 0 0
thiagoralves
Issue could be on many parts of this project: master configuration, wiring, and even your code. I suggest you remove those areas of uncertainty. Get an arduino and connect the cables directly to the ESP32 user and try sending messages over to it. You can manually craft a Modbus message on a little arduino board and check if your ESP32 responds correctly
Reply 0 0
tobby
Issue could be on many parts of this project: master configuration, wiring, and even your code. I suggest you remove those areas of uncertainty. Get an arduino and connect the cables directly to the ESP32 user and try sending messages over to it. You can manually craft a Modbus message on a little arduino board and check if your ESP32 responds correctly
Thanks for your answering! This experiment is using A. USB to TTL adapter. However, the modbus rtu communication works out correctly when I change to B. USB to TTL adapter and using Rx(GPIO17) and Tx(GPIO16).
 
Reply 0 0
Reply