Getting Started with ESP32

Getting Started with ESP32

Set up your ESP32, install drivers, and upload your first WiFi sketch.

What is the ESP32?

The ESP32 is a dual-core 32-bit microcontroller made by Espressif Systems. It is the go-to choice for IoT projects because it has built-in WiFi (802.11 b/g/n) and Bluetooth (Classic + BLE) at a very low cost.

Key specs (ESP32-WROOM-32 ߀” the most common module):

  • Dual-core Xtensa LX6 processor at up to 240 MHz
  • 520 KB SRAM
  • Up to 4 MB Flash (on the module)
  • Built-in WiFi 2.4 GHz + Bluetooth 4.2
  • 34 GPIO pins, multiple ADC/DAC channels, SPI, I2C, UART, PWM

Choosing a Development Board

The raw ESP32 module is just the chip on a small antenna board. Development boards add USB, a 3.3 V regulator, and breakout pins. Common choices:

  • ESP32 DevKitC ߀” Espressif official, all pins broken out
  • DOIT ESP32 DevKit V1 ߀” very common in hobbyist kits
  • NodeMCU-32S ߀” ESP32 version of the popular NodeMCU form factor

Installing the Arduino IDE for ESP32

  1. Download and install Arduino IDE 2 from arduino.cc
  2. Open File ߆’ Preferences and add this URL to "Additional boards manager URLs": https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  3. Open Tools ߆’ Board ߆’ Boards Manager, search for esp32, and install the package by Espressif Systems
  4. Select your board: Tools ߆’ Board ߆’ ESP32 Arduino ߆’ ESP32 Dev Module

Installing USB Drivers

Most ESP32 dev boards use the CP2102 or CH340 USB-to-serial chip:

  • CP2102: Download from Silicon Labs website
  • CH340: Download from WCH website (common on cheaper clones)

After installing, plug in your board ߀” a new COM port should appear in Device Manager.

Selecting the Right Settings

In the Arduino IDE, set:

  • Board: ESP32 Dev Module
  • Upload Speed: 921600
  • CPU Frequency: 240 MHz (or 80 MHz to save power)
  • Flash Size: 4MB (match your module)
  • Port: The COM port your board is on
void setup() {
  pinMode(2, OUTPUT);   // GPIO 2 is the built-in LED on most ESP32 boards
  Serial.begin(115200);
  Serial.println("ESP32 is ready!");
}

void loop() {
  digitalWrite(2, HIGH);
  delay(500);
  digitalWrite(2, LOW);
  delay(500);
}

Uploading a Sketch

  1. Click the Upload (߆’) button
  2. Watch the console ߀” when you see "Connecting........_____", hold the BOOT button on your board until the upload starts
  3. Some boards auto-reset; others require the BOOT button trick
  4. After upload, press the EN (enable/reset) button to run the sketch

Boot Modes

The ESP32 has two main boot modes controlled by the BOOT (GPIO0) pin:

  • GPIO0 HIGH at reset ߆’ normal run mode (your sketch runs)
  • GPIO0 LOW at reset ߆’ firmware download mode (for uploading)

Most dev boards handle this automatically, but if uploads fail, hold BOOT manually.

MicroPython Alternative

If you prefer Python, ESP32 supports MicroPython ߀” a lean Python 3 implementation for microcontrollers. Flash it with esptool.py and use Thonny IDE or uPyCraft to write code.

from machine import Pin
from time import sleep

led = Pin(2, Pin.OUT)

while True:
    led.value(1)
    sleep(0.5)
    led.value(0)
    sleep(0.5)