Author Topic: ESP-WROOM-32: UART1 and UART2 pins  (Read 820 times)

0 Members and 1 Guest are viewing this topic.

Offline HolupTopic starter

  • Newbie
  • Posts: 3
  • Country: sk
ESP-WROOM-32: UART1 and UART2 pins
« on: June 10, 2024, 06:50:24 am »
Hi,

I want to use an ESP32 for the first time in a project, but am a bit confused about UART1 and UART2 pins and multiple versions of the ESP32 and modules.

I bought a few of these modules:
https://www.aliexpress.com/item/1005004268911484.html

I eventually want to use a bare ESP32 instead of the module, probably this one, as it seems to be only one available at LCSC:
https://www.lcsc.com/product-detail/WiFi-Modules_Espressif-Systems-ESP32-WROOM-32-N4_C82899.html

I am attaching a pinout image I found on the internet, that mostly resembles my modules.
It says U2_TXD is GPIO17, and U1 is not shown at all.

When I uploaded this code and scoped all the pins...
Code: [Select]
Serial.println( "UART0 - PC" );
Serial1.println( "UART1" );
Serial2.println( "UART2" );
... I found out that Serial1 (U1_TXD) is my GPIO27, and Serial2 (U2_TXD) is my GPIO25.
(I did not specify any pins when initializing the connection.)

I could not find any information online when this could be happening.

I am uploading the code via Arduino IDE. I downloaded esp32 boards definitions by Espressif. Selected board is "ESP32 Dev Module".
Maybe something wrong with my board selection?

Can UART1 and UART2 be mapped to different pins in case my modules use pin incompatible ESP32 with the one from LCSC?
« Last Edit: June 10, 2024, 07:14:18 am by Holup »
 

Offline elektryk

  • Regular Contributor
  • *
  • Posts: 104
  • Country: pl
Re: ESP-WROOM-32: UART1 and UART2 pins
« Reply #1 on: June 10, 2024, 08:10:35 am »
 
The following users thanked this post: Holup

Offline selcuk

  • Regular Contributor
  • *
  • Posts: 239
  • Country: tr
Re: ESP-WROOM-32: UART1 and UART2 pins
« Reply #2 on: June 10, 2024, 08:41:52 am »
You can reassign the UART pins to any GPIO. But I recommend to keep UART0 as is and reassign UART1 & UART2 to keep things simple.

By the way, that one is a module as well. Bare ESP32 is this one:
https://www.lcsc.com/product-detail/RF-Transceiver-ICs_Espressif-Systems-ESP32-D0WD-V3_C967021.html
 
The following users thanked this post: Holup

Offline HolupTopic starter

  • Newbie
  • Posts: 3
  • Country: sk
Re: ESP-WROOM-32: UART1 and UART2 pins
« Reply #3 on: June 10, 2024, 01:16:52 pm »
Thanks for the responses.

I took a look at `HardwareSerial.h` file located at `C:\Users\holup\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1`
I got the file location from verbose compile output of Arduino IDE.

Here I found my default pin definitions...

Code: [Select]
#if CONFIG_IDF_TARGET_ESP32
#define RX1 (gpio_num_t)26
...
#if CONFIG_IDF_TARGET_ESP32
#define TX1 (gpio_num_t)27
...
#if CONFIG_IDF_TARGET_ESP32
#define RX2 (gpio_num_t)4
...
#if CONFIG_IDF_TARGET_ESP32
#define TX2 (gpio_num_t)25

It seems that in my case:
RX1 = GPIO26
TX1 = GPIO27
RX2 = GPIO4
TX2 = GPIO25

(I did not verify the RX pins on my board yet)

There are different pins defined for `CONFIG_IDF_TARGET_`: `ESP32`, `ESP32S2`, `ESP32C2`, `ESP32C3`, `ESP32S3`, `ESP32C6`, `ESP32H2`

I found definition for these constants in `C:\Users\holup\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083\`
Here are directories: `esp32`, `esp32c3`, `esp32c6`, `esp32h2`, `esp32s2`, `esp32s3`
Is one of these folders set by selecting the board in the Arduino IDE?

How would I notice if I had wrong board/config location selected? Would it fail completely, or would I, for example, have pins in unexpected places?

Each folder contains two files `sdkconfig.h` in dirs `dio_qspi` and `qio_qspi`. They define constants like `CONFIG_IDF_TARGET_ESP32`.
What are `dio_qspi` and `qio_qspi` and how to find out which one am I using or should use?

Where does the discrepancy between my config and most pinouts I found online come from?
 

Online tooki

  • Super Contributor
  • ***
  • Posts: 12587
  • Country: ch
Re: ESP-WROOM-32: UART1 and UART2 pins
« Reply #4 on: June 15, 2024, 12:06:50 pm »
Hi,

I want to use an ESP32 for the first time in a project, but am a bit confused about UART1 and UART2 pins and multiple versions of the ESP32 and modules.

I bought a few of these modules:
https://www.aliexpress.com/item/1005004268911484.html

I eventually want to use a bare ESP32 instead of the module, probably this one, as it seems to be only one available at LCSC:
https://www.lcsc.com/product-detail/WiFi-Modules_Espressif-Systems-ESP32-WROOM-32-N4_C82899.html

I am attaching a pinout image I found on the internet, that mostly resembles my modules.
It says U2_TXD is GPIO17, and U1 is not shown at all.

When I uploaded this code and scoped all the pins...
Code: [Select]
Serial.println( "UART0 - PC" );
Serial1.println( "UART1" );
Serial2.println( "UART2" );
... I found out that Serial1 (U1_TXD) is my GPIO27, and Serial2 (U2_TXD) is my GPIO25.
(I did not specify any pins when initializing the connection.)

I could not find any information online when this could be happening.

I am uploading the code via Arduino IDE. I downloaded esp32 boards definitions by Espressif. Selected board is "ESP32 Dev Module".
Maybe something wrong with my board selection?

Can UART1 and UART2 be mapped to different pins in case my modules use pin incompatible ESP32 with the one from LCSC?
Yes, you can remap.

But let’s clear up ESP32 terminology, because you’re using it exactly wrong.

The thing you’re calling a “module” is known as a dev kit, or board, in the ESP32 world.

The thing you’re calling a “bare chip” is actually called a module.

An actual bare chip ESP32 exists, and is literally the MCU IC itself, and won’t function until you add a crystal, caps, and in most cases flash memory. If you use one with WiFi or Bluetooth, you have to then get it certified.

A module contains the bare chip and all necessary support components, with a metal shield can, on a small, thin PCB with edge castellations, which needs to be soldered to a bigger PCB. An ESP32 module is certified for its radios and is ready to use.

A dev kit contains a module, plus USB bridge chip and a voltage regulator, on a PCB with pins.
 
The following users thanked this post: Holup, Exxor


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf