Arduino and ESP32 Serial Communication using UART_ 'Serial2' was not declared in this scope

I have followed this vedio but facing the error that 'Serial2' was not declared in this scope

Hello @sapna12345

Can you share what is the ESP32 board that you are using? Does it say that it supports Serial2?

Also ESP32's Pins for RX and TX are not standardized, like on mine (Adafruit ESP32 V2), the RX and TX pins are 7 and 8, not like 16 and 17 as shown for the ESP32 board shown on YouTube.

image

I'm using ESP8266 Board.

Then you picked an odd title to name this thread "Arduino and ESP32 Serial Communication using UART_ ‘Serial2’ was not declared in this scope"

ESP8266 hasn't serial2.

Hi @sapna12345,

as already stated by others here the reason for the error message is that you do not use a ESP32 but a ESP8266 board.

Further information can be found

https://www.robmiles.com/journal/2021/1/29/using-the-second-serial-port-on-the-esp8266

and

https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/

If you want to connect the ESP8266 with your Arduino Serial Monitor (PC) and with a second device (here the Arduino) in parallel you can try to use SoftSerial

https://circuits4you.com/2016/12/16/esp8266-software-serial/

As ESP32 boards are not very expensive it might be worth to buy one as they provide better capabilities.

Good luck and have fun!
ec2021

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.