Is there an equivalent pin on ESP32? Also is there a RXD1 on ESP32 and what pin is it?
Hi.
TXD1 on ESP8266 is GPIO2 (D4).
On the ESP32:
- TXD1:GPIO 9
- RXD1: GPIO10
However, these GPIOs are internally connected to the SPI Flash of the ESP32. So, I don’t recommend using those pins.
I recommend taking a look at the following articles that describe in detail the pinout of these bords:
- ESP8266: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
- ESP32: https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
Let me know if you need further help.
Regards,
Sara
Thank you for your answer. I need two serial ports. If I switch to ESP32, can I use TXD2 and RXD2 instead. I believe this is supported by the Arduino IDE. Is there a project in the ESP32 eBook that uses the TXD2 and RXD2?
Hi Anthonny.
If you need two serial ports in the ESP32, you can use:
- TX0 and RX0: GPIO 1 and GPIO 3
- TX2 and RX2: GPIO 17 and GPIO 16
Format for setting a serial port:
Serial.begin(baud-rate, protocol, RX pin, TX pin);
Example for initializing two serial ports:
#define RXD2 16 #define TXD2 17 #define RXD0 3 #define TXD0 1 void setup() { Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2); Serial2.begin(9600, SERIAL_8N1, RXD0, TXD0); }
Then, use the usual functions to interact with serial objects.
I hope this helps.
Regards,
Sara