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="";
}
}
Cannot receive data from UART1 and UART2
Re: Cannot receive data from UART1 and UART2
I have fixed the problem.
UART0, UART1, UART2 is default name in HardwareSerial.h
it should be be used as a class name for UART. the name of UART was changed to DebugUart and everything works well.
Hardwareserial DebugUart(1);
UART0, UART1, UART2 is default name in HardwareSerial.h
it should be be used as a class name for UART. the name of UART was changed to DebugUart and everything works well.
Hardwareserial DebugUart(1);
Who is online
Users browsing this forum: No registered users and 73 guests