Hi, after uploading my code via usb my arduino nano esp32 is disconnecting from my laptop.
I've been testing with an example program and immediately after the code is uploaded, the board disconnects and the on-board led flashes blue/red/green. It .continues to do this and won't reconnect until the re-set button is pressed and the board is physically disconnected from my laptop
Hi @charlottehh. Please post your full sketch. I'll take a look and see if I can spot the problem.
I'll provide instructions you can follow to do that:
Auto Format your code by following these instructions:
If using Arduino IDE: select Tools > Auto Format from the menus.
If using Arduino Cloud Editor: press the Ctrl+B keyboard shortcut.
Click on the window that contains your sketch code.
Press the Ctrl+A keyboard shortcut.
This will select all the text.
Press the Ctrl+C keyboard shortcut.
This will copy the selected text to the clipboard.
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 the Ctrl+V keyboard shortcut.
This will paste the compilation output into the code block.
Move the cursor outside of the code block markup before you add any additional text to your reply.
Repeat the above process if your sketch has multiple tabs.
Click the "Reply" button to post the output.
When your code requires a library that's not included with the Arduino IDE please post a link to where you downloaded that library from, or if you installed it using Library Manager (Sketch > Include Library > Manage Libraries... in Arduino IDE or Libraries > Library Manager in "Arduino Cloud Editor") then say so and state the full name of the library.
OK, great. I was able to reproduce the problem by uploading your sketch to my Nano ESP32.
I noticed that you forgot to add a call to display.begin in your setup function before attempting to use the display. Once I added this line to the top of the setup function to the sketch, the problem went away:
So please try doing that. You can learn about this function by studying the examples for the library. You can access the examples via the File > Examples > Adafruit SSD1306 menu in Arduino IDE.