The wrong NodeMCU pin reacts (D4 is not pin 4)

  • ESP8266 NodeMCU

You may see

error: 'D4' was not declared in this scope; did you mean 'T4'?

Why it happens

  • D-numbers and GPIO numbers differ: D4 is usually GPIO 2.
  • The D-names exist only when a NodeMCU board is chosen.

How to fix it

  1. Write D4, not 4, for the pin printed D4.
  2. Choose NodeMCU 1.0 (ESP-12E Module) in Tools > Board.

It worked if: The LED on the pin you meant blinks.

From the official documentation. Pin names from the ESP8266 core documentation. Sources: ESP8266 Arduino core: boards.

Didn't help? Search another error or ask us.