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,

[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::
Code: Untitled.c Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "driver/uart.h"
#include "freertos/freeRTOS.h"
#include "freertos/task.h"
void app_main(void)
{
printf("Started ... \n");
int bufferSize = 250;
uart_port_t port = UART_NUM_0;
QueueHandle_t queue;
uart_config_t uartConfig = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(port, &uartConfig);
uart_driver_install(port, bufferSize, bufferSize, 10, &queue, 0);
//TX - RX - RTS - CTS
uart_set_pin(port, 1, 3, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
while(true){
char *t = "Test message!\n";
uart_write_bytes(port, t, strlen(t));
vTaskDelay(pdMS_TO_TICKS(5000));
}
}
::ESP32-S3::
Code: Untitled.c Select all
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
static void echo_task(void *arg)
{
int bufferSize = 250;
uart_port_t port = UART_NUM_1;
QueueHandle_t queue;
uart_config_t uartConfig = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(port, &uartConfig);
//TX - RX - RTS - CTS
uart_set_pin(port, 17, 18, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(port, bufferSize-1, bufferSize, 10, &queue, 0);
// Configure a temporary buffer for the incoming data
uint8_t *data = (uint8_t *) malloc(bufferSize);
while (1) {
// Read data from the UART
size_t len = 0;
uart_get_buffered_data_len(port, &len);
uart_read_bytes(port, data, 1024, pdMS_TO_TICKS(1000));
printf("%d\n",len);
if(len > 0){
printf("%s\n", (char*)data);
}
vTaskDelay(pdMS_TO_TICKS(3000));
}
}
void app_main(void)
{
printf("Started... \n");
xTaskCreate(echo_task, "uart_echo_task", 4096, NULL, 10, NULL);
}
