A NodeMCU can look simple on the bench: a USB cable, two rows of headers and a small ESP8266 module. The pin labels cause most first-time wiring mistakes. D1, for example, means GPIO5, while GPIO1 is the UART TX pin. This guide starts by identifying the exact board, then maps its pins and explains the limits that matter when you connect sensors or other hardware.
The main reference is a common NodeMCU ESP-12E-style board. The same method also helps you identify an ESP-01, ESP-12E/12F module or Wemos D1 Mini before using its pin diagram.
What Is the ESP8266?
Espressif’s ESP8266 is a Wi-Fi system-on-chip (SoC) with a 32-bit Tensilica L106 processor and built-in 2.4 GHz Wi-Fi. It provides the processing and wireless connection for compact Internet of Things projects.
The ESP8266EX chip, an ESP module and a development board are different pieces of hardware. ESP-12E and ESP-12F modules add the radio components and antenna connections. A NodeMCU board adds header pins, a USB-to-serial interface and power regulation, which makes prototyping easier.
ESP8266 Pinout Diagram: Identify Your Board First
An ESP8266 pinout diagram only makes sense when it matches the hardware on your desk. Start with the board name and module marking. Then check the header layout and the diagram’s viewing direction.

- ESP8266EX chip pinout: the 32-pin QFN package used in chip-level designs.
- ESP-01 / ESP-01S pinout: a compact module with only a few exposed GPIO and power connections.
- ESP-12E / ESP-12F pinout: module layouts commonly fitted to development boards.
- NodeMCU ESP8266 pinout: a development-board layout with D0–D8 labels, RX, TX, 3V3, GND and board power pins.
- Wemos D1 Mini pinout: a smaller development board with its own header arrangement.
The mapping table below covers a common NodeMCU ESP-12E-style board. It does not apply directly to an ESP-01, a bare ESP-12 module or the ESP8266EX chip. Clones and board revisions can differ, so check the silkscreen and schematic for your board.
NodeMCU ESP8266 Pinout and GPIO Mapping
NodeMCU prints labels such as D0, D1 and D2 beside the header pins. These are board labels, not the chip’s GPIO numbers. For example, D1 maps to GPIO5 and D2 maps to GPIO4. Use the board constants supplied by your selected ESP8266 Arduino board definition, or enter the matching GPIO number in your framework.

| NodeMCU label | ESP8266 GPIO | Common function | Practical note |
|---|---|---|---|
| D0 | GPIO16 | Deep-sleep wake, digital I/O | Limited peripheral support, do not assume normal interrupt/PWM/I²C support. |
| D1 | GPIO5 | I²C SCL (common convention) | Frequently used as the I²C clock pin. |
| D2 | GPIO4 | I²C SDA (common convention) | Frequently used as the I²C data pin. |
| D3 | GPIO0 | Boot-configuration pin | Must be HIGH for normal flash boot, LOW selects UART download mode. |
| D4 | GPIO2 | Boot-configuration pin, onboard LED on many boards | Must be HIGH for normal flash boot, board LED polarity/layout varies. |
| D5 | GPIO14 | SPI SCLK | Common hardware SPI clock pin. |
| D6 | GPIO12 | SPI MISO | Common hardware SPI MISO pin. |
| D7 | GPIO13 | SPI MOSI | Common hardware SPI MOSI pin. |
| D8 | GPIO15 | SPI CS, boot-configuration pin | Must be LOW for normal flash boot, external circuits must not force it HIGH at startup. |
| RX | GPIO3 | UART0 RX | Used for serial communication and programming. |
| TX | GPIO1 | UART0 TX | Used for serial output and programming, avoid loading it LOW at startup. |
| A0 | ADC0 / TOUT | Analog input | Input range depends on the chip/module/board circuitry, check the exact board. |
Quick pin choice reference
| Task | Possible starting pin | Check before wiring |
|---|---|---|
| I²C sensor | D1 / GPIO5, D2 / GPIO4 | Confirm the library pin settings and sensor voltage. |
| SPI device | D5 / GPIO14, D6 / GPIO12, D7 / GPIO13 | Reserve the correct clock, MISO and MOSI lines. |
| LED or digital output | D1, D2, D5, D6 or D7 | Use a series resistor and check the startup state. |
| Serial debugging | RX / GPIO3 and TX / GPIO1 | Keep these pins available during upload and serial monitoring. |
| Deep-sleep wake | D0 / GPIO16 to RST | Check the board/module circuit and wake-up design. |
GPIO16, PWM, and Deep-Sleep Wake
GPIO6–GPIO11 connect to external SPI flash on common ESP8266 modules. They are unavailable for ordinary I/O on most development boards. Leave them alone unless the module’s design and flash arrangement explicitly allow another use.
GPIO16 is different from the other pins on a common ESP8266 board. It is connected to the RTC side of the chip and can be used to wake the ESP8266 from deep sleep when GPIO16 is connected to RST. This wake-up arrangement is board- and module-dependent, so check the module design before adding the wire.
GPIO16 also has peripheral limitations. Code that works on GPIO5 or GPIO14 may behave differently on GPIO16, especially when a library expects a standard interrupt-capable pin. PWM support depends on the ESP8266 Arduino core and the selected pin. Check the core documentation and library requirements before assigning a pin to a timing-sensitive task.
For a first project, keep GPIO16 free until you know whether the design needs deep-sleep wake-up. That avoids having to move a sensor or output later.
ESP8266 Power Pins and Voltage Requirements
The ESP8266 uses 3.3V logic. Its GPIO pins cannot accept 5V signals directly. Use a suitable level shifter or a correctly calculated resistor divider when a connected device outputs 5V.
Development boards often include a voltage regulator and may accept power through USB or a VIN/5V input. That does not mean the ESP8266 chip itself should be powered directly from 5V. Check the board markings and schematic to identify the correct input pin. Connect grounds together when interfacing the board with external sensors or modules, and use a stable supply capable of handling Wi-Fi current peaks. For a wider look at regulated rails and power selection, see our guide to the power supply for embedded systems.
You may see 3V3 for regulated 3.3V, GND for ground, VIN or 5V for the board’s power input, EN/CH_PD for chip enable, and RST for the active-low reset input. Check the board documentation because the circuit behind these labels varies.

Power Stability and Reset Problems
Wi-Fi transmission causes brief current peaks. A weak supply may seem fine while the board is idle, then dip when the radio transmits or a relay switches. The ESP8266 may reset, lose its Wi-Fi connection or return unexpected sensor readings.
Use a regulated supply that meets your board’s input requirements. When powering NodeMCU over USB, use a sound cable and stable USB source. Before using VIN or 5V, check the board regulator. Never feed 5V into 3V3. A bare ESP-12 module also needs a different power arrangement from a NodeMCU board.
For custom hardware, place the recommended decoupling capacitors close to the module’s supply pins and follow the module reference design. Keep power and ground paths short. Motors and relays need a driver stage and a suitable load supply. Do not power them from an ESP8266 GPIO.
If the board keeps restarting, remove the peripherals and test it with a known-good supply. Reconnect one device at a time. This helps isolate a supply fault, boot-pin conflict, short circuit or faulty module.
ESP8266 Boot Mode Pins: GPIO0, GPIO2, and GPIO15
GPIO0, GPIO2 and GPIO15 set the ESP8266 boot mode. The chip reads their logic levels during startup. If an attached sensor or circuit pulls one of them to the wrong level, the board may fail to start or enter UART programming mode.
| Pin | Normal flash boot | UART download mode |
|---|---|---|
| GPIO15 | LOW | LOW |
| GPIO0 | HIGH | LOW |
| GPIO2 | HIGH | HIGH |
Development boards usually include the pull-up and pull-down resistors needed for normal startup. External circuits can still override those levels. If the board will not boot or upload, disconnect devices from these three pins and test it again.

ESP8266 Analog Input: A0 and ADC0
The ESP8266 has one analog-to-digital converter input. It is called TOUT on the chip and is labelled A0 on many development boards. You can use it with a potentiometer or a sensor that provides an analog voltage. The bare ESP8266EX ADC input range is 0–1.0V.
Some NodeMCU boards add a resistor divider that lets the A0 header read a higher voltage, often up to about 3.3V. Other boards do not. Check the schematic for your exact board before connecting an analog sensor. A0 does not have the same input range on every ESP8266 board.

ESP8266 UART, SPI, and I²C Pins
UART (Serial Communication)
The main UART uses GPIO1 for TX and GPIO3 for RX. The USB-to-serial interface uses these pins when you upload sketches or view serial output. Another device connected to RX or TX can disrupt uploads and debugging. Check signal voltage before connecting a second board.
SPI (Serial Peripheral Interface)
On a common NodeMCU layout, D5/GPIO14 carries SPI SCLK, D6/GPIO12 carries MISO and D7/GPIO13 carries MOSI. D8/GPIO15 can act as chip select. Remember that GPIO15 must stay LOW during normal boot.
I²C (Inter-Integrated Circuit)
A common NodeMCU convention is D1/GPIO5 for SCL and D2/GPIO4 for SDA. Unlike a dedicated fixed-function I²C peripheral pin pair, ESP8266 projects commonly configure I²C through the software/board support package. Confirm the pin arguments used by your framework and library. For a broader comparison of I²C, SPI, and UART communication, see the protocol guide.

How to Choose a Safe GPIO Pin
A GPIO may support input or output and still cause trouble in your circuit. Check its startup state, any onboard connection and the signal driven by the attached device. A circuit can work after startup yet stop the ESP8266 from booting if it changes a boot-sensitive pin during reset.
For an LED or digital output, start with an exposed pin that the boot process and serial interface do not need. On a common NodeMCU ESP-12E board, D1/GPIO5, D2/GPIO4, D5/GPIO14, D6/GPIO12 and D7/GPIO13 are useful candidates. Check existing connections and the board schematic before choosing one.
A button input needs a defined idle level. A floating pin can switch randomly and produce false readings. Add a suitable pull-up or pull-down, and check whether your selected pin and board core support the internal pull-up you plan to use.
Write down your pin assignments before wiring several peripherals. Record the D-label, GPIO number, function and any startup restriction. Keep RX/TX free when you need serial debugging, avoid boot-pin conflicts and leave GPIO6–GPIO11 unused on typical modules.
Board-first pin selection: identify the board, check its boot-sensitive pins, reserve any pins used by USB-to-serial or onboard hardware, then assign the remaining GPIOs to peripherals. For a common NodeMCU ESP-12E, D1, D2, D5, D6 and D7 are practical starting points for many projects, subject to the attached circuit and library configuration. This order keeps a pin from looking free on the diagram when the board already depends on it during startup.
Understanding NodeMCU Board Labels and Arduino Code
NodeMCU uses D0, D1 and D2 labels on its headers. The chip uses GPIO numbers. The names map to each other, but they are not interchangeable. For example, NodeMCU D1 is GPIO5. GPIO1 is UART TX, so pinMode(1, OUTPUT) does not select D1.
With the ESP8266 Arduino core and the correct NodeMCU board selected, you can use D0 through D8 in your sketch. For example, const int sensorPin = D2; selects the D2 header, which maps to GPIO4 on the common layout. If you use raw GPIO numbers, add the board mapping to your project notes.
The selected board in the Arduino IDE also matters. Choose the board definition that matches the hardware as closely as possible, such as a NodeMCU 1.0 (ESP-12E Module) option when appropriate. Board menu names can differ between core versions. If the wrong board is selected, upload settings, flash layout, LED definitions or pin aliases may not match the hardware you are using. If you are also working with other Arduino boards, compare the Arduino Uno pinout and Arduino Nano pinout before reusing wiring assumptions.
Select the right serial port and upload settings. Disconnect devices from RX and TX if they interfere with uploading. If an upload fails, check the cable, USB-to-serial driver, port, supply voltage and boot mode. Also inspect circuits connected to GPIO0, GPIO2, GPIO15, RX and TX.
Connecting an LED, Button, and I²C Sensor
Use an LED and a series current-limiting resistor for a first GPIO test. Connect the circuit for the active-high or active-low arrangement you want, and check the LED polarity. Never connect an LED directly to a GPIO without a resistor. Choose a pin that will not disrupt startup.

A push button can be connected as a digital input. One common arrangement connects the button between a GPIO input and ground and enables a supported internal pull-up in software. In that arrangement, the input normally reads HIGH and reads LOW when the button is pressed. The logic is therefore active-low. If you use an external pull-up or pull-down resistor instead, calculate and wire it according to the circuit and the ESP8266’s 3.3V logic requirements. For input circuits that need a defined idle state, review how a pull-up resistor works.
For an I²C sensor such as the BME280 shown in the wiring example, NodeMCU commonly uses D1/GPIO5 for SCL and D2/GPIO4 for SDA. Connect the grounds and power the sensor at the voltage stated in its datasheet. Some breakout boards accept 3.3V only. Others include a regulator or level shifter, so check the board rather than guessing from its connector.
I²C needs pull-up resistors on its signal lines. A breakout board may include them, but some do not. Several modules with onboard pull-ups can also make the combined resistance too low. If the bus fails, check the address, wiring, shared ground, pull-ups, supply voltage and software pin settings.
Arduino LED Blink Example
This sketch blinks an LED connected to NodeMCU D1. Use a series resistor with an external LED. For the onboard LED, check its GPIO and polarity first.
const int ledPin = D1; // NodeMCU D1 maps to GPIO5
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}ESP8266 Module and Board Pinout Differences
ESP-01 is a compact module with fewer exposed connections than NodeMCU. Depending on the version, its header may expose GPIO0 and GPIO2, serial pins, reset and power. Use an ESP-01 or ESP-01S diagram that matches your module. A NodeMCU diagram will give you the wrong physical pin locations.
ESP-12E and ESP-12F are shielded ESP8266 modules with castellated pads around their edges. NodeMCU-style boards often use one of these modules. The module diagram shows its pads, while the development-board diagram shows the headers, regulator and USB circuitry added by the board.
Wemos D1 Mini is a compact ESP8266 development board with its own D-labelled header layout. Its pin positions differ from NodeMCU. Use a D1 Mini diagram when wiring that board. The ESP32 pinout is useful when comparing another Wi-Fi microcontroller, while the Raspberry Pi pinout covers a different type of board.
NodeMCU boards with 30 or 38 pins, the D1 Mini and ESP-01 may all use the ESP8266, but their connectors and pin locations differ. Check the USB connector, board size, header count, printed labels and module marking. If the model is unclear, compare the board with its schematic before connecting power.
Common ESP8266 Pinout Mistakes to Avoid
- Using NodeMCU D-labels as if they were GPIO numbers.
- Applying 5V directly to a 3.3V GPIO.
- Assuming every A0 input accepts 0–3.3V without checking for a divider.
- Ignoring the startup levels required by GPIO0, GPIO2 and GPIO15.
- Using GPIO6–GPIO11 as normal I/O on a board where they connect to flash.
- Leaving devices on RX/TX when they interfere with serial uploads.
- Using a NodeMCU diagram to wire an ESP-01, ESP-12 module or D1 Mini.
ESP8266 Pinout Troubleshooting
Use the table to trace the symptom to a likely pin or wiring fault. Change one thing at a time so the test tells you something useful.
| Symptom | Possible pin-related cause | What to check |
|---|---|---|
| Board does not boot | A boot-sensitive pin is held at the wrong level. | Disconnect external circuits from GPIO0, GPIO2 and GPIO15, check startup pull resistors. |
| Sketch will not upload | GPIO0 is not LOW for download mode, or UART pins are being driven. | Check the board’s auto-reset circuit and disconnect devices from RX/TX during upload. |
| Analog readings are incorrect | A0 range or board divider is misunderstood. | Check the exact board schematic and keep the input within its specified range. |
| Sensor behaves unreliably | Wrong GPIO mapping or unsuitable boot-sensitive pin. | Confirm D-label-to-GPIO mapping and choose a suitable pin. |
| Board resets during Wi-Fi use | Power supply cannot handle current peaks or wiring causes voltage drop. | Use a stable supply, short power leads and suitable decoupling. |
How to Read an ESP8266 Pinout Diagram
Read the diagram title first. Does it show the ESP8266EX chip, ESP-01, ESP-12, NodeMCU or Wemos D1 Mini? Then check the viewing direction and board orientation. A bottom-view diagram can be mirrored compared with a top-side photograph.
Match the board label to the signal name. For example, a NodeMCU header marked D5 maps to GPIO14, which commonly carries SPI SCLK. A useful diagram shows both names so you can match the physical header to your code.
Find 3V3, GND, VIN or 5V, EN/CH_PD and RST before wiring. These pins have different electrical roles. A 5V board input does not make the GPIO pins 5V-tolerant. Also check for pins connected to the onboard LED, USB-to-serial interface, flash memory or boot circuit.
Check alternate pin functions against the documentation for your board and software framework. A pin may support several functions, but you cannot use all of them at once. If D5 is assigned to SPI SCLK, show that role in the wiring diagram and code.
ESP8266 Pinout Checklist Before Powering On
Before powering the circuit, check the whole connection. Confirm the board supply, shared ground and voltage on every input. Check polarity on LEDs, electrolytic capacitors, sensors and external power connectors.
Check the startup levels on GPIO0, GPIO2 and GPIO15. Attached modules must not force them into the wrong state when power is applied or reset is pressed. Devices on RX and TX must also leave serial programming available. Keep flash pins unused unless the board design supports another use.
Compare every code pin with the physical wiring. If the diagram says D2 but the sketch uses GPIO2, the code selects a different pin. Keep the D-label-to-GPIO table beside your wiring diagram and label both names.
Bring up a new project in stages. Upload a simple sketch with peripherals disconnected, test one GPIO, then add one module at a time. Save the pin assignments and board revision with the project. Recheck the diagram if you replace the board with a different clone.
ESP8266 Pinout FAQs
1. What is the ESP8266 pinout?
↑2. What are the GPIO pins on the NodeMCU ESP8266?
↓3. Does the ESP8266 have an analog input pin?
↓4. Which ESP8266 pins are used for I²C?
↓5. Which pins are used for SPI on NodeMCU?
↓6. Can I connect 5V directly to an ESP8266 GPIO?
↓7. What is the difference between ESP-01 and NodeMCU pinouts?
↓8. Where can I find the ESP8266 datasheet or pinout PDF?
↓Conclusion
Choose the pinout for your exact ESP8266 board before connecting anything. On a common NodeMCU, check each D-label against its GPIO number, respect the boot-sensitive pins, and keep signals within 3.3V limits. Verify the A0 range and power input on your board schematic. With those checks complete, you can connect peripherals, upload code, and troubleshoot projects more confidently and safely.


























