ESP8266 Pinout Reference: Which GPIO pins should you use?

This article is a guide for the ESP8266 GPIOs: pinout diagrams, their functions and how to use them.

ESP8266 Pinout Reference GPIOs Pins Guide

The ESP8266 12-E chip comes with 17 GPIO pins. Not all GPIOs are exposed in all ESP8266 development boards, some GPIOs are not recommended to use, and others have very specific functions.

With this guide, you’ll learn how to properly use the ESP8266 GPIOs and avoid hours of frustration by using the most suitable pins for your projects.

We also have a guide for the ESP32 GPIOs: ESP32 Pinout Reference: Which GPIO pins should you use?

ESP8266 12-E Chip Pinout

The following figure illustrates the ESP8266 12-E chip pinout. Use this diagram if you’re using an ESP8266 bare chip in your projects.

ESP8266 12-E chip pinout diagram gpios pins

Note: not all GPIOs are accessible in all development boards, but each specific GPIO works in the same way regardless of the development board you’re using. If you’re just getting started with the ESP8266, we recommend reading our guide: Getting Started with the ESP8266.

At the moment, there are a wide variety of development boards with the ESP8266 chip that differ in the number of accessible GPIOs, size, form factor, etc…

The most widely used ESP8266 boards are the ESP-01, ESP8266-12E NodeMCU Kit, and the Wemos D1 Mini. For a comparison of these board, you can read this guide: ESP8266 Wi-Fi Development Boards comparison.

ESP8266-01 Pinout

If you’re using an ESP8266-01 board, you can use the following GPIO diagram as a reference.

ESP-01 ESP8266 pinout diagram gpios pins

ESP8266 12-E NodeMCU Kit

The ESP8266 12-E NodeMCU kit pinout diagram is shown below.

ESP8266 12-E NodeMCU Kit pinout diagram gpios pins

Wemos D1 Mini Pinout

The following figure shows the WeMos D1 Mini pinout.

WeMos D1 Mini Pinout diagram gpios pins

Download PDF with ESP8266 Pinout Diagrams

We’ve put together a handy PDF that you can download and print, so you always have the ESP8266 diagrams next to you:

Download PDF Pinout Diagrams »

ESP8266 Peripherals

The ESP8266 peripherals include:

  • 17 GPIOs
  • SPI
  • I2C (implemented on software)
  • I2S interfaces with DMA
  • UART
  • 10-bit ADC

Best Pins to Use – ESP8266

One important thing to notice about ESP8266 is that the GPIO number doesn’t match the label on the board silkscreen. For example, D0 corresponds to GPIO16 and D1 corresponds to GPIO5.

The following table shows the correspondence between the labels on the silkscreen and the GPIO number as well as what pins are the best to use in your projects, and which ones you need to be cautious.

The pins highlighted in green are OK to use. The ones highlighted in yellow are OK to use, but you need to pay attention because they may have unexpected behavior mainly at boot. The pins highlighted in red are not recommended to use as inputs or outputs.

LabelGPIOInputOutputNotes
D0GPIO16no interruptno PWM or I2C supportHIGH at boot
used to wake up from deep sleep
D1GPIO5OKOKoften used as SCL (I2C)
D2GPIO4OKOKoften used as SDA (I2C)
D3GPIO0pulled upOKconnected to FLASH button, boot fails if pulled LOW
D4GPIO2pulled upOKHIGH at boot
connected to on-board LED, boot fails if pulled LOW
D5GPIO14OKOKSPI (SCLK)
D6GPIO12OKOKSPI (MISO)
D7GPIO13OKOKSPI (MOSI)
D8GPIO15pulled to GNDOKSPI (CS)
Boot fails if pulled HIGH
RXGPIO3OKRX pinHIGH at boot
TXGPIO1TX pinOKHIGH at boot
debug output at boot, boot fails if pulled LOW
A0ADC0Analog InputX

Continue reading for a more detailled and in-depth analysis of the ESP8266 GPIOs and its functions.

GPIOs connected to the Flash Chip

GPIO6 to GPIO11 are usually connected to the flash chip in ESP8266 boards. So, these pins are not recommended to use.

Pins used during Boot

The ESP8266 can be prevented from booting if some pins are pulled LOW or HIGH. The following list shows the state of the following pins on BOOT:

  • GPIO16: pin is high at BOOT
  • GPIO0: boot failure if pulled LOW
  • GPIO2: pin is high on BOOT, boot failure if pulled LOW
  • GPIO15: boot failure if pulled HIGH
  • GPIO3: pin is high at BOOT
  • GPIO1: pin is high at BOOT, boot failure if pulled LOW
  • GPIO10: pin is high at BOOT
  • GPIO9: pin is high at BOOT

Pins HIGH at Boot

There are certain pins that output a 3.3V signal when the ESP8266 boots. This may be problematic if you have relays or other peripherals connected to those GPIOs. The following GPIOs output a HIGH signal on boot:

  • GPIO16
  • GPIO3
  • GPIO1
  • GPIO10
  • GPIO9

Additionally, the other GPIOs, except GPIO5 and GPIO4, can output a low-voltage signal at boot, which can be problematic if these are connected to transistors or relays. You can read this article that investigates the state and behavior of each GPIO on boot.

GPIO4 and GPIO5 are the most safe to use GPIOs if you want to operate relays.

Analog Input

The ESP8266 only supports analog reading in one GPIO. That GPIO is called ADC0 and it is usually marked on the silkscreen as A0.

The maximum input voltage of the ADC0 pin is 0 to 1V if you’re using the ESP8266 bare chip. If you’re using a development board like the ESP8266 12-E NodeMCU kit, the voltage input range is 0 to 3.3V because these boards contain an internal voltage divider.

You can learn how to use analog reading with the ESP8266 with the following guide:

On-board LED

Most of the ESP8266 development boards have a built-in LED. This LED is usually connected to GPIO2.

ESP8266 NodeMCU On-board LED

The LED is connected to a pull-down resistor, so when you send a HIGH signal the LED turns off.

RST Pin

When the RST pin is pulled LOW, the ESP8266 resets. This is the same as pressing the on-board RESET button.

ESP8266 NodeMCU On-board Reset button

GPIO0

When GPIO0 is pulled LOW, it sets the ESP8266 into bootloader mode. This is the same as pressing the on-board FLASH/BOOT button.

ESP8266 NodeMCU GPIO 0 Flash boot button

GPIO16

GPIO16 can be used to wake up the ESP8266 from deep sleep. To wake up the ESP8266 from deep sleep, GPIO16 should be connected to the RST pin. Learn how to put the ESP8266 into deep sleep mode:

I2C

The ESP8266 doens’t have hardware I2C pins, but it can be implemented in software. So you can use any GPIOs as I2C. Usually, the following GPIOs are used as I2C pins:

  • GPIO5: SCL
  • GPIO4: SDA

SPI

The pins used as SPI in the ESP8266 are:

  • GPIO12: MOSI
  • GPIO13: MISO
  • GPIO14: SCLK
  • GPIO15: CS

PWM Pins

ESP8266 allows software PWM in all I/O pins: GPIO0 to GPIO16. PWM signals on ESP8266 have 10-bit resolution. Learn how to use ESP8266 PWM pins:

Interrupt Pins

The ESP8266 supports interrupts in any GPIO, except GPIO16.

Wrapping Up

We hope you’ve found this guide for the ESP8266 GPIOs useful. If you have some tips on how to use the ESP8266 GPIOs properly, you can write a comment below.

We also have a similar guide for the ESP32 GPIOs that you can read.

If you’re getting started with the ESP8266, we have some great content you might be interested in:

Thanks for reading.


Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our weekly newsletter!

38 thoughts on “ESP8266 Pinout Reference: Which GPIO pins should you use?”

    • A really comprehensive guide. I’ve done a lot of trial and error with these devices. I now have all of the insight to design my projects and possibly a commercial product correctly from scratch. I am much endebted.

      Reply
  1. Rui, your site is one of the best there is for learning ESP8266 (& ESP32).
    I’ve struggled a lot with projects that wont boot etc. and now I understand why !!!
    Your articles are always very professional, very interesting and easy to follow.
    I have found many solutions to problems by studying your articles & projects !!
    Thank you !!

    Reply
    • Hi.
      Thank you so much for your nice works.
      I’m very happy to see that our readers really enjoy our work. That keeps me motivated to write even better content.
      Regards,
      Sara

      Reply
  2. Great article, thanks !!
    It’s always convenient to have tables showing the pin outs of these fantastic cards.
    I’ve been trying to flash an ESP-07S with nodemcu firmware lately, but I didn’t succeed. Do you have a chart for this card?
    Greetings. Mike.

    Reply
  3. Thank you for producing comprehensive guides to ESP8266 devices /boards (also ESP12E), they provide very useful and accessible information sources, without the need for internet searches.

    Reply
  4. Thanks for this useful guide to the pinouts.

    Does the Wemos D1 mini have an onboard voltage divider for the analog input? I ask because I just tried an ACS712 Current Sensor Module, 5V powered, and divided down to the 1V range with a 4K7 & 1K2 resistor divider.

    The ACS712 gives a “neutral” reading of half the range, so I was expecting around 512 with nothing connected. Instead I get 170, which would be expected if the A0 input was divided onboard by 3.

    (Now what do I need to do to turn a divide by 3 into a divide by 5?)

    Reply
  5. This clears up some questions, thanks!

    Is there a key or guide for the color tabs used in the pinout diagrams? I understand black and red, but light blue, gray, etc?

    Thanks

    Reply
    • Hi Dave.
      Those are just random colors we’ve chosen to differentiate the pins.
      Pins with similar functions are highlighted with the same color.
      For example, SPI is green, I2C is light blue, etc.
      Regards,
      Sara

      Reply
  6. Wonderful, clear and concise article.
    I bough one of your guide and it’s written this way.
    Pleasant to read and to use!

    Reply
  7. O trabalho de vcs é perfeito, sempre fico impressionado com a qualidade e precisão de suas postagens.

    Reply
  8. You are correct, the A0 input is divided. See drawing.
    escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram/
    In the middle of the schematic far right you can the the divider.

    Reply
  9. Forgot to mention that you can modify the voltage divider on the ACS712 to a 5 to 3 V divider. Here some math comes in. since you will load 1 voltage divider by another. Some testing needed. Final calibration can be done in software.

    Reply
  10. Re voltage divider on the D1 Mini, the link below says onboard there are 220K and 100K resistors, so to divide down 5 volts, you add 180K in series to A0.

    letscontrolit.com/wiki/index.php/DC_Voltage_divider

    Reply
  11. Great resource, thank you.
    Your site is one that I recommend to folks often as your courses are so well put together. Please keep it up 🙂

    Reply
  12. I have an ESP-WROOM-32 board, what pin-out should I follow? I looks kinda like the ESP8266 12-E NodeMCU Kit, pins are differently labelled. Any assistance.

    Reply
  13. Greetings

    Excellent guide.
    I was struggling with a D1 mini, three switch buttons and four relays.

    It seems that I must use an esp32.

    Thanks

    Reply
    • A D1 mini should be able to handle 3 switch buttons and 4 relays. Note that RX and TX can be made to be GPIOs if need to be. I’ve been bitten by boot condition needs–specifically, I had a pullup for a DS18B20 on D8, which disabled normal booting.

      It’s also possible to add an MCP23017 16-bit I2C GPIO expander module (<$3US on ebay) to gain a lot more I/Os on a D1 Mini (I like the D1 Mini a lot).

      Reply
  14. Hey guys! This page is very useful!

    I’m currently prototyping using a Wemos D1 mini, but tht final processor will be an ESP12EX. Since it has more GPIOs available at the bottom (GPIO: 6, 8, 10 , 9, 7, 11) do you know if these are usable? I’m planning to create my own breakout board since I don’t need the extra stuff NodeMCU has. Thank you!

    Reply

Leave a Reply to Andrew Wilson Cancel reply

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.