Hi.
I'm trying to eventually write a piece of code that does a "man in the middle" hack between an RFID reader and a mainboard in a piece of equipment. I need to alter the serial data sent over this link on-the-fly.
For a start I've made a simple code that just lets the two serial ports talk to each other to test the hardware part of the project, and this is giving me a hard time.
I've picked the ESP32-S2 because it has support for several Hardware serial ports, but I'm having a real hard time getting it to work. Is there something really simple I have overlooked maybe?
Data comes fine from Serial1 to Serial, but not the other way around.
I've tested the pins by swapping the definitions, so it's not because those pins are being used by something else (some of the ESP32's pins can be a bit finicky)
Any ideas?
// Tested pins: Both 18&35 receives.
#define RXD0 18 // OK!
#define RXD1 35 // OK!
// Tested pins: Both 16&33 transmits.
#define TXD0 16 // OK!
#define TXD1 33 // OK!
void setup() {
Serial.begin(115200, SERIAL_8N1, RXD0, TXD0);
Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
}
void loop() {
// This section does NOT work.
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte0 = Serial.read();
Serial1.write(inByte0);
}
// The following section works Serial1 > Serial.
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte1 = Serial1.read();
Serial.write(inByte1);
}
}
Oh, and I almost forgot, i'm compiling this on Arduno IDE 2.3.0 on Windows 10. The target board is ESP32S2 Dev module, and the actual hardware is the S2 Mini from Wemos.cc
Thank you in advance ![]()
