- ✓ Understanding the ESP8266 D1 Mini pinout
- ✓ Wiring relays to the D1 Mini
- ✓ Connecting DHT22, DS18B20, and NTC sensors
- ✓ Power supply requirements
- ✓ Common wiring mistakes and fixes
ESP8266 D1 Mini Overview
The ESP8266 D1 Mini is the most popular board for OceanRemote. It's small, inexpensive ($3-5), and powerful enough for most home automation projects.
- Microcontroller: ESP8266 (ESP-12E module)
- Operating Voltage: 3.3V (5V tolerant on some pins)
- Input Voltage: 5V (via USB) or 5-12V (via VIN pin)
- Digital I/O Pins: 16 (D0-D8, D10-D16)
- Analog Input: 1 (A0, 10-bit ADC, 0-3.3V)
- Flash Memory: 4MB
- RAM: 80 KB
Pinout Diagram
ESP8266 D1 Mini Pinout
┌─────────────────────────────────────┐
│ ┌───┐ │
│ │USB│ │
│ └───┘ │
│ │
│ D0 ────┐ ┌──── D8 │
│ D1 ────┤ ├──── D7 │
│ D2 ────┤ ├──── D6 │
│ D3 ────┤ ├──── D5 │
│ D4 ────┘ └──── D4 (LED) │
│ D5 ────┐ ┌──── 3.3V │
│ D6 ────┤ ├──── GND │
│ D7 ────┤ ├──── RST │
│ D8 ────┘ └──── A0 │
│ 3V3 GND RST TX RX │
└─────────────────────────────────────┘
Pin to GPIO Mapping
| Board Pin | GPIO | Function | OceanRemote Use |
|---|---|---|---|
| D0 | GPIO16 | Wake from deep sleep | Not used |
| D1 | GPIO5 | I2C SCL | Relay 1 |
| D2 | GPIO4 | I2C SDA / Sensor | Relay 2 + Sensor |
| D3 | GPIO0 | FLASH button | Relay 3 (⚠️ boot caution) |
| D4 | GPIO2 | Built-in LED | Relay 4 (⚠️ boot caution) |
| D5 | GPIO14 | SPI CLK | Relay 5 |
| D6 | GPIO12 | SPI MISO | Not used |
| D7 | GPIO13 | SPI MOSI | Not used |
| D8 | GPIO15 | SPI CS | Not used (⚠️ boot caution) |
| A0 | ADC | Analog input | NTC Thermistor |
- GPIO0 (D3) - Must be HIGH at boot. If pulled LOW, board enters flash mode.
- GPIO2 (D4) - Must be HIGH at boot. Built-in LED is active LOW.
- GPIO15 (D8) - Must be LOW at boot (connect to GND with 10k resistor if used).
- GPIO1, GPIO3 (TX/RX) - Used for Serial communication. Avoid using.
OceanRemote's default pin selection avoids boot issues by not using GPIO15 and using D3/D4 with care.
Wiring Relays to D1 Mini
OceanRemote uses 5 relays by default. Here's the recommended wiring:
| Relay | D1 Mini Pin | GPIO | Relay Module Connection |
|---|---|---|---|
| Relay 1 | D1 | GPIO5 | IN1 → D1, VCC → 5V, GND → GND |
| Relay 2 | D2 | GPIO4 | IN2 → D2, VCC → 5V, GND → GND |
| Relay 3 | D3 | GPIO0 | IN3 → D3, VCC → 5V, GND → GND |
| Relay 4 | D4 | GPIO2 | IN4 → D4, VCC → 5V, GND → GND |
| Relay 5 | D5 | GPIO14 | IN5 → D5, VCC → 5V, GND → GND |
Positive Logic (🔺) - Relay turns ON when pin is HIGH (3.3V). Default for most relay modules.
Negative Logic (🔻) - Relay turns ON when pin is LOW (0V). Use if your relay module is active LOW.
Most cheap relay modules use Negative Logic (LOW = ON). You can change this in the device configuration page.
Wiring Sensors
DHT22 Temperature & Humidity Sensor
| DHT22 Pin | Connect to D1 Mini |
|---|---|
| VCC (Pin 1) | 3.3V or 5V |
| DATA (Pin 2) | D2 (GPIO4) |
| GND (Pin 4) | GND |
DHT22 Wiring: ┌─────────┐ ┌──────────┐ │ D1 Mini │ │ DHT22 │ ├─────────┤ ├──────────┤ │ 3.3V ├────────────────────┤ VDD (1) │ │ D2 ├────────────────────┤ DATA (2) │ │ GND ├────────────────────┤ GND (4) │ └─────────┘ └──────────┘
DS18B20 Digital Temperature Sensor
| DS18B20 Pin | Connect to D1 Mini |
|---|---|
| VDD (Pin 3) | 3.3V |
| DATA (Pin 2) | D2 (GPIO4) |
| GND (Pin 1) | GND |
A 4.7kΩ resistor must be connected between DATA (D2) and 3.3V. Without it, readings will fail.
DS18B20 Wiring (with pull-up):
┌─────────┐ ┌──────────┐
│ D1 Mini │ │ DS18B20 │
├─────────┤ ├──────────┤
│ 3.3V ├────┬───────────────┤ VDD (3) │
│ │ │ │ │
│ D2 ├────┼───────────────┤ DATA (2) │
│ │ │ 4.7kΩ │ │
│ GND ├────┼────[====]─────┤ GND (1) │
│ │ │ │ │
└─────────┘ │ └──────────┘
└────────────────┘
NTC 10kΩ Thermistor (Analog)
The NTC thermistor requires a voltage divider circuit to work with the D1 Mini's ADC.
| Component | Connect to D1 Mini |
|---|---|
| NTC Thermistor | Between 3.3V and A0 |
| 10kΩ Resistor (R_series) | Between A0 and GND |
NTC Thermistor Voltage Divider:
3.3V
│
▼
┌───┐
│NTC│ ← 10kΩ NTC (resistance changes with temperature)
└───┘
│
├──────► A0 (ADC) ← Voltage measured here
│
┌───┐
│10k│ ← Fixed 10kΩ resistor (R_series)
│Ω │
└───┘
│
GND
Power Supply Requirements
USB Power (Recommended for Testing)
- Use a quality USB cable (not charge-only)
- 5V, 500mA minimum (1A recommended with relays)
- Phone charger works well
- Computer USB port works (but may be limited to 500mA)
External Power (For Permanent Installation)
- Connect 5-12V DC to the 5V pin (regulated power)
- Or use the VIN pin for unregulated 5-12V (board has voltage regulator)
- Relay modules should share the same power supply
- Total current: ~200mA (D1 Mini) + 70mA per active relay
Do NOT power relays from the D1 Mini's 3.3V pin! Relays need 5V. Use the 5V pin or an external power supply.
Complete Wiring Diagram
Here's a complete wiring diagram for a D1 Mini with 5 relays and a DHT22 sensor:
COMPLETE D1 MINI WIRING
┌─────────────────────────────────────────────────────┐
│ │
│ ┌─────────┐ ┌─────────────────────────────┐ │
│ │ D1 Mini │ │ 5-Channel Relay Module │ │
│ ├─────────┤ ├─────────────────────────────┤ │
│ │ USB │ │ IN1 │ D1 │ GPIO5 │ │
│ │ 5V ├──────┤ IN2 │ D2 │ GPIO4 │ │
│ │ GND ├──────┤ IN3 │ D3 │ GPIO0 │ │
│ │ 3.3V ├────┐ │ IN4 │ D4 │ GPIO2 │ │
│ │ D1 ├────┤ │ IN5 │ D5 │ GPIO14 │ │
│ │ D2 ├────┤ │ VCC │ 5V │ │ │
│ │ D3 ├────┤ │ GND │ GND│ │ │
│ │ D4 ├────┘ └─────────────────────────────┘ │
│ │ D5 ├──────┐ │
│ │ A0 │ │ ┌─────────────────────┐ │
│ └─────────┘ │ │ DHT22 Sensor │ │
│ │ ├─────────────────────┤ │
│ └────┤ DATA │ D2 │ │
│ │ VCC │ 3.3V │ │
│ │ GND │ GND │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────┘
Common Wiring Mistakes
Mistake 1: Relay Module Powered from 3.3V
- Problem: Relays don't click or work intermittently
- Fix: Connect relay VCC to 5V (not 3.3V)
Mistake 2: Missing Pull-up on DS18B20
- Problem: Sensor reads -127°C or fails
- Fix: Add 4.7kΩ resistor between DATA and 3.3V
Mistake 3: Wrong GPIO for Relay
- Problem: Board doesn't boot or relay behaves strangely
- Fix: Avoid GPIO0, GPIO2, GPIO15 for relays if possible (OceanRemote uses them but they're safe with proper logic)
Mistake 4: Floating Sensor Pins
- Problem: Random temperature readings
- Fix: Ensure all sensor pins are connected properly
Mistake 5: Power Supply Too Weak
- Problem: Device resets when turning on relays
- Fix: Use a stronger power supply (2A recommended for multiple relays)
Start with just the D1 Mini connected via USB. Get the firmware working first, then add relays one at a time, then sensors. This makes troubleshooting much easier.
Next Steps
Now that you understand the wiring, continue with:
- Tutorial 11: ESP8266 D1 Large Pinout and Wiring
- Tutorial 12: ESP32 Pinout and Wiring Guide
- Tutorial 13: Raspberry Pi Pico W Pinout and Wiring
- Return to Tutorial 02: Generate and flash your firmware!
Your D1 Mini is now properly wired. You can now generate firmware from the OceanRemote dashboard and flash your device!