Arduino IDE ESP8266 Setup: NodeMCU Install and First Sketch

NodeMCU ESP8266 Development Board with 0.96 Inch OLED Display, CH340, ESP-12E WiFi Mod, additional view - Quality RC Parts

Arduino IDE ESP8266 Setup: NodeMCU Install and First Sketch

Arduino IDE ESP8266 setup starts with Arduino IDE 2: add the ESP8266 board manager URL to Preferences, install esp8266 by ESP8266 Community in Boards Manager, then select NodeMCU 1.0 (ESP-12E Module) and the serial port. The URL is https://arduino.esp8266.com/stable/package_esp8266com_index.json. Upload the Blink example to confirm the install, then run the WiFi scan example to test the radio.

Quick facts

  • Board package: esp8266 by ESP8266 Community, installed through Boards Manager.
  • Board manager URL: https://arduino.esp8266.com/stable/package_esp8266com_index.json
  • Board entry: NodeMCU 1.0 (ESP-12E Module).
  • Built-in LED: GPIO 2, also labeled D4, active low. LOW turns it on.
  • Logic level: 3.3 V. One analog input, A0, with a 0 to 1023 read range.

What is a NodeMCU board?

NodeMCU is a ready-made board around the ESP8266 chip. It adds a USB port, a 3.3 V regulator, and reset and flash buttons to the ESP-12E module. The ESP8266 is a single-core WiFi chip with 80 MHz clock speed and 4 MB of flash on most NodeMCU boards. It has one analog input and a small set of GPIO pins. It is older than ESP32, and it has less RAM and fewer pins. It still works well for a WiFi sensor, a simple web server, or a first IoT project. The board in this guide is the NodeMCU with a 0.96 inch OLED display and a CH340 USB chip.

The D labels on the board are nicknames for GPIO numbers. D0 is GPIO 16, D1 is GPIO 5, D2 is GPIO 4, D3 is GPIO 0, and D4 is GPIO 2. The safest pins to start with are D1, D2, D5, D6, and D7. Avoid D3 and D4 for outputs until you understand the boot pins, because GPIO 0 and GPIO 2 affect startup. The pinout guide in this series is not part of this post, so check the board marking before you wire a sensor. The OLED on the board in this guide connects over I2C, and the WiFi scan example in this post does not need it.

How do you add the ESP8266 board package?

Install Arduino IDE 2 if it is not already installed. Open Arduino IDE and go to File, Preferences on Windows and Linux, or Arduino IDE, Settings on macOS. Find Additional boards manager URLs. Paste this URL on its own line: https://arduino.esp8266.com/stable/package_esp8266com_index.json. If the field already holds other URLs, add this one on a new line. Click OK. This URL points to a JSON index that tells Boards Manager where to fetch the ESP8266 Community package. Do not paste a GitHub repository page instead. The repository page is source code, and Boards Manager cannot read it.

Open Tools, Board, Boards Manager. Type esp8266 in the search box. Find esp8266 by ESP8266 Community and click Install. The download includes the compiler toolchain, so allow several minutes. When the install finishes, close Boards Manager and restart Arduino IDE. Open Tools, Board and confirm that an ESP8266 Boards section now appears. If the section is missing, check the URL for a typo and confirm that you used the stable index URL, not an old mirror. The old dl.espressif.com style URLs are outdated for ESP8266.

Which board entry and port do you pick?

Open Tools, Board, ESP8266 Boards, and select NodeMCU 1.0 (ESP-12E Module). That entry matches the NodeMCU boards in this guide. If you are unsure which board you have, select Generic ESP8266 Module as a fallback, but the NodeMCU entry is the right pick for a NodeMCU board. Leave the other Tools options at their defaults for the first upload. Flash Size should read 4MB. CPU Frequency should read 80 MHz. Upload Speed at 921600 works on most boards with a good cable. Lower it to 115200 if uploads fail.

Connect the board with a USB data cable. The NodeMCU board in this guide uses a CH340 USB chip. On Windows, the port appears as USB-SERIAL CH340 under Ports in Device Manager. On macOS it appears as a cu.usbserial device. On Linux it appears as /dev/ttyUSB0. Pick the new port under Tools, Port. Unplug the board and watch the port disappear to confirm it belongs to your board. If no port appears, the cable or the CH340 driver is the problem. The driver fix guide in this series covers CH340 and CP2102 installs.

What does the first sketch do?

Open File, Examples, 01.Basics, Blink. The sketch sets LED_BUILTIN as an output and toggles it once per second. On a NodeMCU board, LED_BUILTIN is GPIO 2, also labeled D4. The LED is active low, so writing LOW turns it on and writing HIGH turns it off. That confuses many beginners. The Blink example handles it, because it toggles the pin and you see the LED change state. Click Upload and wait for Done uploading. The LED starts to blink. That confirms the core install, the board entry, and the port in one test.

If Blink does not upload, read the output panel. A fatal error about a timeout means the chip did not enter download mode. Press and hold the FLASH button on the board, click Upload, and release FLASH when the output shows Connecting. Most NodeMCU boards enter download mode on their own, but a weak auto-reset circuit can fail. A port busy error means another program holds the port. Close the Serial Monitor and any other serial tool, then retry. A sketch too big error on ESP8266 is rare for Blink, and it points at a wrong Flash Size setting.

How do you test WiFi with a scan sketch?

Open File, Examples, ESP8266WiFi, WiFiScan. That example is included with the ESP8266 core. It scans for nearby networks and prints each network name, signal strength, and encryption type to the Serial Monitor. Click Upload, then open Tools, Serial Monitor at 115200 baud. The scan runs, prints the list, waits 5 seconds, and scans again. A list of networks proves the radio works and the antenna is connected. An empty list with no error usually means the board is in a shielded spot or the antenna is damaged. Move the board and retry before you change code.

Read the scan output line by line. Each line shows the network name, the channel, and the signal strength in dBm. A signal near -30 dBm is strong. A signal near -90 dBm is weak. The ESP8266 radio draws more current when it transmits, so a weak USB port can reset the board during a scan. If the board resets when WiFi starts, use a shorter cable and a port directly on the computer. The brownout guide in this series explains the power rules for ESP32, and the same current rules apply to ESP8266 WiFi.

When should you pick ESP32 instead of ESP8266?

Pick ESP8266 when a tutorial, a kit, or an existing project already uses it. The NodeMCU board is cheap, the core is stable, and the WiFi examples are short. Pick ESP32 when you need Bluetooth, more GPIO pins, more RAM, a second core, or a camera. ESP32 also has a larger flash and a faster CPU. The ESP8266 vs ESP32 comparison in this series gives the full side-by-side table. For a new project with no ESP8266 requirement, ESP32 is the better buy. For a first WiFi sensor on a tight budget, NodeMCU still does the job well.

Keep the ESP8266 core updated, but do not update it in the middle of a working project. A core update can change a library or a default and break a build that worked yesterday. Finish the project, then update the core and test again. Record the core version in your project notes. That habit saves hours when a build fails after an update. The same rule applies to the ESP32 core and to every library in the Library Manager.

Step-by-step: Arduino IDE ESP8266 setup and Blink upload

  1. Install Arduino IDE 2 and launch it.
  2. Open File, Preferences and add https://arduino.esp8266.com/stable/package_esp8266com_index.json to Additional boards manager URLs, then click OK.
  3. Open Tools, Board, Boards Manager, search for esp8266, and install esp8266 by ESP8266 Community.
  4. Restart Arduino IDE, then open Tools, Board, ESP8266 Boards, and select NodeMCU 1.0 (ESP-12E Module).
  5. Connect the NodeMCU board with a USB data cable and select the new port under Tools, Port.
  6. Open File, Examples, 01.Basics, Blink.
  7. Click Upload and wait for Done uploading in the output panel.
  8. Watch the on-board LED blink once per second. LOW turns it on, HIGH turns it off.
  9. Open File, Examples, ESP8266WiFi, WiFiScan, upload it, and read the network list in the Serial Monitor at 115200 baud.

NodeMCU D labels and GPIO numbers

Printed on board GPIO Notes
D0 16 No PWM or I2C. Used to wake from deep sleep
D1 5 Common I2C SCL pin
D2 4 Common I2C SDA pin
D3 0 Boot pin. Do not pull low at startup
D4 2 Built-in LED, active low. Boot pin
D5 14 Safe general purpose pin
D6 12 Safe general purpose pin
D7 13 Safe general purpose pin
A0 Analog only One analog input, 0 to 1023 read range

First code to run

Paste this sketch into a new sketch if the built-in Blink example is not listed. It is the same Blink logic, with the active-low LED wiring on NodeMCU explained in the comments.

// Blink for NodeMCU ESP8266 in Arduino IDE
// Board: NodeMCU 1.0 (ESP-12E Module)
// Library: none. Uses only the ESP8266 Arduino core.
// LED_BUILTIN is GPIO 2 (D4) on NodeMCU. The LED is active low.
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);  // Set the on-board LED pin as an output
}

void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // LOW turns the LED on (active low)
  delay(1000);                      // Wait 1000 ms (1 second)
  digitalWrite(LED_BUILTIN, HIGH);  // HIGH turns the LED off
  delay(1000);                      // Wait 1000 ms (1 second)
}

The on-board LED on NodeMCU is wired active low. Writing LOW turns it on. That is normal for this board, and it is not a fault.

Frequently asked questions

Which driver does a NodeMCU ESP8266 board need?

It depends on the USB chip on the board. The NodeMCU board in this guide uses CH340, so it needs the WCH CH341SER driver. Other NodeMCU boards use CP2102 and need the Silicon Labs CP210x driver. Read the chip marking near the USB port to pick the right driver.

Why is my NodeMCU LED on when the sketch writes HIGH?

The NodeMCU on-board LED is active low. HIGH turns it off and LOW turns it on. That is the board wiring, not a code error. Use LOW for on and HIGH for off in your sketch.

Can I use ESP8266 code on ESP32?

Most simple code ports with small changes, but WiFi libraries differ. ESP8266 uses ESP8266WiFi.h and ESP32 uses WiFi.h. Pin numbers and the analog read range also differ. Test a ported sketch on the new board before you trust it.

How many analog inputs does ESP8266 have?

One. The A0 pin is the only analog input, and analogRead returns 0 to 1023. ESP32 has more analog inputs, so pick ESP32 when a project needs two or more analog sensors.

Why does my ESP8266 reset when WiFi starts?

WiFi transmit draws a current burst that a weak USB port or a long cable cannot deliver. Use a short data cable and a port directly on the computer. A separate 5 V supply rated for at least 1 A fixes most WiFi reset cases.

Parts used in this guide

This guide uses the NodeMCU ESP8266 board with the 0.96 inch OLED display and the NodeMCU 6-pack linked below. Pick the NodeMCU 1.0 (ESP-12E Module) board entry for both.

Related guides

Sources

Last updated: 2026-11-21