One crucial point to note about the ESP8266 is that the GPIO numbers do not align with the labels on the board's silkscreen. For instance, D0 corresponds to GPIO16, while D1 maps to GPIO5.
The table below illustrates the correspondence between the silkscreen labels and the GPIO numbers. It also highlights which pins are most suitable for your projects and which ones require caution.
Pins highlighted in green are safe to use. Those marked in yellow are generally fine but may exhibit unexpected behavior, especially during boot. Pins highlighted in red are not recommended for use as inputs or outputs.
Label | GPIO | Input | Output | Notes |
D0 | GPIO16 | no interrupt | no PWM or I2C support | HIGH at boot used to wake up from deep sleep |
D1 | GPIO5 | OK | OK | often used as SCL (I2C) |
D2 | GPIO4 | OK | OK | often used as SDA (I2C) |
D3 | GPIO0 | pulled up | OK | connected to FLASH button, boot fails if pulled LOW |
D4 | GPIO2 | pulled up | OK | HIGH at boot connected to on-board LED, boot fails if pulled LOW |
D5 | GPIO14 | OK | OK | SPI (SCLK) |
D6 | GPIO12 | OK | OK | SPI (MISO) |
D7 | GPIO13 | OK | OK | SPI (MOSI) |
D8 | GPIO15 | pulled to GND | OK | SPI (CS) Boot fails if pulled HIGH |
RX | GPIO3 | OK | RX pin | HIGH at boot |
TX | GPIO1 | TX pin | OK | HIGH at boot debug output at boot, boot fails if pulled LOW |
A0 | ADC0 | Analog Input | X |