Component guide · Beginner · 3 min read
D1 Mini (ESP8266)

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The D1 Mini is a small ESP8266 Wi-Fi board with USB, a 3.3 V regulator and 11 usable pins in a 34 x 26 mm footprint. Program it from the Arduino IDE with the ESP8266 core and the 'LOLIN(WEMOS) D1 mini' board. Logic is 3.3 V, A0 reads 0 to 3.2 V through an on-board divider, and stacking shields add sensors, relays and displays.
Key specs at a glance
- Chip
- ESP8266EX, 80/160 MHz, 4 MB flash
- Wi-Fi
- 2.4 GHz 802.11 b/g/n
- Pins
- 11 digital I/O, 1 analog input (A0, 0 to 3.2 V)
- Logic
- 3.3 V
- Power
- USB 5 V, or 5 V pin, or 3.3 V pin
- USB
- CH340 serial chip (driver may be needed on Windows)
What the D1 Mini (ESP8266) is
The D1 Mini puts the ESP8266 on a small board with everything needed to program it from USB. It is a favourite for compact Wi-Fi sensors, smart switches running Tasmota or ESPHome, and battery nodes with deep sleep.
Pin labels (D0 to D8) differ from GPIO numbers, which is the most common source of confusion. Use the D labels in Arduino code or look up the GPIO number.
D1 Mini (ESP8266) pinout
The pins on the D1 Mini (ESP8266) and what each one does.
| Pin | Function |
|---|---|
| D0 (GPIO16) | Wake from deep sleep (connect to RST); no PWM or interrupts |
| D1 (GPIO5) | I2C SCL |
| D2 (GPIO4) | I2C SDA |
| D3 (GPIO0) | Flash button, must be HIGH at boot |
| D4 (GPIO2) | On-board LED (active LOW), must be HIGH at boot |
| D5 to D7 (GPIO14, 12, 13) | SPI SCK, MISO, MOSI |
| D8 (GPIO15) | SPI CS, must be LOW at boot |
| A0 | Analog input, 0 to 3.2 V |
| 5V / 3V3 / GND | Power pins |
- D0 (GPIO16)
- Wake from deep sleep (connect to RST); no PWM or interrupts
- D1 (GPIO5)
- I2C SCL
- D2 (GPIO4)
- I2C SDA
- D3 (GPIO0)
- Flash button, must be HIGH at boot
- D4 (GPIO2)
- On-board LED (active LOW), must be HIGH at boot
- D5 to D7 (GPIO14, 12, 13)
- SPI SCK, MISO, MOSI
- D8 (GPIO15)
- SPI CS, must be LOW at boot
- A0
- Analog input, 0 to 3.2 V
- 5V / 3V3 / GND
- Power pins
Wiring the D1 Mini (ESP8266)
A typical I2C sensor hookup plus the deep sleep link. Avoid D3, D4 and D8 for buttons or relays because they set the boot mode.
| D1 Mini (ESP8266) pin | Connect to | Notes |
|---|---|---|
| D2 (SDA) | Sensor SDA | I2C data |
| D1 (SCL) | Sensor SCL | I2C clock |
| 3V3 | Sensor VCC | 3.3 V sensors only |
| GND | Sensor GND | Common ground |
| D0 | RST | Deep sleep wake; remove while uploading |
- D2 (SDA)
- Connect to:
- Sensor SDA
- Notes:
- I2C data
- D1 (SCL)
- Connect to:
- Sensor SCL
- Notes:
- I2C clock
- 3V3
- Connect to:
- Sensor VCC
- Notes:
- 3.3 V sensors only
- GND
- Connect to:
- Sensor GND
- Notes:
- Common ground
- D0
- Connect to:
- RST
- Notes:
- Deep sleep wake; remove while uploading
Example code
In the Arduino IDE add the ESP8266 boards URL, install 'esp8266 by ESP8266 Community' and pick 'LOLIN(WEMOS) D1 mini'.
#include <ESP8266WiFi.h>
const char* SSID = "your-wifi";
const char* PASS = "your-password";
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
delay(250);
}
digitalWrite(LED_BUILTIN, LOW); // LED on = connected (active LOW)
Serial.println(WiFi.localIP());
}
void loop() {}Setup and tuning
connect D0 to RST, then ESP.deepSleep(60e6) sleeps for 60 s and wakes by reset. Disconnect the link while uploading.
the regulator and USB chip draw some current even in sleep; for long battery life use a board variant with a low-quiescent regulator.
the on-board divider scales 3.2 V to the chip's 1 V input. Add your own divider for higher voltages.
ESPHome and Tasmota support the D1 Mini for Home Assistant projects (MQTT and Home Assistant).
What you need
Shop this list5 of 5 found in our store · ₹731
D1 Mini V2 ESP8266 Wi-Fi development board: the board this guide coversD1 Mini V2 NodeMcu ESP8266 WiFi IoT Development Board₹209Closest match, check the specs
D1 Mini dual motor shield (TB6612FNG): a stacking shield for motorsWemos D1 Mini Dual Motor Shield (TB6612FNG)₹349
Asair AHT20 temperature and humidity sensor: a first Wi-Fi sensorAsair AHT20 Temperature & Humidity Sensor -40°C to +85°C – I2C Digital Output₹56Closest match, check the specs
Solderless breadboard: to build without solderingSolderless Breadboard₹68
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- ESP8266 NodeMCU: same chip, larger board with more labelled pins.
- ESP32: more GPIOs, Bluetooth, two cores.
- Seeed XIAO boards: even smaller, including ESP32-C3 and S3.
Try it: Battery life calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Using GPIO numbers where the code expects D labels (or the other way round).
- Holding D3, D4 or D8 in the wrong state at boot, so it will not start.
- Feeding 5 V signals into the pins.
- Leaving D0 connected to RST while uploading.
Frequently asked questions
Which board do I select in Arduino IDE?
'LOLIN(WEMOS) D1 mini' (or D1 mini Lite/Pro if you have those) from the ESP8266 core.
Is it 5 V tolerant?
Not officially. Use 3.3 V logic; the 5V pin is for power only.
Why is the LED on when I write LOW?
The built-in LED on D4 is active LOW.
How do I use deep sleep?
Connect D0 to RST and call ESP.deepSleep with a time in microseconds.
What voltage can A0 read?
0 to about 3.2 V thanks to the on-board divider.
Can it run Home Assistant firmware?
Yes. ESPHome and Tasmota both support it.
Parts for this guide
Calculators
Projects that use it
Put this into practice: 9 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.
