ESP32 S3 UART Problem

temraire
Posts: 1
Joined: Tue Jan 17, 2023 6:42 pm

ESP32 S3 UART Problem

Postby temraire » Tue Jan 17, 2023 7:10 pm

Hi everyone,

I have an issue about uart communication. I have two esp32 these are esp32-devkit-c_v4(esp32-wroom-32d) and ESP32-DevKitS-V1(esp32-s3-wroom-1).

I want to send data from esp32-wroom-32d(uart0) to esp32-s3(uart1) via uart but i can't it.

I can't read data with uart1 as follow but when i use uart0 it is working.
How can i use uart1 for reading data.

Thanks,

Image


[Pins]
esp32-wroom-32d --> esp32-s3
Tx(pin_uart0_tx) ------------- Rx(pin_uart1_rx_gpio_18)
Rx(pin_uart0_rx) ------------- Tx(pin_uart1_tx_gpio_17)


::Codes::
::ESP32-WROOM-32D::
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "driver/uart.h"
  5.  
  6. #include "freertos/freeRTOS.h"
  7. #include "freertos/task.h"
  8.  
  9. void app_main(void)
  10. {
  11.     printf("Started ... \n");
  12.  
  13.     int bufferSize = 250;
  14.     uart_port_t port = UART_NUM_0;
  15.     QueueHandle_t queue;
  16.  
  17.     uart_config_t uartConfig = {
  18.         .baud_rate = 115200,
  19.         .data_bits = UART_DATA_8_BITS,
  20.         .parity = UART_PARITY_DISABLE,
  21.         .stop_bits = UART_STOP_BITS_1,
  22.         .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
  23.     };
  24.  
  25.  
  26.     uart_param_config(port, &uartConfig);
  27.     uart_driver_install(port, bufferSize, bufferSize, 10, &queue, 0);
  28.  
  29.     //TX - RX - RTS - CTS
  30.     uart_set_pin(port, 1, 3, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
  31.  
  32.    
  33.    
  34.     while(true){
  35.        
  36.         char *t = "Test message!\n";
  37.         uart_write_bytes(port, t, strlen(t));
  38.  
  39.         vTaskDelay(pdMS_TO_TICKS(5000));
  40.     }
  41.    
  42. }

::ESP32-S3::
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "driver/uart.h"
  5.  
  6.  
  7. static void echo_task(void *arg)
  8. {
  9.  
  10.     int bufferSize = 250;
  11.     uart_port_t port = UART_NUM_1;
  12.     QueueHandle_t queue;
  13.  
  14.     uart_config_t uartConfig = {
  15.         .baud_rate = 115200,
  16.         .data_bits = UART_DATA_8_BITS,
  17.         .parity = UART_PARITY_DISABLE,
  18.         .stop_bits = UART_STOP_BITS_1,
  19.         .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
  20.     };
  21.  
  22.  
  23.     uart_param_config(port, &uartConfig);
  24.  
  25.     //TX - RX - RTS - CTS
  26.     uart_set_pin(port, 17, 18, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
  27.  
  28.     uart_driver_install(port, bufferSize-1, bufferSize, 10, &queue, 0);
  29.  
  30.  
  31.     // Configure a temporary buffer for the incoming data
  32.     uint8_t *data = (uint8_t *) malloc(bufferSize);
  33.  
  34.     while (1) {
  35.         // Read data from the UART
  36.  
  37.         size_t len = 0;
  38.         uart_get_buffered_data_len(port, &len);
  39.  
  40.         uart_read_bytes(port, data, 1024, pdMS_TO_TICKS(1000));
  41.         printf("%d\n",len);
  42.         if(len > 0){
  43.             printf("%s\n", (char*)data);
  44.         }
  45.  
  46.         vTaskDelay(pdMS_TO_TICKS(3000));
  47.     }
  48. }
  49.  
  50. void app_main(void)
  51. {
  52.     printf("Started... \n");
  53.  
  54.     xTaskCreate(echo_task, "uart_echo_task", 4096, NULL, 10, NULL);
  55. }

ESP_LJH
Posts: 387
Joined: Tue May 18, 2021 9:21 am

Re: ESP32 S3 UART Problem

Postby ESP_LJH » Thu Jan 19, 2023 8:30 am

Could you do not use UART0 to communicate, it is connected to a serial chip, then serial chip may affect the communication.
You could try to 1) use anther GPIO pair as UART 2) replace UART0 series resistor ( 0 ohm ) with 500 ~ 1K.

Who is online

Users browsing this forum: No registered users and 62 guests