Language: EN

como-programar-esp32-con-el-ide-de-arduino

How to program ESP32 with Arduino IDE

In this post we will see how to set up the standard Arduino IDE to be able to program the ESP32 and the boards based on this popular SoC.

The process is quite simple, thanks to the work that Espressif has done in creating a Core compatible with the Arduino environment.

All the code is Open Source and is available in the project’s repo on GitHub - espressif/arduino-esp32: Arduino core for the ESP32

The process is only valid for the ESP32. If you are looking for the same tutorial for the ESP8266, you can find it in this post How to program ESP8266 with Arduino IDE

Install ESP32 on Arduino IDE

We will assume that you have the Arduino IDE installed and updated to the latest version. If not, logically, go to the official Arduino page and install it on your computer.

The ESP32 is not included in the Arduino IDE by default, but we can easily add it using the “Board Manager”.

Open the Arduino IDE and go to “File” > “Preferences”. In the “Additional Board Manager URLs” field, add the following URL:

https://espressif.github.io/arduino-esp32/package_esp32_index.json

If you want the development branch, instead add this URL.

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json

Then, go to “Tools” > “Board” > “Board Manager”.

programar-esp32-arduino

In the panel that appears, search for “ESP32” in the search bar, and click on “Install” in the package that appears.

programar-esp32-arduino-2

Once the installation is complete, you can choose the ESP32 models in the drop-down menu, and you will be ready to program the ESP32.

Testing ESP32 on Arduino IDE

Let’s test that everything works correctly. Connect the ESP32 to your computer using a USB cable.

In the Arduino IDE, select the board you are using. Go to “Tools” > “Board” and select “ESP32 Dev Module” as the board you are using.

Then select the COM port to which the ESP32 is connected in “Tools” > “Port”.

If you are not sure which port it is, you can disconnect the ESP32 and come back to this section to see which port disappears and reappears when you connect the device.

Hello world on ESP32

Now that you have your development environment set up, let’s test it with a simple ‘Blink’, in which we will only make the LED built into the ESP32 blink every second.

Copy this code in the Arduino IDE

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT); // Configure the built-in LED pin as an output
}

void loop()
{
  digitalWrite(LED_BUILTIN, HIGH); // Turn on the LED
  delay(1000); // Wait for a second
  digitalWrite(LED_BUILTIN, LOW); // Turn off the LED
  delay(1000); // Wait for a second
}

Press “Verify” to make sure there are no syntax errors. If everything is fine, press the “Upload” button to load the program onto the ESP32.

After a few seconds, you should see the built-in LED blinking at one-second intervals.

As we can see, it is very simple to program an ESP32 with the Arduino environment, thanks to the work that Espressif has done to create a compatible Core.

In the following tutorials, we will see how to use the different features of the ESP32, and its differences with a “normal” Arduino.