programacion ESP32 IDE arduino
Posted: Wed Oct 02, 2024 11:18 pm
Good afternoon, I need to program an ESP32S3 with the Arduino environment but I want to program it from the USB pins because I need the UART ports available, and I also need the USB port to receive and send data with the 3 UART ports. thank you so much. I attach a code that I already have but it does not work correctly
#include <Arduino.h>
void setup() {
// Initialize USB communication (Serial)
Serial.begin(115200); // USB port at 115200 bps
// Initialize UART0, UART1, and UART2
Serial1.begin(9600, SERIAL_8N1, 16, 17); // UART0 on pins 16 (RX) and 17 (TX)
Serial2.begin(9600, SERIAL_8N1, 18, 19); // UART1 on pins 18 (RX) and 19 (TX)
Serial3.begin(9600, SERIAL_8N1, 22, 23); // UART2 on pins 22 (RX) and 23 (TX)
}
void loop() {
// Read data from the USB port and send it to UART0
if (Serial.available()) {
char incomingByte = Serial.read();
Serial1.write(incomingByte);
}
// Read data from UART0 and send it to the USB port
if (Serial1.available()) {
char incomingByte = Serial1.read();
Serial.write(incomingByte);
}
// Similar for UART1 and UART2
if (Serial2.available()) {
char incomingByte = Serial2.read();
Serial.write(incomingByte);
}
if (Serial3.available()) {
char incomingByte = Serial3.read();
Serial.write(incomingByte);
}
}
#include <Arduino.h>
void setup() {
// Initialize USB communication (Serial)
Serial.begin(115200); // USB port at 115200 bps
// Initialize UART0, UART1, and UART2
Serial1.begin(9600, SERIAL_8N1, 16, 17); // UART0 on pins 16 (RX) and 17 (TX)
Serial2.begin(9600, SERIAL_8N1, 18, 19); // UART1 on pins 18 (RX) and 19 (TX)
Serial3.begin(9600, SERIAL_8N1, 22, 23); // UART2 on pins 22 (RX) and 23 (TX)
}
void loop() {
// Read data from the USB port and send it to UART0
if (Serial.available()) {
char incomingByte = Serial.read();
Serial1.write(incomingByte);
}
// Read data from UART0 and send it to the USB port
if (Serial1.available()) {
char incomingByte = Serial1.read();
Serial.write(incomingByte);
}
// Similar for UART1 and UART2
if (Serial2.available()) {
char incomingByte = Serial2.read();
Serial.write(incomingByte);
}
if (Serial3.available()) {
char incomingByte = Serial3.read();
Serial.write(incomingByte);
}
}