# NodeMCU D1, D2 pin labels vs GPIO numbers \(ESP8266\)

> Map NodeMCU ESP8266 labels D0 to D8 to GPIO numbers: D1 is GPIO 5, D2 is GPIO 4 and so on, and which pins to avoid at boot.

Canonical: https://roboticsengineering.in/fix/nodemcu-d-pin-numbers-vs-gpio/ | Published: 2026-11-03 | Updated: 2026-11-04

**On a NodeMCU the D labels are not GPIO numbers.** D1 is GPIO 5, D2 is GPIO 4, D5 is GPIO 14, D6 is GPIO 12 and D7 is GPIO 13.

## What the message means

The ESP8266 sketch uses GPIO numbers, or the D constants the board package defines. Mixing the two gives a pin that does nothing.

## Fix it in this order

1. Use the constants D1, D2 and so on in the sketch if your board package defines them.
2. Or use the GPIO numbers: D0=16, D1=5, D2=4, D3=0, D4=2, D5=14, D6=12, D7=13, D8=15.
3. Avoid D3 (GPIO 0), D4 (GPIO 2) and D8 (GPIO 15) for things that pull the pin at reset. They decide the boot mode.
4. For I2C the usual pins are D1 (SCL) and D2 (SDA).
5. There is only one analog input, A0. The bare chip reads up to about 1 V, and most boards add a divider for 3.3 V.
6. Check the label on your own board, since clone layouts vary.

## Why it happens

On a NodeMCU board, the silkscreen labels D1 through D8 are not the ESP8266’s GPIO numbers. The chip is addressed by GPIO number, and the board package maps each D label to one of those numbers. D1 is GPIO5, D2 is GPIO4, D5 is GPIO14, D6 is GPIO12 and D7 is GPIO13. Writing digitalWrite(1, HIGH) therefore drives GPIO1, which is a different pin from the one you wired to your LED.

Some pins also affect startup. GPIO0, GPIO2 and GPIO15, labelled D3, D4 and D8, set the boot mode at reset, so an attached device that pulls them to the wrong level can stop the board booting. The ESP8266 has one analog input, A0, and the bare chip accepts only about 1 volt there, so check whether your board adds a divider before feeding it more. Checking the pin map printed for your own board is the reliable step, because clones vary.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Pin does nothing | D label used as GPIO. |
| Fails to boot with a module attached | Strapping pin D3, D4 or D8. |

## Confirm the fix

1. Print the value of D1 with Serial.println(); if it prints 5, the board package is mapping the label to GPIO5 as expected.
2. Blink the LED on the wired pin first by D label and then by GPIO number, and note which version lights it.
3. With the device attached, reset the board and check it boots; if it fails only with the device connected, inspect the D3, D4 or D8 wiring.

**Common mistake:** Readers assume the D label on the board is the same number the sketch uses, when the board package maps each label to a separate GPIO number.

## Related

[ESP8266 Soft WDT](https://roboticsengineering.in/fix/esp8266-soft-wdt-reset/), [wiring checker](https://roboticsengineering.in/wiring-checker/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
