OC
OceanRemote
Low-code IoT platform
← Back to Course

Installing ESP32 in Arduino IDE + First Code

🛠️ Installing ESP32 in Arduino IDE - Complete Setup Guide

Follow this step-by-step guide to set up your ESP32 development environment. Even if you're a complete beginner, these instructions will get you running in 15 minutes.

📋 Step 1: Install Arduino IDE (if not already installed)

📋 Step 2: Add ESP32 Board Manager URL

  1. Open Arduino IDE
  2. Go to File → Preferences (or Arduino IDE → Settings on Mac)
  3. Find "Additional Boards Manager URLs" field
  4. Add this URL (if multiple, separate with commas):
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  5. Click OK

📋 Step 3: Install ESP32 Board Package

  1. Go to Tools → Board → Boards Manager
  2. Type "ESP32" in the search box
  3. Find "esp32 by Espressif Systems"
  4. Click Install (version 2.0.14 or newer)
  5. Wait 2-5 minutes for download and installation
  6. Click Close when finished
💡 Slow Internet? The installation file is about 500MB. If your connection is slow, consider downloading directly from GitHub or using a download manager.

📋 Step 4: Select Your ESP32 Board

  1. Go to Tools → Board → ESP32 Arduino
  2. Select your board type:
    • For most development boards: "ESP32 Dev Module"
    • For NodeMCU-32S: "NodeMCU-32S"
    • For Wemos D1 R32: "Wemos D1 R32"
  3. Select the correct Port (Tools → Port)
    • Windows: Shows as COM3, COM4, etc.
    • Mac: Shows as /dev/cu.usbserial-xxx
    • Linux: Shows as /dev/ttyUSB0 or /dev/ttyACM0
⚠️ No Port Found? You need to install USB drivers:
  • CP2102 driver: Common on NodeMCU boards
  • CH340 driver: Common on cheap ESP32 boards
  • Download from manufacturer website or Silicon Labs

📋 Step 5: Test with Blink Sketch

Copy and paste this code into Arduino IDE:

/*
 * ESP32 Blink Sketch
 * Most ESP32 boards have built-in LED on GPIO2
 * Test your setup with this simple program
 */

void setup() {
    pinMode(2, OUTPUT);      // Set GPIO2 as output
    Serial.begin(115200);    // Start serial communication
    Serial.println("");
    Serial.println("ESP32 Started Successfully!");
    Serial.println("LED should start blinking...");
}

void loop() {
    digitalWrite(2, HIGH);   // Turn LED ON
    Serial.println("LED ON");
    delay(1000);              // Wait 1 second
    
    digitalWrite(2, LOW);    // Turn LED OFF
    Serial.println("LED OFF");
    delay(1000);              // Wait 1 second
}
    

📋 Step 6: Upload and Test

  1. Connect your ESP32 via USB cable
  2. Verify Board and Port are selected correctly
  3. Click the Upload button (→ right arrow icon)
  4. Watch the console for progress messages
  5. When you see "Connecting..." you may need to press and hold the BOOT button on some boards
  6. Wait for "Done uploading" message
  7. Open Serial Monitor (Tools → Serial Monitor) at 115200 baud
✅ SUCCESS! You should see the built-in LED blinking and the Serial Monitor showing "LED ON/OFF" messages. Congratulations! Your ESP32 is now ready for IoT projects!

🐧 Linux Users Only - USB Permission Fix:

# Add your user to dialout group
sudo usermod -a -G dialout $USER

# Log out and back in, OR run:
newgrp dialout

# Then reconnect USB and restart Arduino IDE
    

🔧 Troubleshooting Common Issues:

  • "Failed to connect to ESP32" → Press and hold BOOT button while uploading
  • "Timed out waiting for packet header" → Check your USB cable (use data cable, not charging-only)
  • "Board not detected" → Install USB drivers (CP2102 or CH340)
  • Compilation errors → Make sure ESP32 board package is properly installed
💡 Key Takeaways:
  • Apply these concepts directly to your farm or project.
  • Take notes on important details for the quiz.
  • Use the button below to track your progress.