Search

Search more

Search

Share post

Sections

Installing ESP32 In Arduino IDE

Want to explore IoT projects? Then learning ESP32 is a great starting point. In this tutorial, you will learn how to install ESP32 in Arduino IDE. We will use Windows for this tutorial, but the same steps can be used for, mac and Linux OS.
To program ESP32, we have to add an addon package in Arduino IDE.
installing ESP32 board in arduino IDE fetured image displaying quick setup

Table Of Contents :

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-

  1. Open Arduino IDE. Now go to File โ†’ Preferences
    opening Arduino IDE preferences section
  2. 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

    Adding ESP32 board package URL in additional boards URL field in Arduino IDE

    Then hit the OK button to save the settings.

  3. 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.
    Opening Arduino IDE board manager
  4. 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.
    selecting version number while installing ESP32 package in Arduino IDE board manager

    Hit the Install button and wait.

    Serching ESP32 package in Arduino IDE board manager
  5. That’s all, ESP32 has been installed in your Arduino IDE.
    ESP32 board package installed successfully in Arduino IDE
  6. 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:

  1. Selecting proper board. Go to Tools โ†’ Board โ†’ ESP32 Arduino โ†’ ESP32 Dev Module. Leave all settings default.
    Selecting ESP32 dev board in arduino ide board manager
  2. Selecting COM port. Go to Tools โ†’ Port โ†’ COM5 (select your ESP32 com port; in our case, it’s COM5).
    Selecting com port for ESP32 board in Arduino IDE
    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.

  3. Opening the example. Go to File โ†’ Examples โ†’ WiFi (ESP32) โ†’ WiFiScan
    A new Arduino project window will be opened named as WiFiScan.
    ESP32 WiFi scan Example code opened on Arduino IDE
  4. 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.
    ESP32 board program uploading from Arduino IDE
  5. If all goes as per plan, you will see a Done uploading message. 
    ESP32 board Done uploading message shown in Arduino IDE
  6. Open the Serial Monitor in Arduino IDE. Set the baud rate to 115200 as this baud rate is defined in the Example code.

  7. 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.
    ESP32 WiFi scan example result output shown in Arduino IDE 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

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header in ESP32 Arduino IDE

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.
    pointing out ESP32 onboard boot button
  • When compiling is finished, you will see the Connecting…….  message in Arduino IDE, Now you have to release the BOOT button.
    ESP32 not going in bootloader mode and Arduino IDE displaying doted line pattern.
    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.

pointing out ESP32 onboard Enable button

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.

Subscribe to our weekly newsletter

Subscribe
Notify of
guest

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Robert
Robert
Guest
June 2, 2021 12:42 am

Nice tutorial – thanks TechTonions!

steanRDR
steanRDR
Guest
August 31, 2021 12:08 am

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.

posts info

Subscribe to our weekly newsletter

STAY IN TOUCH WITH US

Subscribe to our weekly newsletter