- β 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!