Two UART periferals in the same GPIO pins

try_except
Posts: 2
Joined: Thu Jan 23, 2025 12:50 pm

Two UART periferals in the same GPIO pins

Postby try_except » Thu Jan 23, 2025 1:10 pm

Hello,
I'm currently working with an ESP32-CAM board, so I don't have many pins available for external communication (I'm using both the camera and the PSRAM). I need to communicate the board via RS485, so I need 3 pins to make it work. I'm currently using GPIO12 (the only "free" pin I have left) for the RX ENABLE signal, but I still need TX and RX so I thought "well, I can use GPIO1 and GPIO3 for this", but the thing is that after setting the pins for UART_NUM_2, I loose serial output to the terminal even if I don't output anything via UART_NUM_2. Reading through the Technical Reference Manual I can't find anything that suggests that I can't use two peripherals on the same pins, but maybe this is related to UART_NUM_0 being routed via IOMUX and UART_NUM_2 via the GPIO Matrix. It would be nice to have this two UARTs because the RS485 line that I'm connecting to works at 9600 bauds and the ESP32-CAM works at 115200.

My question is: Is it possible to attach two UART peripherals to the same pins? And if so, how can I work around my current situation? I know that I can simply lower the baudrate for the ESP32 serial port but I would much rather have two separate peripherals.
Last edited by try_except on Thu Jan 23, 2025 2:50 pm, edited 1 time in total.

ESP_Sprite
Posts: 9883
Joined: Thu Nov 26, 2015 4:08 am

Re: Two UART periferals in the same GPIO pins

Postby ESP_Sprite » Thu Jan 23, 2025 2:41 pm

You cannot connect two output signals to the same pin. (Conceptually: if you could, and one signal would drive the pin high and the other drives the pin low, you would have a short.)

try_except
Posts: 2
Joined: Thu Jan 23, 2025 12:50 pm

Re: Two UART periferals in the same GPIO pins

Postby try_except » Thu Jan 23, 2025 2:59 pm

Thanks! Reading your reply it seemed obvious; the UART that is not "talking" wants to drive TX high (idle), so nothing can go through. Not sure why it didn't occur to me.

PD: This was my first time using the forum and I'm amazed at how fast you replied! Thanks again

akshay9
Posts: 2
Joined: Thu Jan 09, 2025 9:32 pm

Re: Two UART periferals in the same GPIO pins

Postby akshay9 » Thu Jan 23, 2025 6:35 pm

Hi ESP_Sprite,
If you are constrained by I/O pins, use a multiplexer to solve this problem. If you need more help, send a detailed use case.
Best,
Akshay

MicroController
Posts: 1955
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Two UART periferals in the same GPIO pins

Postby MicroController » Sat Jan 25, 2025 9:36 pm

You may be able to get away without a DE/RE signal, saving one I/O pin: https://docs.espressif.com/projects/esp ... r-receiver

Who is online

Users browsing this forum: pppp12 and 32 guests