Page 1 of 1

UART Receiving Random Data

Posted: Tue Aug 27, 2019 5:13 am
by Ritu21
Hi,

I am writing an application on esp32 dev board where data will be received on Uart, which will be shared to the further tasks.
Wrote driver for UART1 using IO17 for TXD and IO16 for RXD in dev board.

Below is the task for uart for receiving data :

static void rx_task()
{
static const char *RX_TASK_TAG = "RX_TASK";
ESP_LOGI(RX_TASK_TAG,"rx task started \n");
esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO);
uint8_t* data = (uint8_t*) malloc(RX_BUF_SIZE+1);
while (1)
{
const int rxBytes = uart_read_bytes(UART_NUM_1, data, (RX_BUF_SIZE-1), 1000 / portTICK_RATE_MS);
if(rxBytes > 0)
{
data[rxBytes] = 0;
if(rfid_queue != 0)
{
xQueueSendToBack(rfid_queue, data, ( TickType_t ) 10 );
ESP_LOG_BUFFER_HEXDUMP("Http Queue", data, rxBytes, ESP_LOG_INFO);
}
ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data);
}
}
free(data);
}

My problem is that uart is receiving some random data continuously from the external device attached through uart. Also, I have connected that device to pc, it was not receiving any such data as esp32 was. Could you suggest something on this ?


Thanks
Ritu.

Re: UART Receiving Random Data

Posted: Tue Aug 27, 2019 8:24 pm
by chegewara
What module are you using? WROOM or WROVER?

Re: UART Receiving Random Data

Posted: Wed Aug 28, 2019 1:20 am
by mikemoy
Would help to know what the other device is. Or have you checked the voltages of the TX/RX pins from the other device to make sure its not higher than 3.3v ? For instance if you using an Arduino, those pins will be 5v which is to high.

Re: UART Receiving Random Data

Posted: Wed Aug 28, 2019 12:11 pm
by Ritu21
Hi,

I am using ESP32 wroom32 dev board. Will check the voltage on RX/TX pin and shall let you know.


Thanks
Ritu