ESP32: Getting Started with Arduino IDE

ESP32 Tutorial: Getting Started with Arduino IDE

Abstract

Learn how to use the ESP32 Core with the Arduino IDE to develop Internet of Things (IoT) applications. This complete guide introduces the powerful Dual-Core ESP32 architecture, compares it to other platforms, details the available development boards (focusing on the DEVKIT v1 DOIT), and outlines the installation of the necessary toolchain for C++ programming. We conclude with the essential LED Blinking test to ensure your setup is functional.

1. Introduction

This article serves as the starting point for anyone who wishes to learn ESP32 programming with the Arduino framework. We will also briefly explore other development options such as the Espressif IDF, MicroPython, and AT Commands.

The ESP32 is the successor to the ESP8266, featuring a more powerful Dual-Core processor and integrated Wi-Fi / BLE (Bluetooth Low Energy) capability. It significantly raises the bar for embedded IoT application development. In this tutorial, you’ll be introduced to the ESP32 boards, their features, the available IDE options, and the first steps with the ESP32 Arduino Core development framework.

2. Prerequisites

  • To follow along with this series of tutorials, ensure you have the following hardware and software ready:

    • ESP32 Development Board: The ESP32 DEVKIT v1 DOIT board is recommended, though any ESP32 board will suffice (you may need to adjust GPIO pins).
    • Jumper Wires & Breadboard: Necessary for connecting external modules in future labs.
    • Arduino IDE or VS Code + PlatformIO installed on your computer.
    • ESP32 Arduino Core installed in your chosen IDE (toolchain setup is covered later).

3. ESP32 Features & Specs

The ESP32 represents a massive upgrade in computational power and connectivity compared to its predecessor, the ESP8266, and traditional 8-bit microcontrollers like the Arduino.

Microcontroller Comparison Table

Characteristics Arduino ESP8266 ESP32
MCU AVR Atmega328P Tensilica Xtensa LX106 Tensilica Xtensa LX6
Architecture 8-Bit 32-Bit 32-Bit
# Cores 1 Core 1 Core 2 Cores + ULP
F_cpu 20 MHz 80-160 MHz 240 MHz
FLASH 32 KB 4 MB 16 MB
RAM 2 KB 160 KB 520 KB

CPU Features & Peripherals

For a very low price, the ESP32 provides a rich set of on-chip features:

  • CPU: Xtensa® single-/dual-core 32-bit LX6 microprocessor(s) (up to 400 MIPS)
  • Memory: 520 KB SRAM, 448 KB ROM, and 16 KB SRAM in RTC.
  • Wireless: Integrated Wi-Fi and BLE (Smart Bluetooth).
  • GPIOs: 34 programmable GPIOs.
  • Analog: 12-bit SAR ADC (up to 18 channels) and 2x 8-bit DAC channels (GPIO25, GPIO26).
  • Timers: Two timer groups, including 2 × 64-bit timers and 1 × main watchdog in each group.
  • Special Features: 10x touch sensors, Hall effect sensor, and PWM up to 16 channels.
  • Interfaces: 4x SPI, 2x I²S, 2x I²C, 3x UART, and Two-Wire Automotive Interface (TWAI or CAN).

4. ESP32 Development Boards & Pinout

The ESP-WROOM-32 Module is the compact, shielded core component, which is then mounted onto various development boards. The most popular and recommended board for this series is the ESP32 DEVKIT v1 DOIT.

Recommended Board: ESP32 DEVKIT v1 DOIT

This board is recommended because it is the most affordable, accessible, and gives access to most of the available GPIO pins without any of them being “hard-wired” to extra components (like an LCD or SD card), which is common on other specialty ESP32 boards.

Key GPIO Pin Considerations

While most pins are flexible, some have specific limitations you must be aware of when designing projects:

  • Input-Only Pins: You cannot set these pins as outputs or use them for PWM. They also lack internal pull-ups/pull-downs.
    • GPIO 34, GPIO 35, GPIO 36, GPIO 39.
  • PWM Pins: The PWM LED controller supports up to 16 channels, which can be assigned to any GPIO pin that can be set as an output.
  • I²C Default Pins: When using the ESP32 Arduino Core, the default I2C pins are:
    • SDA (GPIO 21)
    • SCL (GPIO 22)
    • Note: These pins can be changed to any other pair using begin(SDA_pin, SCL_pin).

5. ESP32 Development Framework Options

There are various ways to develop firmware for the ESP32, depending on the level of abstraction and control required:

  1. ESP32 IDF (IoT Development Framework by ESPRESSIF): The native development method. It provides complete control, uses embedded C and an RTOS (Real-Time Operating System), and is best for low-level, high-performance applications, but has the steepest learning curve.
  2. ESP32 Arduino Core (This Series): The most common and beginner-friendly method. It allows using the Arduino IDE, writing standard Arduino C++ code, and leveraging the vast community-contributed libraries.
  3. ESP32 MicroPython: Allows the ESP32 to be programmed in Python after burning the MicroPython firmware. It has a low barrier to entry for Python programmers.
  4. ESP32 AT Commands: Flashes the ESP32 to act as a Wi-Fi/BLE slave device controlled by a main microcontroller (e.g., Arduino, STM32) over UART using simple AT commands.

6. Installing ESP32 Arduino Toolchain

To write Arduino code (C++) for the ESP32 core, you need a compiler, board manager, and loader.

Arduino IDE Vs PlatformIO + VS Code

Feature Arduino IDE PlatformIO + VS Code
Code Editor
Compiler / Flasher
Library / Board Manager
Auto Code-Completion
Debugger
Multi-Project

The Arduino IDE is highly recommended for beginners. However, advanced users may prefer VS Code with PlatformIO for features like auto-completion, multi-project management, and debugging.

7. Hands-On Lab: ESP32 LED Blinking

The first essential step is to upload a basic sketch to blink the onboard LED to confirm your toolchain and board are correctly set up. The onboard LED is commonly connected to GPIO pin 2.

Hardware Setup Tip

The ESP32 DevKit is often wider than a standard breadboard, leaving no connection points on one side. It is recommended to use two breadboards side-by-side or cut off the power rails on one side of a breadboard to create enough space for external components.

ESP32 Blinking LED Code Example

This code initializes GPIO 2 as an output and toggles it every 250 milliseconds.

				
					#define LED_BUILTIN 2 // On-Board LED Pin (Commonly GPIO2)

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(250);                      
  digitalWrite(LED_BUILTIN, LOW);  // turn the LED off by making the voltage LOW
  delay(250);                      
}

				
			

Flashing Steps

  1. Compile the sketch (Verify button).
  2. Select the correct board and COM port.
  3. Upload (arrow icon).
  4. If the upload fails with a “Failed to connect” error: Hold down the BOOT button on the board, then click upload. Release the BOOT button when the upload log shows Writing at 0x00001000….
  5. After a successful upload, press the EN (Reset) button to run the new firmware. (Newer ESP32 Arduino Cores may perform this reset automatically).

8. Lab Recap

You’ve learned the foundational steps for ESP32 Arduino programming:

  • The ESP32’s superior hardware features (Dual-Core, Wi-Fi/BLE, rich peripherals).
  • The preferred ESP32 DEVKIT v1 DOIT board and its pinout limitations (e.g., input-only pins).
  • The role of the ESP32 Arduino Core as the most accessible development framework.
  • The difference between the beginner-friendly Arduino IDE and the feature-rich PlatformIO.
  • How to write and successfully flash the basic LED Blinking sketch to your board.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top