From D-labels to GPIO numbers
D0 is GPIO16, D1 GPIO5, D2 GPIO4, D3 GPIO0, D4 GPIO2, D5 GPIO14, D6 GPIO12, D7 GPIO13 and D8 GPIO15. In the Arduino core for the ESP8266 you can write either D5 or 14: with the D1 mini board selected, the D constants point to the right GPIO.
D3, D4 and D8: boot pins
The ESP8266 reads three pins at reset: GPIO0 (D3) and GPIO2 (D4) must be HIGH and GPIO15 (D8) LOW to run your sketch. The board already sets these levels with resistors, so the pins work as outputs and for buttons as long as nothing forces the wrong level at power-up. D4 also drives the blue LED of the module, lit when the pin is LOW.
| Pin | On the D1 mini | Needed at reset | In practice |
|---|---|---|---|
| D3 · GPIO0 | Pulled HIGH | HIGH runs the sketch, LOW enters flashing mode | A button to GND is fine |
| D4 · GPIO2 | Pulled HIGH, LED | HIGH | Don’t pull it LOW at power-up |
| D8 · GPIO15 | Pulled LOW | LOW | No pull-up, no module that drives it HIGH |
D0, the special pin
GPIO16 (D0) can’t trigger interrupts and has no internal pull-up, only a pull-down. Its main job is waking the board from deep sleep: wire D0 to RST and ESP.deepSleep() wakes the board with its timer. WEMOS lists it as the only pin without interrupt, PWM, I²C and 1-Wire support.
Analog input and buses
A0 is the only analog input. The bare ESP8266 accepts 0 to 1.0 V, and the D1 mini has a divider that raises the range to about 3.2 V. I²C runs in software on almost any pin, by default D2 (SDA) and D1 (SCL). SPI uses the fixed hardware pins D5 (SCK), D6 (MISO) and D7 (MOSI), with CS on D8 by default. TX and RX go to the USB-serial chip.
Full D1 mini pin table
| Pin | GPIO | Status | Analog | Functions | Notes |
|---|---|---|---|---|---|
| D3 | GPIO0 | Use with care | No | PWM (analogWrite) | boot: HIGH |
| TX | GPIO1 | Use with care | No | PWM (analogWrite), U0TXD | serial TX, UART TX |
| D4 | GPIO2 | Use with care | No | PWM (analogWrite), U1TXD (Serial1) | boot: HIGH, LED |
| RX | GPIO3 | Use with care | No | PWM (analogWrite), U0RXD | serial RX, UART RX |
| D2 | GPIO4 | Free to use | No | PWM (analogWrite) | I²C SDA |
| D1 | GPIO5 | Free to use | No | PWM (analogWrite) | I²C SCL |
| D6 | GPIO12 | Free to use | No | PWM (analogWrite), HSPI MISO | SPI MISO (RX) |
| D7 | GPIO13 | Free to use | No | PWM (analogWrite), HSPI MOSI, RXD2 (Serial.swap) | SPI MOSI (TX) |
| D5 | GPIO14 | Free to use | No | PWM (analogWrite), HSPI SCK | SPI SCK |
| D8 | GPIO15 | Use with care | No | PWM (analogWrite), HSPI CS, TXD2 (Serial.swap) | boot: LOW, SPI CS |
| D0 | GPIO16 | Use with care | No | PWM (analogWrite) | no interrupts, deep-sleep wake |
| A0 | No | Input only | ADC (TOUT) | No | analog only, 0 to 3.2 V |
GPIO 6 to 11 are wired to the module’s flash and are not on the header. The pins work at 3.3 V and are not rated for 5 V, so use a level shifter for 5 V signals.
Frequently asked questions
Which D1 mini pins are safe to use?
D1, D2, D5, D6 and D7 (GPIO 5, 4, 14, 12 and 13) have no boot role and support interrupts and PWM. D3, D4 and D8 are boot pins, D0 has limits, and TX and RX belong to the serial port.
What is the maximum voltage on A0 of the D1 mini?
About 3.2 V, thanks to the divider on the board. The ESP8266 itself accepts 0 to 1.0 V on its ADC, so bare modules need their own divider.
How do I wake the D1 mini from deep sleep?
Connect D0 (GPIO16) to RST and call ESP.deepSleep() with the sleep time in microseconds. When the time is up, GPIO16 pulls RST LOW and the board restarts.
Why doesn’t my D1 mini start with something connected to D8?
D8 is GPIO15, which must be LOW at reset. A module or an external pull-up that holds it HIGH makes the ESP8266 choose another boot mode. Move that connection to D1, D2 or D5 to D7.
Which pins are I2C and SPI on the D1 mini?
I²C defaults to D2 (SDA) and D1 (SCL), and Wire.begin(SDA, SCL) moves it to most other pins. SPI uses D5 (SCK), D6 (MISO) and D7 (MOSI), with CS usually on D8.