Issues with UART on WEMOS ESP32-S3

Monskiller
Posts: 1
Joined: Sun Sep 22, 2024 2:42 pm

Issues with UART on WEMOS ESP32-S3

Postby Monskiller » Sun Sep 22, 2024 3:39 pm

Good day,

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);
  }
}
Preferably I'd like to use the builtin USB serial aswell to monitor data and debug.
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.

nopnop2002
Posts: 109
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Issues with UART on WEMOS ESP32-S3

Postby nopnop2002 » Tue Sep 24, 2024 5:57 am

I don't know how Arduino's HardwareSerial works.

ESP-IDF allows you to create multiple UART devices using uart_driver_install.

The number of available UART port number varies by model.

UART port number, can be UART_NUM_0 ~ (UART_NUM_MAX -1).

This sample is useful for sending and receiving using UART.

https://github.com/espressif/esp-idf/tr ... _rxtxtasks

Who is online

Users browsing this forum: aapee-jcv and 389 guests