My sketch worked perfectly under 2.1.1 with an ESP32 using core version 2.0.11. After updating the IDE to 2.2.0 it can't use Serial2:
....\Arduino\XXX_prototype_QR\XXX_prototype_QR.ino:257:3: error: 'Serial2' was not declared in this scope
Serial2.begin(GPS_BAUD, SERIAL_8N1); // GPS serial
^~~~~~~
.
.
.
Compilation error: 'Serial2' was not declared in this scope
I will try to extract the serial code and post it here. Meanwhile, I reinstalled 1.8.19. All works perfectly as it did under 2.1.1. I would have gone back to 2.1.1 but it is no longer on the website.
You can always download all the releases from GitHub. 2.1.1 is here for the time being. You might need to click on the Assets section to expand to see all the artifacts.
C:\Users\KarlB\AppData\Local\Temp.arduinoIDE-unsaved2023729-20616-1nd8n2n.qimem\sketch_aug29a\sketch_aug29a.ino: In function 'void setup()':
C:\Users\KarlB\AppData\Local\Temp.arduinoIDE-unsaved2023729-20616-1nd8n2n.qimem\sketch_aug29a\sketch_aug29a.ino:3:3: error: 'Serial2' was not declared in this scope
Serial2.begin(9600, SERIAL_8N1);
^~~~~~~
C:\Users\KarlB\AppData\Local\Temp.arduinoIDE-unsaved2023729-20616-1nd8n2n.qimem\sketch_aug29a\sketch_aug29a.ino:3:3: note: suggested alternative: 'Serial'
Serial2.begin(9600, SERIAL_8N1);
^~~~~~~
Serial
exit status 1
Compilation error: 'Serial2' was not declared in this scope
I have just installed 2.2.0, set the target to DOIT ESP32 DEVKIT V1 and the sketch compiles OK for me. I am using the ESP32 boards files version 2.0.11 which is the same as you
Try uninstalling the board files and installing them again
My brain took a reset during a happy vacation and I unwisely updated to IDE 2.2.1, forgetting the grief caused by 2.2.0. As before, it sees Serial2 as undefined.
Where are the board files located and what should be deleted?
Hi @W4KRL. I'm going to ask you to post the full verbose output from a compilation.
This procedure is not intended to solve the problem. The purpose is to gather more information.
Please do this:
Select File > Preferences... from the Arduino IDE menus.
The "Preferences" dialog will open.
Check the box next to "Show verbose output during: ☐ compilation" in the "Preferences" dialog.
Click the OK button.
Select Sketch > Verify/Compile from the Arduino IDE menus.
Wait for the compilation to fail.
You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the COPY ERROR MESSAGES button on that notification.
Open a forum reply here by clicking the Reply button.
Click the <CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
Press Ctrl+V.
This will paste the compilation output into the code block.
Move the cursor outside of the code tags before you add any additional text to your reply.
Click the Reply button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:
Open a forum reply here by clicking the Reply button.
Click the "Upload" icon () on the post composer toolbar:
A dialog will open.
In the dialog, select the .txt file you saved.
Click the Open button.
Click the Reply button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.