ESP32 UART Hardware Serial Ports Help

kpin404
Posts: 14
Joined: Sat Apr 23, 2022 4:45 am

ESP32 UART Hardware Serial Ports Help

Postby kpin404 » Tue Jul 12, 2022 1:59 pm

Hello there, I am working out on ESP32 for one of my projects as it says that it has the advantage of direct access to use 3 hardware UART serial ports. But I found that it has only one hardware UART serial port which works actually only i.e RX 16, TX 17 and other 2 UART hardware serial ports not work at all as they are internally connected and can not use externally and if tried to use they don't work and crash the ESP32. So its wrongly described about the advantage of direct access to use 3 hardware UART serial ports on ESP32. If someone has successfully used these UART0, UART1 ports externally just like UART2 (RX 16, TX 17) please let me assist with the same. Thanking you.

lbernstone
Posts: 831
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 UART Hardware Serial Ports Help

Postby lbernstone » Tue Jul 12, 2022 5:01 pm

You can assign the serial ports to whatever pins you have available when you initialize.

Code: Select all

Serial1.begin(115200, SERIAL_8N1, RX_1, TX_1);
Serial2.begin(9600, SERIAL_8N1, 21, 22);
https://github.com/espressif/arduino-es ... ard-pinmap

kpin404
Posts: 14
Joined: Sat Apr 23, 2022 4:45 am

Re: ESP32 UART Hardware Serial Ports Help

Postby kpin404 » Wed Jul 13, 2022 4:08 am

lbernstone wrote:
Tue Jul 12, 2022 5:01 pm
You can assign the serial ports to whatever pins you have available when you initialize.

Code: Select all

Serial1.begin(115200, SERIAL_8N1, RX_1, TX_1);
Serial2.begin(9600, SERIAL_8N1, 21, 22);
https://github.com/espressif/arduino-es ... ard-pinmap
Hello, sorry i have already been gone through this and it didn't work at all. Actually, I want to use GPS on UART1 serial port of ESP32 and when run the code sketch it didn't work at all on UART1 serial port and when I run the same code sketch on UART2 i.e. RX 16/TX 17 of ESP32 it works very well without any issue. Thanks.

Momin786
Posts: 13
Joined: Mon Jul 11, 2022 7:52 am
Contact:

Re: ESP32 UART Hardware Serial Ports Help

Postby Momin786 » Wed Jul 13, 2022 5:24 am

Default pins for UART1 (GPIO9 and GPIO10) do not work. Because they are internally connected to flash. You can use any other GPIO pins. You can check this tutorial: https://microcontrollerslab.com/esp32-u ... s-example/
I create ESP32 tutorials and Projects using ESP-IDF https://esp32tutorials.com/

kpin404
Posts: 14
Joined: Sat Apr 23, 2022 4:45 am

Re: ESP32 UART Hardware Serial Ports Help

Postby kpin404 » Wed Jul 13, 2022 6:15 am

Momin786 wrote:
Wed Jul 13, 2022 5:24 am
Default pins for UART1 (GPIO9 and GPIO10) do not work. Because they are internally connected to flash. You can use any other GPIO pins. You can check this tutorial: https://microcontrollerslab.com/esp32-u ... s-example/
Actually, I have already been gone through your provided tutorial, but it didn't work. Secondly, I want to use UART1 hardware serial as per its datasheet and software serial no longer works with ESP32 at all. Thanks.

Momin786
Posts: 13
Joined: Mon Jul 11, 2022 7:52 am
Contact:

Re: ESP32 UART Hardware Serial Ports Help

Postby Momin786 » Wed Jul 13, 2022 6:55 am

I have myself followed the same tutorial and used the HardwareSerial example in that tutorial and changed UART2 to UART1 in the example code, it worked fine for me.
I create ESP32 tutorials and Projects using ESP-IDF https://esp32tutorials.com/

kpin404
Posts: 14
Joined: Sat Apr 23, 2022 4:45 am

Re: ESP32 UART Hardware Serial Ports Help

Postby kpin404 » Wed Jul 13, 2022 11:22 am

Momin786 wrote:
Wed Jul 13, 2022 6:55 am
I have myself followed the same tutorial and used the HardwareSerial example in that tutorial and changed UART2 to UART1 in the example code, it worked fine for me.
Which esp32 board version it has worked for you? Thanks.

Momin786
Posts: 13
Joined: Mon Jul 11, 2022 7:52 am
Contact:

Re: ESP32 UART Hardware Serial Ports Help

Postby Momin786 » Wed Jul 13, 2022 1:24 pm

ESP32 dev kit.
I create ESP32 tutorials and Projects using ESP-IDF https://esp32tutorials.com/

kpin404
Posts: 14
Joined: Sat Apr 23, 2022 4:45 am

Re: ESP32 UART Hardware Serial Ports Help

Postby kpin404 » Wed Jul 13, 2022 1:45 pm

Momin786 wrote:
Wed Jul 13, 2022 1:24 pm
ESP32 dev kit.
Could you please let me know which pin numbers you have used for serial1/UART1 port on ESP32 dev kit? Thanks.

Momin786
Posts: 13
Joined: Mon Jul 11, 2022 7:52 am
Contact:

Re: ESP32 UART Hardware Serial Ports Help

Postby Momin786 » Wed Jul 13, 2022 1:53 pm

#include <HardwareSerial.h>

HardwareSerial SerialPort(1); // use UART1

void setup()
{
SerialPort.begin(15200, SERIAL_8N1, 4, 2);
}
I create ESP32 tutorials and Projects using ESP-IDF https://esp32tutorials.com/

Who is online

Users browsing this forum: JimNickerson and 37 guests