- ✓ Understanding ESP32 pinout and capabilities
- ✓ Differences between ESP32 and ESP8266
- ✓ Wiring relays to ESP32 (safe GPIO selection)
- ✓ Connecting DHT22, DS18B20, and NTC sensors
- ✓ ESP32 power requirements and best practices
ESP32 Overview
The ESP32 is the powerful successor to the ESP8266. It adds Bluetooth, dual-core processing, more GPIO pins, and better analog-to-digital converters. It's the ideal choice for advanced IoT projects that need more processing power or Bluetooth connectivity.
| Feature | ESP8266 | ESP32 |
|---|---|---|
| Processor | Single-core 80/160 MHz | Dual-core 240 MHz |
| RAM | 80 KB | 520 KB |
| Flash | 4 MB | 4-16 MB |
| GPIO Pins | 16 | 34+ |
| ADC Channels | 1 (10-bit) | 18 (12-bit) |
| Bluetooth | No | Yes (BLE + Classic) |
| Touch Sensors | No | Yes (10) |
| Price | $3-5 | $8-12 |
ESP32 Board Variants
OceanRemote works with most ESP32 development boards:
- ESP32 Dev Module (30-pin) - Most common. Fits breadboards.
- ESP32 Dev Module (36-pin) - More GPIO pins exposed.
- ESP32-WROOM-32 - Standard module with 4MB flash.
- ESP32-WROVER - Includes 4MB PSRAM for larger applications.
- NodeMCU-32S - NodeMCU-style ESP32 board.
- LOLIN D32 - Compact ESP32 board.
For most users, get a standard ESP32 Dev Module (30-pin). It's widely available, well-documented, and fully compatible with OceanRemote.
ESP32 Pinout Diagram (30-pin version)
ESP32 Dev Module (30-pin) Pinout
┌─────────────────────────────────────────────────────────────┐
│ │
│ EN ────┐ ┌──── 3.3V USB ┌───┐ │
│ VP ────┤ ├──── EN │ │ │
│ VN ────┤ ├──── VP │USB│ │
│ GPIO34───┤ ├──── VN │ │ │
│ GPIO35───┤ ├──── GPIO34 └───┘ │
│ GPIO32───┤ ├──── GPIO35 │
│ GPIO33───┤ ├──── GPIO32 │
│ GPIO25───┤ ├──── GPIO33 │
│ GPIO26───┤ ├──── GPIO25 │
│ GPIO27───┤ ├──── GPIO26 │
│ GPIO14───┤ ├──── GPIO27 │
│ GPIO12───┤ ├──── GND │
│ GND ────┘ └──── GPIO13 │
│ GPIO13───┐ ┌──── GPIO12 │
│ GPIO9 ────┤ ├──── GPIO14 │
│ GPIO10────┤ ├──── GPIO27 │
│ GPIO11────┤ ├──── GPIO26 │
│ GPIO6 ────┤ ├──── GPIO25 │
│ GPIO7 ────┤ ├──── GPIO33 │
│ GPIO8 ────┘ └──── GPIO32 │
│ │
│ GPIO5 ────┐ ┌──── GPIO18 │
│ GPIO17────┤ ├──── GPIO19 │
│ GPIO16────┤ ├──── GPIO21 │
│ GPIO4 ────┤ ├──── GPIO22 │
│ GPIO0 ────┤ ├──── GPIO23 │
│ GPIO2 ────┘ └──── GPIO15 │
└─────────────────────────────────────────────────────────────┘
Important ESP32 Pin Notes
| Pins | Status | Notes |
|---|---|---|
| GPIO0, GPIO2, GPIO5, GPIO12, GPIO15 | ⚠️ Boot pins | Have pull-up/down at boot, use with caution |
| GPIO34, 35, 36, 39 | 📥 Input-only | Cannot be used as outputs (relays won't work) |
| GPIO6-11 | 🚫 Avoid | Connected to internal flash, do not use |
| GPIO16, 17 | ⚠️ Used for PSRAM | Avoid if PSRAM enabled, safe otherwise |
| GPIO1, 3 (TX/RX) | 🔧 Serial | Used for USB communication, avoid using |
- GPIO0 - LOW at boot = flashing mode. Keep HIGH or floating.
- GPIO2 - Affects boot if pulled LOW. Onboard LED may be connected.
- GPIO12 - Affects flash voltage (3.3V vs 1.8V). Keep floating or high.
- GPIO15 - Affects boot if pulled HIGH. Keep LOW or floating.
- Input-only pins (34-39) - Cannot output signals. Do NOT connect relays here!
OceanRemote Default Pin Assignments for ESP32
OceanRemote firmware uses these safe GPIO pins for relays:
| Relay | GPIO | Safe for Boot? | Notes |
|---|---|---|---|
| Relay 1 | GPIO2 | ⚠️ Caution | Must be HIGH at boot (relay OFF) |
| Relay 2 | GPIO4 | ✅ Safe | No boot constraints |
| Relay 3 | GPIO5 | ⚠️ Caution | Has pull-up at boot, but safe if relay OFF |
| Relay 4 | GPIO12 | ⚠️ Caution | Affects flash voltage if pulled LOW |
| Relay 5 | GPIO13 | ✅ Safe | No boot constraints |
| Sensor (DHT/DS18B20) | GPIO15 | ⚠️ Caution | Has pull-down at boot, ensure sensor doesn't pull HIGH |
| NTC Thermistor | GPIO34 | ✅ Safe | Input-only pin (perfect for analog sensor) |
If you want to change the pin assignments, these are the safest GPIOs: GPIO4, GPIO13, GPIO14, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33. Avoid GPIO0, GPIO2, GPIO5, GPIO12, GPIO15 for relays.
Wiring Relays to ESP32
Here's how to connect 5 relay channels to your ESP32:
| Relay | ESP32 GPIO | Relay Module Connection |
|---|---|---|
| Relay 1 | GPIO2 | IN1 → GPIO2, VCC → 5V, GND → GND |
| Relay 2 | GPIO4 | IN2 → GPIO4, VCC → 5V, GND → GND |
| Relay 3 | GPIO5 | IN3 → GPIO5, VCC → 5V, GND → GND |
| Relay 4 | GPIO12 | IN4 → GPIO12, VCC → 5V, GND → GND |
| Relay 5 | GPIO13 | IN5 → GPIO13, VCC → 5V, GND → GND |
Wiring Sensors to ESP32
DHT22 Temperature & Humidity Sensor
| DHT22 Pin | Connect to ESP32 |
|---|---|
| VCC | 3.3V or 5V |
| DATA | GPIO15 |
| GND | GND |
DS18B20 Digital Temperature Sensor
| DS18B20 Pin | Connect to ESP32 |
|---|---|
| VDD | 3.3V |
| DATA | GPIO15 + 4.7kΩ pull-up to 3.3V |
| GND | GND |
A 4.7kΩ resistor must be connected between DATA (GPIO15) and 3.3V. Without it, readings will fail.
NTC 10kΩ Thermistor (Analog)
NTC Thermistor Voltage Divider (ESP32):
3.3V
│
▼
┌───┐
│NTC│ ← 10kΩ NTC (resistance changes with temperature)
└───┘
│
├──────► GPIO34 (ADC1_CH6) ← Voltage measured here (12-bit ADC)
│
┌───┐
│10k│ ← Fixed 10kΩ resistor (R_series)
│Ω │
└───┘
│
GND
The ESP32 has 12-bit ADC (0-4095) which is much more precise than ESP8266's 10-bit (0-1023). Use GPIO34, GPIO35, GPIO36, or GPIO39 for analog inputs. GPIO36 and GPIO39 are recommended for better linearity.
Complete Wiring Diagram
COMPLETE ESP32 WIRING (30-pin)
┌─────────────────────────────────────────────────────────────┐
│ │
│ ┌─────────┐ ┌─────────────────────────────────────┐ │
│ │ ESP32 │ │ 5-Channel Relay Module │ │
│ ├─────────┤ ├─────────────────────────────────────┤ │
│ │ USB │ │ IN1 │ GPIO2 │ │
│ │ 5V ├──────┤ IN2 │ GPIO4 │ │
│ │ GND ├──────┤ IN3 │ GPIO5 │ │
│ │ 3.3V ├───┐ │ IN4 │ GPIO12 │ │
│ │ GPIO2 ├───┤ │ IN5 │ GPIO13 │ │
│ │ GPIO4 ├───┤ │ VCC │ 5V │ │
│ │ GPIO5 ├───┤ │ GND │ GND │ │
│ │ GPIO12├───┤ └─────────────────────────────────────┘ │
│ │ GPIO13├───┘ │
│ │ GPIO15├─────┐ ┌─────────────────────────────┐ │
│ │ GPIO34├─────┤ │ DHT22 Sensor │ │
│ └─────────┘ │ ├─────────────────────────────┤ │
│ └────┤ DATA │ GPIO15 │ │
│ │ VCC │ 3.3V │ │
│ │ GND │ GND │ │
│ └─────────────────────────────┘ │
│ │
│ ┌─────────────────────────────┐ │
│ │ NTC Thermistor │ │
│ │ (Between 3.3V and GPIO34) │ │
│ │ + 10kΩ to GND │ │
│ └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
ESP32 Power Requirements
USB Power (Recommended for Testing)
- Use a quality USB cable (not charge-only)
- 5V, 500mA minimum (2A recommended with relays)
- Phone charger works well
- Computer USB port works (may be limited to 500mA)
External Power (For Permanent Installation)
- Connect 5-12V DC to the VIN pin (has voltage regulator)
- Or connect regulated 3.3V directly to 3.3V pin (advanced users)
- ESP32 consumes ~240mA with WiFi active
- Each active relay adds ~70mA
- Use 5V 2A power supply for 5 relays + ESP32
Do NOT power relays from the ESP32's 3.3V pin! Relays need 5V. Use the 5V pin (from USB) or an external 5V power supply.
The ESP32's voltage regulator can provide up to 600mA. If you're powering many relays, use an external 5V supply.
ESP32 Special Features
- Dual-Core Processing - OceanRemote runs WiFi on Core 0 and your application on Core 1.
- Bluetooth - Future OceanRemote versions may support Bluetooth control.
- Touch Sensors - GPIO0, 2, 4, 12, 13, 14, 15, 27, 32, 33 have touch sensing.
- Hall Effect Sensor - Built-in magnetic field sensor on most ESP32 boards.
- Deep Sleep - Can go into deep sleep (μA range) and wake on timer or external trigger.
- Choose ESP32 for: Bluetooth projects, better ADC accuracy, more GPIO pins, dual-core performance
- Choose ESP8266 for: Simpler projects, lower cost, smaller physical size
- Choose Pico W for: Python programming, 12-bit ADC, official Raspberry Pi ecosystem
Troubleshooting ESP32
Device Won't Boot / Continuously Resets
- Check GPIO0, GPIO2, GPIO5, GPIO12, GPIO15 - ensure they're not in wrong state at boot
- Disconnect all sensors and relays, test with bare board first
- Try a different USB cable (many are charge-only)
- Check serial monitor for boot loop error messages
Upload Fails (Connecting... timeout)
- Hold the BOOT button while uploading, release when you see "Connecting..."
- Lower upload speed to 115200
- Check port selection
- Press EN/RST button after upload attempt
WiFi Connection Issues
- Check antenna connection (some boards have external antenna)
- Move ESP32 closer to router
- Check for 2.4GHz interference (microwave, cordless phones)
Relays Not Responding
- Verify relay VCC connected to 5V (not 3.3V)
- Check relay logic (Positive vs Negative) in dashboard settings
- Test GPIO pin with a simple blink sketch before connecting relay
- Check that you're not using input-only pins (34-39) for relays
| Pin | Normal Boot | Flash Mode |
|---|---|---|
| GPIO0 | HIGH or floating | LOW |
| GPIO2 | HIGH or floating | Don't care |
| GPIO5 | HIGH or floating | Don't care |
| GPIO12 | HIGH or floating (3.3V flash) | LOW (1.8V flash) |
| GPIO15 | LOW | HIGH |
Next Steps
Now that you understand ESP32 wiring, continue with:
- Tutorial 13: Raspberry Pi Pico W Pinout and Wiring
- Tutorial 16-20: Working with sensors (DHT22, DS18B20, NTC)
- Return to Tutorial 02: Generate and flash your firmware!
Your ESP32 is now properly wired. You can now generate firmware from the OceanRemote dashboard and flash your device!