I'm trying to add a S3 between a MCU and interface to interject serial communication. Mostly to forward general data and modify particular bytes where necessary in my project.
The two devices are a main MCU and a simple screen with buttons to display data and send general commands;
MCU <-> Screen
I want to add an ESP to 'catch' specific data packets and alter a byte;
MCU <-> ESP <-> Screen
My issue at the moment is that I can't even get basic forwarding to work.
Code: Select all
#include <HardwareSerial.h>
#define ScreenRx 44 //Screens TX wire, going into U0RXD to receive bytes
#define ScreenTx 43 //Screen RX wire, going into U0TXD to send bytes
#define McuRx 18 //MCU TX wire, going into U1RXD to receive bytes
#define McuTx 17 //MCU RX wire, going into U1TXD to send bytes
#define Brate 115200
HardwareSerial ScreenSerial(0);
HardwareSerial MCUSerial(1);
void setup() {
Serial.begin(Brate);
ScreenSerial.begin(Brate, SERIAL_8N1, ScreenRx , ScreenTx);
MCUSerial.begin(Brate, SERIAL_8N1, McuRx , McuTx);
}
void loop() {
if (ScreenSerial.available()) {
int inByte0 = ScreenSerial.read();
MCUSerial.write(inByte0);
}
if (MCUSerial.available()) {
int inByte1 = MCUSerial.read();
ScreenSerial.write(inByte1);
}
}
I've attempted a few things, like swapping RX and TX pins. Using just one of the two serials just to monitor with USB. But nothing's working.
USB Serial has strange behavior aswell. If i begin MCUSerial, USB one stops working and I can't flash code unless I use BOOT + RESET.
Also, if I reset the ESP or reconnect USB cable I'm unable to reconnect to the serial monitor. Tried this with just Serial while disabling the other two, and same behavior.
I have USB CDC enabled on boot.