#define UART1_ODU_BAUD_RATE 2400
#define U1RXD 32
#define U1TXD 33
Use this for UART Init in the setup
// UART1 Configuration
uart_config_t Configurazione_UART1 = {
.baud_rate = UART1_ODU_BAUD_RATE,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_APB,
};
uart_param_config(NUMERO_PORTA_SERIALE, &Configurazione_UART1);
esp_log_level_set(TAG, ESP_LOG_INFO);
uart_set_pin(NUMERO_PORTA_SERIALE, U1TXD, U1RXD, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(NUMERO_PORTA_SERIALE, BUF_SIZE, BUF_SIZE, 20, &uart1_queue, 0);
xTaskCreate(UART_ISR_ROUTINE, "UART_ISR_ROUTINE", 2048, NULL, 12, NULL);
//vTaskDelete(NULL);
Create a ISR function
static void UART_ISR_ROUTINE(void *pvParameters) //uart1
{
uart_event_t event;
size_t buffered_size;
bool exit_condition = false;
String ODU_PAC_ONE_Temp = "";
ODU_PAC_ONE = "";
while (1) {
if (xQueueReceive(uart1_queue, (void * )&event, (portTickType)portMAX_DELAY)) {
if (event.type == UART_DATA) {
uint8_t UART1_data[128];
int UART1_data_length = 0;
ESP_ERROR_CHECK(uart_get_buffered_data_len(UART_NUM_1, (size_t*)&UART1_data_length));
UART1_data_length = uart_read_bytes(UART_NUM_1, UART1_data, UART1_data_length, 100);
for (byte i = 0; i < UART1_data_length; i++) {
ODU_PAC_ONE_Temp += (int) UART1_data[i];
}
}
else if (event.type == UART_FRAME_ERR) {
}
}
if (exit_condition) {
break;
}
}
vTaskDelete(NULL);
}
You will get your data in here (int) UART1_data[i]