My project uses ESP32-S3-WROOM-1 Soc with a USB C port connected to D+ and D-. The Serial2 out put is connected to a RS485 interface.
My problem is I can send/receive data on ether port but not both at the same time.
in platformio.ini if I use
board= = adafruit_feather_esp32s3
I can use Serial but not Serial2.
if I use
board = esp32-s3-devkitc-1
I can write to Serial2 but not Serial.
I can upload my program with both options.
I have tested this with a simple program to do alternate writes to Serial and Serial2
Any hints as to why this is?
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:CurrentMonitor]
; writes to Serial but not Serial 2
board = adafruit_feather_esp32s3
; writes to Serial2 but not Serial
;board = esp32-s3-devkitc-1
platform = espressif32@^6.1.0
framework = arduino
board_build.mcu = esp32s3
board_build.f_cpu = 240000000L
board_build.f_flash = 80000000L
board_build.flash_mode = dio
;
board_flags =
-DARDUINO_USB_MODE=0
-DARDUINO_USB_CDC_ON_BOOT=1
-DBOARD_HAS_PSRAM
; -mfix-esp32-psram-cache-issue
monitor_speed = 115200
upload_port = /dev/ttyACM0
program file
include <HardwareSerial.h>
/* Pin assignments for RS485 communication */
#define RxPin 16
#define TxPin 17
#define RXENB 37
// led info lights
#define BLUELED_PIN 7
#define REDLED_PIN 6
void RedLED(bool value)
{
digitalWrite(REDLED_PIN, value);
}
void BlueLED(bool value)
{
digitalWrite(BLUELED_PIN, value);
}
void Flash(uint8_t number, uint16_t On, int pin)
{
for(int i = number; i > 0; i--)
{
digitalWrite(pin, HIGH);
delay(On);
digitalWrite(pin, LOW);
delay(200);
}
}
unsigned char TxEnablePin = 37;
void setup()
{
String sBuff;
//File tFile;
delay(2000);
pinMode(REDLED_PIN, OUTPUT);
pinMode(BLUELED_PIN, OUTPUT);
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, RX, TX);
pinMode(TxEnablePin, OUTPUT);
digitalWrite(TxEnablePin, HIGH); // set tx mode
Flash(1, 2000, BLUELED_PIN);
delay(3000);
Serial.println("Setup finished");
}
char frame[30];
void loop()
{
Serial.println("Hello");
Flash(1, 50, BLUELED_PIN);
delay(2000);
Serial2.println("RS4852222222222222222222222222222222222222222222222222222222222222222222");
Flash(1, 50, REDLED_PIN);
delay(2000);
}