• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

How to use Serial2 in ESP32 DOIT DEVKIT?

Q&A Forum › Category: ESP32 › How to use Serial2 in ESP32 DOIT DEVKIT?
0 Vote Up Vote Down
Robert Baldwin asked 2 years ago

First, I love your site, tutorials and courses!
I have a project for which I’d like to use the UART2 peripheral on an ESP32 DOIT DEVKIT V1 board but I cannot seem to get the hardware serial port to work.  I’ve included #include <HardwareSerial.h> (but shouldn’t have to as the Serial2 class is already recognized).  I initialize in Setup with Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);, where RXD2 = 16 & TXD2 = 17. 
Executing Serial2.write(comBuffer, ComBufferSize); produces no output on GPIO17, either to a serial monitor or watching the pin with an oscilloscope. 
I thought I remembered an RNT tutorial covering use of multiple serial ports on the ESP32 but I haven’t been able to locate it.  Would you kindly point me to one if one exists and/or suggest what I might be missing?
Thanks,
Mitchell

 

 
 

2 Answers
0 Vote Up Vote Down
Robert Baldwin answered 2 years ago

I got this working by declaring a new HardwareSerial instance:

HardwareSerial HostPCSerialPort(2);

and initializing:

HostPCSerialPort.begin(460800, SERIAL_8N1, 27, 14);

It seems odd that no errors resulted when I used the pre-defined “Serial2”, but I learned a lot in the process of figuring this out 🙂

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Unfortunately, we don’t have yet, a tutorial about Serial2.
I’ve remember watching a very good youtube video of Andreas Spiess (the swiss accent) about using Serial communication with the ESP32.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.