ESP32 UARTs/Serial pins

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lzemail
 
Posts: 52
Joined: Tue May 29, 2012 5:00 pm

ESP32 UARTs/Serial pins

Post by lzemail »

Product:
Adafruit ESP32 Feather V2 - 8MB Flash + 2 MB PSRAM - STEMMA QT
https://www.adafruit.com/product/5400

Objective: Use/need additional UARTs/serial pins. Try to find out all the UARTs' / serial pin numbers.

Questions:
1. The product description page says "3 x UARTs (only two are configured by default in the Feather Arduino IDE support, one UART is used for bootloading/debug)". Which two are configured by default and which one is used for bootloading/debug)? What does "configured by default" mean?
2. What are the three UARTs / serial pin numbers?
3. This page https://cdn-learn.adafruit.com/assets/a ... 1657054446 shows some UARTs CTS and RTC pins but not UARTs' Rx and Tx pins except Pin 7 and Pin 8 are marked as RX and TX. Are Pin7 and Pin8 UART2's RX and TX or something else?
(Please see attached screenshot).
ESP32FeatherV2-pinout.png
ESP32FeatherV2-pinout.png (386.56 KiB) Viewed 86 times
4. Searched the datasheet per this link https://cdn-shop.adafruit.com/product-f ... eet_en.pdf. Unable to find the needed UART pin numbers, except those already marked on this page https://cdn-learn.adafruit.com/assets/a ... 1657054446
Maybe I missed something?

Thanks.

User avatar
snkYmkrct
 
Posts: 11
Joined: Sat Oct 19, 2013 12:14 pm

Re: ESP32 UARTs/Serial pins

Post by snkYmkrct »

The product description page actually says:
Here are specifications from Espressif about the ESP32:
...
3 x UARTs (only two are configured by default in the Feather Arduino IDE support, one UART is used for bootloading/debug)
This means that the microcontroller has support for 3 UART connections, but only 2 of those connections can be accessed in the Feather board design (the pins for the 3rd one are not broken out).

You have a freely available connection on the RX (pin 7) and TX (pin 8) pins.

RX0 (pin 22) and TX0 (pin 19) are also available, but as seen in the board schematic https://cdn-learn.adafruit.com/assets/a ... V2_sch.png, they are also connected to the USB-to-Serial converter, so if you use them at the same time as the USB, you will get the USB traffic on them. They also overlap in functionality with the SPI and I2C connections.

User avatar
lzemail
 
Posts: 52
Joined: Tue May 29, 2012 5:00 pm

Re: ESP32 UARTs/Serial pins

Post by lzemail »

Thanks for the information.
The pinout map shows pin7 as RX and U2RTS, pin8 as TX and U2CTS. Does that mean each pin has two functions (i.e. pin7 is for U2RX and U2RTS, pin8 is for U2TX and U2CTS) for UART2? I thought RX, RTS, TX and CTS need to be separate pins?

User avatar
lzemail
 
Posts: 52
Joined: Tue May 29, 2012 5:00 pm

Re: ESP32 UARTs/Serial pins

Post by lzemail »

Adafruit Support: Could you please provide some answers/information on this (please also see the original post/questions)?
Thank you.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32 UARTs/Serial pins

Post by adafruit_support_mike »

lzemail wrote: Tue Dec 27, 2022 4:45 pm Which two are configured by default and which one is used for bootloading/debug)?
Read a bit lower on the Pinouts page:
RX - This is the UART RX (receive) pin. It is also pin 8. Connect to the TX pin found on a breakout or device. This is separate than the 'debug UART' which is connected to the USB-to-Serial converter, so it will not interfere during upload.
TX - This is the UART TX (transmit) pin. It is also pin 7. Connect to the RX pin found on a breakout or device. This is separate than the 'debug UART' which is connected to the USB-to-Serial converter, so it will not interfere during upload.
The UART pins for the debug connection (identifed as the Serial interface in the Arduino IDE) are shown on the schematic:

https://cdn-learn.adafruit.com/assets/a ... 1646779441

They're signals RXD0 and TXD0 on physical pins 30 and 31.
lzemail wrote: Tue Dec 27, 2022 4:45 pm What does "configured by default" mean?
It means the board support package only defines pin connections to signals for two of the three UART peripherals built into the ESP32. Which relates directly to:
lzemail wrote: Tue Dec 27, 2022 4:45 pm What are the three UARTs / serial pin numbers?
There are no pin numbers. Only signal names.

With only a few exceptions, the ESP32 can map every internal signal to every physical pin on the package. The last time I looked there were something like 192 possible signals for all the internal peripherals.

As such, the first thing you have to do with an ESP32 is tell it what signals to use, and how to connect them to physical pins.

The ESP32 has three 'instances of peripherals' (identical circuits) that handle the UART signal protocol. Our board support package connects one of them to pins 30 and 31 which talk to the USB-to-Serial converter, and one to pins 7 and 8 for use as general-purpose Serial communication with other devices. It doesn't do anything with the third.

The third UART peripheral still exists, you can write code to enable it, and you can tell the ESP32's pin multiplexer to connect its signals to any of the pins broken out to the edge of the board. That's code you'd have to write yourself though, as opposed to the signal/pin configuration that comes with the board by default.
lzemail wrote: Tue Dec 27, 2022 4:45 pm Maybe I missed something?
For the level of programming you apparently want to do, it would be a very good idea to read the ESP32 datasheet to learn how to chip is organized internally, and what's involved in using the peripherals. From there, it would be helpful to look through the code in the ESP32 board support package to learn the API-level code that does things like configure a UART:

https://cdn-learn.adafruit.com/assets/a ... 1646852017

https://github.com/adafruit/arduino-esp32

User avatar
lzemail
 
Posts: 52
Joined: Tue May 29, 2012 5:00 pm

Re: ESP32 UARTs/Serial pins

Post by lzemail »

adafruit_support_mike:
Thank you very much for the very detailed and helpful information.
The ESP32 has three 'instances of peripherals' (identical circuits) that handle the UART signal protocol. Our board support package connects one of them to pins 30 and 31 which talk to the USB-to-Serial converter, and one to pins 7 and 8 for use as general-purpose Serial communication with other devices. It doesn't do anything with the third.
Does this mean that the pin30/pin31 connected UART instance is UART0 (based on the label RXD0 and TXD0)?
If yes, what would be the UART number for the pin7/pin8 connected UART instance, e.g UART2? Or maybe my concept / understanding of the UART numbers (e.g. UART0, UART1, UART2) is not correct, or the UART number is irrelevant/insignificant?

I am trying to learn how to specify/address the pin7/pin8 connected UART when using Arduino IDE. For example, is the following the correct way to use the pin7/pin8 connected UART?

Code: Select all

define RXD2 7
define TXD2 8
HardwareSerial Serial2(RXD2, TXD2);

void setup()
{
Serial2.begin(9600);
}  
Thanks.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”