Skip to content

uPesy only delivers currently in France.

Contents Menu Expand Light mode Dark mode Auto light/dark mode

Install ESP32 in Arduino IDE easily

This tutorial will guide you in installing the tools necessary for programming the ESP32 through the Arduino IDE. You will then write your first program for the ESP32 via Arduino code.

../../_images/arduino_ide_pres.png

Before installing the ESP32 specific tools, you must first install the Arduino IDE software.

Note

If you already have Arduino IDE installed, check that it is a recent version (> 1.8)

Arduino IDE Installation

To install Arduino IDE on Windows , follow these steps:

../../_images/arduinoIDE0.PNG
  • In the next window, leave the default installation location.

../../_images/arduinoIDE1.PNG
  • Then allow the installation of the drivers:

../../_images/arduinoIDE2.PNG ../../_images/arduinoIDE3.PNG ../../_images/arduinoIDE4.PNG
  • The installation is now complete. A window of this type should appear:

../../_images/arduinoIDE5.PNG

Warning

A Windows Firewall window may ask you to approve the application to access the Internet. Accept the authorization to download libraries, updates, maps and tools for the ESP32 .

You can currently program only Arduino boards. To program ESP32 boards, you need to download other tools.

Add ESP32 support in the Arduino IDE.

To install the necessary tools, you should:

  • Go to File> Preferences

../../_images/arduinoIDE6.PNG
  • Click on Additional Boards Manager URL and add the URL:

https://dl.espressif.com/dl/package_esp32_index.json
../../_images/arduinoIDE7.PNG
  • Then go to the Boards manager: Tools > Board > Boards Manager

../../_images/arduinoIDE8.PNG
  • Scroll down until you find esp32, and click on install . Once the download and installation are completed, the tools are ready to be used.

../../_images/arduinoIDE9.PNG
  • ESP32 boards have been added in the board manager:

../../_images/arduinoIDE10.PNG
  • If you have a uPesy ESP32 Wroom DevKit board or other ESP32 board, you can choose “ESP32 Dev Module” or ” DOIT ESP32 DEVKIT V1” board. Moreover, to use the additional RAM of the uPesy ESP32 Wrover Devkit board, you must choose a compatible board, such as the “ESP32 Wrover Module” board.

../../_images/arduinoIDE11.jpg
  • The installation is now complete. You can now program your ESP32 board like a regular Arduino board. Examples are available for Wi-Fi and Bluetooth in File> Examples .

Upload your first sketch on ESP32

Now that all the tools are installed, we will create our first program and send it to the ESP32 board. But before making the first program, you must make sure that you can communicate with the ESP32 board.

Board detection

Note

ESP32 boards should be automatically detected: there is no need to install additional drivers.

Connect your ESP32 board to your computer via USB (with a USB Micro-B cable). On Windows, when you plug in the board, you should hear the same noise as a USB key, but it’s normal to not see the ESP32 board in the file explorer.

Warning

Make sure to take a USB cable that transmits the data and not a USB cable that can only load a battery from a device.

Once the board is plugged in, you should see a COM number on Arduino IDE.

../../_images/arduinoIDE11.png

To receive messages from the board, you must open the serial monitor.

The setting to be changed in the serial monitor is the data transmission speed . The serial port standard speed with an Arduino board is 9600 bauds (bytes/s). But with the ESP32, the commonly used rate is 115200 bauds . The reason is that the ESP32 sends messages at this speed when booting or in case of hardware errors.

Hint

The serial port speed can be different from 115200 baud, but in this case, the messages during the ESP32 boot will not be visible and will appear with incomprehensible characters.

Once the rate is changed, you can communicate with the ESP32.

All uPesy boards come already flashed with a program that blinks the blue LED present on the board and scan nearby Wi-Fi Access Point. With the ESP32 WROOM DevKit board, we then obtain in the serial monitor :

../../_images/arduinoIDE12.jpg

Warning

On Linux-based OS , all necessary Python packages may not be installed by default (for example, on Ubuntu 20.04). If you have this error: exec: “python”: executable file not found in $PATH , install the package python-is-python3 to make a symbolic link between python and python3 .

sudo apt install python-is-python3

Then, if you have the error ModuleNotFoundError: No module named ‘serial’ , you have to install the pyserial packet with pip3

sudo apt install python3-pip
pip3 install pyserial

Finally, if you can not upload code on the ESP32 with an error of this type: avrdude: ser_open(): can’t open device “/dev/ttyUSB0”: Permission denied , you have to add reading/writing permissions with the chmod command:

sudo chmod a+rw /dev/ttyUSB0

Your first program

Here is a straightforward example that blinks the built-in blue led located on the GPIO2 pin of the ESP32 Wroom DevKit board.

void setup() {
  Serial.begin(115200);
  Serial.println("Mon premier programme");

  pinMode(2,OUTPUT);

}

void loop() {
  digitalWrite(2, HIGH); //On allume la led bleue
  delay(500); //On attend pendant 500 ms
  digitalWrite(2, LOW); //On eteinds la led bleue
  delay(500); //On attend pendant 500 ms
}

Tip

The code can be copied directly to the clipboard by clicking on the right icon of the code section.

Once you have typed or copied the example code and saved the code, you will have to compile the program.

The first compilation is quite long because all the source files for the ESP32, even those not directly used by the program, are compiled. Fortunately, only the modified files will be compiled for the subsequent compilations.

To do this, simply press the “Verify” button. Then click on the arrow next to upload the program to the ESP32.

Tip

To compile and send immediately after the program, click directly on the arrow.

Here are the lines in the terminal that correspond to uploading the program to an ESP32:

esptool.py v2.6
 Serial port COM8
 Connecting .....
 Chip is ESP32D0WDQ5 (revision 1)
 Features: Wi-Fi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
 MAC: 4c: 11: ae: 68: 09: 44
 Uploading stub ...
 Running stub ...
 Stub running ...
 Changing baud rate to 921600
 Changed.
 Configuring flash size ...
 Auto-detected Flash size: 8MB
 Compressed 8192 bytes to 47 ...

 Writing at 0x0000e000 ... (100%)
 Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 4096.0 kbit / s) ...
 Hash of data verified.
 Flash params set to 0x023f
 Compressed 17392 bytes to 11185 ...

 Writing at 0x00001000 ... (100%)
 Wrote 17392 bytes (11185 compressed) at 0x00001000 in 0.2 seconds (effective 804.3 kbit / s) ...
 Hash of data verified.
 Compressed 261024 bytes to 123037 ...

 Writing at 0x00010000 ... (12%)
 Writing at 0x00014000 ... (25%)
 Writing at 0x00018000 ... (37%)
 Writing at 0x0001c000 ... (50%)
 Writing at 0x00020000 ... (62%)
 Writing at 0x00024000 ... (75%)
 Writing at 0x00028000 ... (87%)
 Writing at 0x0002c000 ... (100%)
 Wrote 261024 bytes (123037 compressed) at 0x00010000 in 2.4 seconds (effective 866.8 kbit / s) ...
 Hash of data verified.
 Compressed 3072 bytes to 128 ...

 Writing at 0x00008000 ... (100%)
 Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 4096.0 kbit / s) ...
 Hash of data verified.

 Leaving ...
 Hard resetting via RTS pin ...

Once the upload is finished, you should see the blue LED blinking faster than before (on uPesy boards).

Note

Once the upload is complete, the ESP32 directly executes the program. Therefore, it is normal not to see the message “My first program” when you go to the serial monitor. Unlike the Arduino, the ESP32 does not restart when clicking on the serial monitor button. (In Arduino IDE but not on PlatformIO)

So to see the message, you must either :
  • Add a delay of a few seconds with delay() before executing the code.

  • Have the serial monitor open before the upload is complete

  • Press the “EN” button on the ESP32 board to do a manual restart.

We use cookies to make your visit to the site as pleasant as possible. Privacy Policy