UART Receiving Random Data

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

UART Receiving Random Data

Postby Ritu21 » Tue Aug 27, 2019 5:13 am

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.

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

Re: UART Receiving Random Data

Postby chegewara » Tue Aug 27, 2019 8:24 pm

What module are you using? WROOM or WROVER?

mikemoy
Posts: 626
Joined: Fri Jan 12, 2018 9:10 pm

Re: UART Receiving Random Data

Postby mikemoy » Wed Aug 28, 2019 1:20 am

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.

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

Re: UART Receiving Random Data

Postby Ritu21 » Wed Aug 28, 2019 12:11 pm

Hi,

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


Thanks
Ritu

Who is online

Users browsing this forum: No registered users and 73 guests