What You'll Need
Before diving in, make sure you have the following:
- An ESP32 development board (any common DevKit variant will work)
- A USB Micro-B or USB-C cable (check your board)
- A computer running Windows, macOS, or Linux
- Arduino IDE 2.x (download free from arduino.cc)
- A Wi-Fi network name and password (for the connectivity demo)
Step 1: Install the Arduino IDE
Head to arduino.cc/en/software and download the Arduino IDE 2.x for your operating system. Install it using the default settings. This version includes an improved board manager and library manager compared to the older 1.x branch.
Step 2: Add the ESP32 Board Package
By default, the Arduino IDE only knows about official Arduino boards. To program an ESP32, you need to add Espressif's board support package:
- Open Arduino IDE and go to File → Preferences.
- In the "Additional boards manager URLs" field, paste the following URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Click OK.
- Go to Tools → Board → Boards Manager.
- Search for esp32 and install the package by Espressif Systems.
Installation may take a few minutes depending on your internet speed.
Step 3: Select Your Board and Port
- Plug your ESP32 into your computer via USB.
- Go to Tools → Board → ESP32 Arduino and select your specific board. For most generic DevKit boards, choose ESP32 Dev Module.
- Go to Tools → Port and select the COM port (Windows) or /dev/tty.usbserial-xxx (macOS/Linux) that appeared after plugging in your board.
Tip: If no port appears, you may need to install the CP2102 or CH340 USB-to-serial driver for your specific board's USB chip.
Step 4: Upload Your First Sketch — Blink
Let's confirm everything is working with the classic Blink sketch:
- Go to File → Examples → 01.Basics → Blink.
- Note: The ESP32's onboard LED is typically on pin 2. Change
LED_BUILTINto2if your board doesn't have a defined LED pin. - Click the Upload button (right-pointing arrow).
- Wait for "Done uploading" to appear in the console.
Your ESP32's onboard LED should now be blinking once per second. 🎉
Step 5: Connect to Wi-Fi
Now let's use what makes the ESP32 special. Open a new sketch and paste the following:
#include <WiFi.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {}
Replace YOUR_WIFI_NAME and YOUR_WIFI_PASSWORD with your credentials. Upload the sketch, then open the Serial Monitor (Tools → Serial Monitor) at 115200 baud. You should see your ESP32 connect and display its local IP address.
Troubleshooting Common Issues
- Port not showing up: Install the correct USB driver (CP2102 or CH340) and replug the board.
- Upload fails with "A fatal error occurred": Hold the BOOT button on your ESP32 while uploading begins, then release it.
- Wi-Fi won't connect: Double-check your credentials. ESP32 only supports 2.4 GHz networks, not 5 GHz.
- Wrong baud rate: Always set the Serial Monitor to match your
Serial.begin()rate.
Next Steps
Now that your ESP32 is up and running, explore these directions:
- Connect a DHT22 temperature/humidity sensor and serve readings over HTTP
- Use the ESP32's Bluetooth to communicate with a smartphone app
- Try deep sleep modes to build battery-powered projects
- Experiment with the SPIFFS file system to store data on-device