I have been playing with ESP32 module for the past few days. I have gotten around activating UART1 using IO 9 (RX) and IO 10 (TX). The following code is my UART setting:
Code: Select all
int uart_num = 1; //uart port number
uart_config_t uart_config = {
.baud_rate = 19200, //baudrate
.data_bits = UART_DATA_8_BITS, //data bit mode
.parity = UART_PARITY_EVEN, //parity mode
.stop_bits = UART_STOP_BITS_1, //stop bit mode
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, //hardware flow control(cts/rts)
.rx_flow_ctrl_thresh = 120, //flow control threshold
};
uart_param_config(uart_num, &uart_config);
//QueueHandle_t uart_queue;
if(uart_driver_install(uart_num, 1024 * 2, 1024 * 2, 0, UART_INTR_NUM, NULL) != ESP_OK){
puts("uart driver install failed");
}
uart_set_pin(uart_num, 10, 9, 15, 13);
uart_set_word_length(uart_num, UART_DATA_8_BITS);
uart_set_parity(uart_num, UART_PARITY_EVEN);
Code: Select all
if((recv(client_sock2, &recvbuffer,32,0))>0){
uart_write_bytes(uart_num, (const char*) recvbuffer, 32);
}
Anybody has any idea if I did anything wrong?