Cannot receive data from UART1 and UART2
Posted: Sat Jun 04, 2022 7:13 am
Dear members,
I am trying to test Hardware UART function on a ESP32 module base on Arduino.
An USB -UART dongle was use to test the ESP32. below is the code.
RX on UART0 can receive the data send from dongle.
but the UART1 and UART2 can't receive data. however, trasnfer from TX works well.
HardwareSerial UART2(2);
void setup() {
UART2.begin(115200, SERIAL_8N1, 16,17,false,20000);
delay(500);
Serial.begin(115200);
delay(100);
Serial.println("UART0 was activated");
delay(200);
UART2.println("UART2 OUTPUT");
}
int i;
String Data;
void loop() {
delay(1000);
i = UART2.available();
UART2.println(i);
if(i>0){
while(i){
i--;
Data = Data + UART2.read();
}
UART2.print(Data);
Data="";
}
}
I am trying to test Hardware UART function on a ESP32 module base on Arduino.
An USB -UART dongle was use to test the ESP32. below is the code.
RX on UART0 can receive the data send from dongle.
but the UART1 and UART2 can't receive data. however, trasnfer from TX works well.
HardwareSerial UART2(2);
void setup() {
UART2.begin(115200, SERIAL_8N1, 16,17,false,20000);
delay(500);
Serial.begin(115200);
delay(100);
Serial.println("UART0 was activated");
delay(200);
UART2.println("UART2 OUTPUT");
}
int i;
String Data;
void loop() {
delay(1000);
i = UART2.available();
UART2.println(i);
if(i>0){
while(i){
i--;
Data = Data + UART2.read();
}
UART2.print(Data);
Data="";
}
}