Start a new topic

ESP32 Serial ports

There are three 'normal" serial ports on the ESP but one has a problem if externally connected during a reset of the ESP. This is Serial1 that is normally assigned to IO-12 and IO-13. The reason for this is that the state of IO-12 at boot up determines an internal voltage level to the flash and hence can be placed to the wrong value. If you boot up with nothing connected to IO-12 (or a high impedance) then once the ESP is running then Serial1 works fine.


So if you have a standard breakout board for the ESP ( Development Board) then you are really limited to Serial2 on IO-16 and IO-17 as the only available permanent connection (unless you take care on the hardware interconnection to IO-12) as the normal Serial is interconnected to the USB programming port (and connected to RXDO and TXDO).


If you are using the basic ESP32 wroom module you can then use Serial and Serial2 as the programming and permanent connection and Serial1 as say a debug port with a physical connection after running.


I used the word 'normal' above. This is because there is a method to assign almost any I/O to any function. This advanced feature, as well as several others, are not yet available in the standard Arduino IDE.


To invoke the serials in ESP32 use


HardwareSerial Serial1(1);

#define SERIAL1_RXPIN 12 

#define SERIAL1_TXPIN 13

HardwareSerial Serial2(2); // pin 16=RX, pin 17=TX

 

and in setup

  Serial.begin(9600);

  Serial1.begin(9600, SERIAL_8N1, SERIAL1_RXPIN, SERIAL1_TXPIN);

  Serial2.begin(115200); // pin 16=RX, pin 17=TX   


For a reason that escapes me there is no need to use the extended form on Serial2 for the pin 16 and 17 combination .


There are just so many features and some limitations on this new device that its going to take some learning.


Other threads show how to adjust the Nextion.h file to cope with your connection.




Which Development Board does this refer to?

I have two types via Bangood of the Geekcreit make...  However, this is not a feature of the boards but of the ESP32 wroom module itself. Refer ESP32 Hardware Design Guidelines  Section 2.3 Strapping Pins. and 5.1 UART to WiFi Smart device


I found the problem first on a FTD serial interface unit and it also exhibits on the two Nextions I own.


Just to update 

You can use other pin selections for Serial1(1) such as

HardwareSerial Serial1(1);

#define SERIAL1_RXPIN 23 

#define SERIAL1_TXPIN 22 

without an issue... Only GPIO 12 gives problems


Login or Signup to post a comment