Table Of Contents :
- Watch the Video Tutorial
- About ESP32
- Requirement – Installing Arduino IDE
- Installing ESP32 Board Package In Arduino IDE
- Testing ESP32 With Arduino IDE
- Troubleshooting
- Conclusion
About ESP32
ESP32 series of modules are designed and developed by Espressif. ESP32 modules are small yet have the capability to serve the most demanding task for IoT applications.
It has WiFi+Bluetooth/BLE wireless capabilities, dual-core and single-core modules available, GPIO pins with capacitive touch capabilities, RTC timer block, inbuild hall effect sensor, and more to make this module an ideal choice for your IoT or IIoT projects.
Recently they have announced about there new ESP32-DA module with a dual antenna setup you can check our blog to know more about:
โ New ESP32-WROOM-DA Module
Requirement – Installing Arduino IDE
Before getting started with this tutorial, you will require Arduino IDE installed on your computer.
If you have already installed the latest Arduino IDE, then skip this step.
Else you can follow our easy-to-follow guide on:
โ Getting Familiar With Arduino IDE
Watch the Video Tutorial
This tutorial is available in video format (watch below) and written format (continue reading this page).
Installing ESP32 Board Package In Arduino IDE
To program ESP32 using Arduino IDE, we need to install the ESP32 board package provided by the official espressif.
Follow these simple steps-
- Open Arduino IDE. Now go to File โ Preferences
- Copy-paste the below URL from espressif in the Additional Boards Manager URLs:
If you are new to ESP32 use
Stable release URL:https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
If you are familiar with ESP32 and want to test or want to help in a new development release then use
Development release URL:https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
Then hit the OK button to save the settings.
- Opening the board manager. Go to Tools โ Board โ Boards Manager. It will open a new board manager window, and it will load all contents from the added URLs in step 2. Wait till this process completes.
- Search for ESP32 in the search bar. You will see esp32 by Espressif Systems; select it.
Select the appropriate version number from the right bottom corner. We recommend installing the latest version.Hit the Install button and wait.
- That’s all, ESP32 has been installed in your Arduino IDE.
- You can also confirm installation by going to Tools โ Boards you will see ESP32 Arduino category has been added now.
Note:- If you don’t see ESP32 boards added then try restarting your Arduino IDE
Testing ESP32 With Arduino IDE
We will test your ESP32 board by programming an example sketch that comes with the ESP32 package.
We will upload a WiFiScan example to test everything is working perfectly on ESP32 with Arduino IDE.
WiFiScanย example, will scan all WiFi networks in the range of your ESP32 and print their network SSID in the serial terminal. Additionally, it will also print the RSSI (signal strength) of the network.
Connect your ESP32 board with a micro USB data cable to your computer and follow the instructions for uploading the example to ESP32:
- Selecting proper board. Go to Tools โ Board โ ESP32 Arduino โ ESP32 Dev Module. Leave all settings default.
- Selecting COM port. Go to Tools โ Port โ COM5 (select your ESP32 com port; in our case, it’s COM5).
If the COM port is not shown on your computer, you need to install CP2102 virtual COM port drivers.
CP2102 is a USB to UART chip from Silicon labs used for converting USB data to UART data, and it is taking care of uploading program in our ESP32 board. - Opening the example. Go to File โ Examples โ WiFi (ESP32) โ WiFiScan
A new Arduino project window will be opened named as WiFiScan. - Press the upload button in Arduino IDE for uploading the example code in your ESP32 board.
Now time to hold your breath for a while until the code is compiled and uploaded. - If all goes as per plan, you will see a Done uploading message.
- Open the Serial Monitor in Arduino IDE. Set the baud rate to 115200 as this baud rate is defined in the Example code.
- Now press the EN (Enable) button on the ESP32 board. It will reset the ESP32, and our example code will start from the beginning.
Now ESP32 will scan all available WiFi networks, and then it will print the list of their SSID name in the Serial Monitor.
Troubleshooting
Most commonly, you will end up in this error while uploading
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
This error is caused because your ESP32 board is not entering into bootloader mode. Mostly we have phased this problem in cheap Chinese boards of ESP32.
Solution:
Follow the steps to encounter this error:
- Select the right COM port and board name.
- Press the upload button in Arduino IDE.
- When your code starts compiling, hold down the BOOT button on ESP32.
- When compiling is finished, you will see the Connecting……. message in Arduino IDE, Now you have to release the BOOT button.
If it works, you will see the uploading process started, and some numbers in percentages will be printed.
If you see the same pattern in Arduino IDE, Try holding the BOOT button again for a while and release it.
Note:- Timing is important for this; It may require few tweaks and little practice to solve this.
- After that, you will see the Done uploading message in Arduino IDE.
Now you can press the ESP32 onboard Enable button to restart the uploaded ESP32 code.
Note:- You will need to follow the same button sequence every time you start uploading your code.
Conclusion
We have learned how to start programming ESP32 boards using Arduino IDE. The process had become very simple compared to the initial days when espressif had started integrating ESP32 with the Arduino environment.
Now it’s time for building new projects based on ESP32.
Nice tutorial – thanks TechTonions!
Thank you, Robert.
Hi all,
the “work around” with the boot button works in my case. But on my other computer my ESP32 DEV board works without that. On that other computer I use an older version of the USB driver from 2018. If I find the time I try to figure out what is the reason the uploading works on one computer but not on the other with the same DEV board.
Hello steanRDR,
Yes you are right we have faced the similar issue that you are facing right now. In my case it was between 2 laptops and common dev board. My old dell laptop was able to upload program without any issue but in my new ASUS system it need to press the boot button. Have not observed the driver version in both of them but I think my dell has an old driver and they work like a charm.
But then I figured out a solution for such scenarios, if you closely look at top left corner of the ESP32 board image that we have used in this tutorial we have soldered a small SMD 10uF capacitor between EN and GND pin of ESP32 and now I am able to program it with both laptops perfectly without any issue.
Let me know if you find any info on the driver part as it is very common issue with this boards, I can make a small writeup on different fixes for such issues.
Happy debugging.