Page 1 of 1

ESP32 doesn't see all the data in UART rx buffer

Posted: Thu Nov 28, 2019 4:36 pm
by Alexix
I am using ESP32 WROOM to communicate with TI PGA460 chip via asynchronous UART2 (pins 16 17, 115200 8N2). The command transmission from ESP32 works fine, but the problem appears with the response data reception.

PGA460 responds with known number of bytes every time. ESP32 receives them all, but the reading functions (eg., Serial.available(), ...) see a various number of received bytes in buffer (from 0 to all of the received) (randomly?). For example, PGA460 responds with 10 bytes, all of them are being received by ESP32, but when the reading function is called ( inside while(serial.available) cycle), it recognizes (for example) 7 of them. (sometimes none of them)

It was noticed that if I send someting via Serial monitor (using Arduino IDE (UART connection with PC), the rest of the bytes are being found in the buffer (even if the UART2 connection with PGA460 was preliminary unpluged). What could be a reason of that and the possible solution ? (the same connection with other ESP32 works fine in both ways)

Re: ESP32 doesn't see all the data in UART rx buffer

Posted: Mon Dec 02, 2019 11:17 pm
by Alexix

Attached the example of received bytes from UART buffer.

All the shown bytes were sent to ESP32 as a single pack of data. --END-- line represents the point, where Serial2.available / think the Rx buffer is now empty. After interracting with Serial port (UART with PC) (for example sending something via serial monitor of Arduino IDE), ESP32 detects the rest of the received bytes.

The tested code is provided below.

Code: Select all

void setup()
Serial2.begin(115200, SERIAL_8N2);

void loop()
while (Serial2.available()>0)
	Serial.println(, HEX);

if (i==1)
	Serial.println(" ");