NodeMCU ESP8266

Board summary

ManufacturerVarious, ESP8266 is made by Espressif Systems
DatasheetESP8266-NodeMCU-Datasheet.pdf1
Pinoutnodemcu_esp8266_pinout.jpg
Arduino pinsnodemcu/pins_arduino.h
ESPHome deviceNodeMCU ESP8266
ESPHome platformESP8266 Platform
ESPHome configpackages/boards/esp8266nodemcu.yaml2
Frameworkarduino3

ESP8266 NoceMCU

NodeMCU ESP8266 board with micro-USB connector (USB-C variants are also available)

ESPHome support

Board config:

esp8266:
  board: nodemcuv2

Config for status_led (on some boards):

light:

  # This is the built-in blue status LED
  - platform: status_led
    name: "Status LED"
    id: esp_status_led
    icon: "mdi:alarm-light"
    entity_category: "config"
    restore_mode: ALWAYS_OFF
    pin:
      number: D4
      inverted: true

  # Only present on some boards, this is the built in AUX led, next to the UART chip
  - platform: status_led
    name: "AUX LED"
    id: esp_aux_led
    icon: "mdi:alarm-light"
    entity_category: "config"
    restore_mode: ALWAYS_OFF
    pin:
      number: D0
      inverted: true

Pinout

NodeMCU ESP8266 pinout

Pins

The NodeMCU pin numbering on the silkscreen (e.g. D0, A0) is different from the internal pin numbering. ESPHome knows how to map the silkscreen pins numbers to internal pin numbers4.

Silkscreen pinInternal pinInterfaceNotes
A0GPIO17ADC
D0GPIO16Deep-sleep wakeup, AUX LED (inverted)Can be accessed from RTC, weak pull-down
D1GPIO5I²C SCLHigh impedance
D2GPIO4I²C SDAHigh impedance
D3GPIO0Controls boot mode (strapping pin), weak pull-up
D4GPIO2Blue LED (inverted)Controls boot mode (strapping pin), weak pull-up
D5GPIO14SPI CLK/SCKWeak pull-up
D6GPIO12SPI MISOWeak pull-up
D7GPIO13SPI MOSIWeak pull-up
D8GPIO15SPI CS/SSControls boot mode (strapping pin), weak-pull-up
RX / D9GPIO3UART Serial RX
TX / D10GPIO1UART Serial TX

The ESP8266 can only use the designed pins for each interface (SPI, UART, I²C, etc), other pins can't be used for them.

InterfacePins
status_ledD4 / GPIO2
UART RXRX / D9 / GPIO03
UART TXTX / D10 / GPIO01
SPI MISOD6 / GPIO12
SPI MOSID7 /GPIO13
SPI CLK/SCKD5/ GPIO14
SPI CS/SSD8 / GPIO15
ADCA0 / GPIO17
I²C SCLD1 / GPIO5
I²C SDAD2 / GPIO4

Some notes about pins on NodeMCU ESP82663:

  • The internal pull-up/-down resistors have values of to 5.
  • In some cases pins marked as INTERNAL on the pinout can be used.
  • D0 can be used to wake the device up from deep sleep if the pin is connected to the RESET pin.
  • D3, D4, D8: Strapping pins that control boot mode. If these are used as general purpose GPIO pins they should be in the default states to boot from flash:
    • D3 (GPIO0): HIGH
    • D4 (GPIO2): HIGH (blue status led)
    • D8 (GPIO15): LOW
  • D4 (GPIO2): connected to blue status_led, in inverted mode.
  • D0 (GPIO16, only on some boards): AUX LED next to the UART chip, in inverted mode.
  • A0 (GPIO17): ADC pin, measures voltages from to . Can be used as a normal GPIO pin.
  • VIN: Voltage input, board can be powered by external power supply on this pin. Some boards support up to , other .
  • ENABLE/RESET: Board resets when these pins are triggered. Difference is how they handle voltages above .

When the ESP8266 boots, the three strapping pins are checked to determine which boot mode to enter3:

ModeUART codeGPIO0 (D3)GPIO2 (D4)GPIO15 (D8)
Boot from flash (normal)3HIGHHIGHLOW
Program from UART1LOWHIGHLOW
Boot from SD-card4-7AnyAnyHIGH

The reset causes are documented in the datasheet and are as follows:

UART codeReset cause
0Undefined
1Power on reboot
2Deep-sleep wake-up or external reset
4Hardware WDT reset

On boot, the first line in the UART output tells you which boot mode was used and the reset cause:

rst cause:4, boot mode:(3,6)

Here the reset cause was 4 and the boot mode was 3.

6

Components 101 NodeMCU ESP8266