OC
OceanRemote
Low-code IoT platform
← Back to Course

ESP32 Pinout Complete Guide

ESP32 Pinout Complete Guide

🔌 ESP32 Pinout Complete Guide - Safe Wiring for Your Farm Sensors

🔌 What You'll Learn:

  • 📊 Know which pins are safe for sensors (and which to avoid)
  • ⚡ Understand power pins: 3.3V (output), 5V/VIN (input)
  • ⚠️ Learn the critical 3.3V logic rule (NEVER connect 5V!)
  • 🔧 Complete wiring examples for common sensors
⚠️ CRITICAL WARNING - READ FIRST:
  • ESP32 pins are 3.3V logic ONLY - NEVER connect 5V sensors directly!
  • Using 5V will destroy your ESP32 permanently.
  • Use a logic level converter ($2-3) for 5V sensors.
  • Some boards have a 5V pin for INPUT only (never output 5V).

✅ Safe & Recommended Pins for Sensors

  • GPIO4, GPIO5: Best for relays, LEDs, buttons - safe digital I/O
  • GPIO16, GPIO17: DHT22, DS18B20 sensors - reliable digital I/O
  • GPIO21, GPIO22: I2C sensors (OLED, BMP280, BME280) - SDA(21), SCL(22)
  • GPIO18, GPIO19: SPI devices (LoRa, SD card) - SCLK(18), MISO(19)
  • GPIO23, GPIO25, GPIO26, GPIO27: General purpose I/O - safe for most uses
  • GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39: Analog sensors (soil moisture, light, pH) - ADC input pins

⚠️ Pins to AVOID

  • GPIO0: Boot mode - must be HIGH at startup (pulling LOW during boot = flashing mode)
  • GPIO2: Built-in LED - can cause boot issues if pulled LOW
  • GPIO6-11: Connected to internal flash - WILL CRASH your ESP32
  • GPIO12, GPIO13, GPIO14, GPIO15: JTAG pins - unreliable for general use
  • GPIO1, GPIO3: Serial TX/RX - used for USB communication
💡 Best Pins for Beginners:
  • Digital sensors (DHT22, relay): GPIO4, GPIO5, GPIO16, GPIO17
  • Analog sensors (soil moisture): GPIO32, GPIO33, GPIO34, GPIO35
  • I2C sensors (BMP280, OLED): GPIO21 (SDA), GPIO22 (SCL)

🔋 Power Pins Reference

  • 3.3V (multiple pins): Output for sensors (max 500mA total)
  • 5V / VIN: Input from USB or external 5V battery (powers the ESP32)
  • GND (multiple pins): Always connect ground - use multiple pins for stability
  • EN: Reset pin (pull LOW to reset, HIGH to run - leave floating normally)
  • VBAT (some boards): Direct battery input (3.6-4.2V for Li-ion)
⚠️ 5V Pin Warning:

The 5V pin is for INPUT only (powering the ESP32 from external 5V). It cannot output 5V to sensors. Most sensors need 3.3V from the 3.3V pin.

🔌 Complete Wiring Examples

1. Soil Moisture Sensor (Analog)

ESP32              → Soil Moisture Sensor
3.3V               → VCC
GND                → GND
GPIO34 (ADC)       → AO (Analog Output)
    

2. DHT22 Temperature/Humidity

ESP32              → DHT22
3.3V               → VCC (pin 1)
GND                → GND (pin 4)
GPIO16             → DATA (pin 2)
[10kΩ resistor between DATA and 3.3V - REQUIRED!]
    

3. Relay Module (Water Pump Control)

ESP32              → Relay Module
3.3V               → VCC
GND                → GND
GPIO5              → IN (control pin - active LOW)
    

4. I2C Sensor (BME280)

ESP32              → BME280
3.3V               → VCC
GND                → GND
GPIO21             → SDA
GPIO22             → SCL
    
💡 Pro Tip:

Always use a logic level converter ($2-3) when connecting 5V sensors. Alternatively, choose 3.3V compatible sensors when possible. Many agricultural sensors (capacitive soil moisture, DHT22, DS18B20) work at 3.3V.

🎯 Quick Reference - Pin Selection Guide:
  • Analog sensors: GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39
  • Digital sensors (DHT22, DS18B20): GPIO4, GPIO5, GPIO16, GPIO17
  • I2C sensors: GPIO21 (SDA), GPIO22 (SCL)
  • Relays / LEDs: GPIO4, GPIO5, GPIO23, GPIO25, GPIO26, GPIO27
  • Avoid: GPIO0, GPIO2, GPIO6-11, GPIO12-15
💡 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.