Esp8266 community created an add-on to help the maker program the esp8266 board using Arduino IDE and its programming language. This tutorial shows how to install the ESP8266 add-ons in Arduino IDE in windows and Mac os or Linux systems.


Prerequisites: Arduino IDE Installed


To use Arduino IDE to program the NodeMCU, you first have to install Arduino IDE in your system. you can download it from the Arduino community website.
Make sure that you installed the latest Arduino IDE

Do you need an ESP8266 board? You can buy it here.

Install Nodemcu-ESP8266 Add-on in Arduino IDE

  • First open the Arduino IDE and go to File > Preferences. On the Additional Boards Manager URL, paste the following URL and click OK.
https://arduino.esp8266.com/stable/package_esp8266com_index.json
Preference
  • Now go to Tools > Board > Boards Manager >
boardmanager
<gwmw style=displaynone>
  • Search “ESP8266” > Install “esp8266 by ESP8266 community”
esp8266 addon instaltion
  • After installing, go to Tools > Board > ESP8266 boards (2.7.1) > Select “NodeMCU 1.0 ESP-12E Module”

Now you have set your board as NodeMCU ESP8266.

choose nodemcu
<gwmw style=displaynone><gwmw>

Testing the Installation


To test the ESP8266 add-on installation in Arduino ide, we can blink the onboard LED with esp8266 using the Arduino programming language. In all the ESP8266-Nodemcu board, an onboard LED is connected to Digital Pin 4, commonly called GPIO02.

Parts required

Here the hardware items required to complete this testing are:


1.ESP8266 -Nodemcu board

2. USB cable for Connection

Uploading the Sketch


Uploading the program in Nodemcu esp8266 is relatively straightforward. Since it has a built-in programmer, plug the nodemcu into your computer. Then open Arduino IDe and go to Boardmanager > choose the right board named NodeMCU.


Then Again, go back to Boardmanager and choose the port to which nodemcu is connected.


Then copy the code and paste it on the ide.

#define LED D4           // Led in NodeMCU at pin GPIO2 (D4).
void setup() {
pinMode(LED, OUTPUT);    // LED pin as output.
}
void loop() {
digitalWrite(LED, HIGH);// turn the LED off.(Note that LOW is the voltage level but actually 
                        //the LED is on; this is because it is acive low on the ESP8266.
delay(1000);            // wait for 1 second.
digitalWrite(LED, LOW); // turn the LED on.
delay(1000); // wait for 1 second.
}


Click on the verify button of the Arduino ide, and in a few seconds, the code will verify and shows no error. If any error comes, check the code once again. The most common errors are spelling mistakes and missing some semicolons.


Next is you need to click the upload button. It will upload the program to NodeMCU and wait for a few seconds until you see the message Done uploading on the bottom corner left.

Troubleshooting common errors in esp8266-Nodemcu


If you try to upload a new program /sketch to your nodemcu board, you get an error message like “esptool.FatalError: Failed to connect to ESP8266“: Timed out waiting for packet header” this denotes that your esp is not in the flashing mode.

Check the board manager if the board is chosen accurately and com port is selected.

  • Hold the boot/flash button in Nodemcu development board
  • Press the upload button inthe Arduino IDE to upload in yoiur sketch

author avatar
Amith G Nair
Experience as a product developer, innovation coach, and electronics lecturer,a seasoned professional driven by passion for designing projects.expertise extends to 3D modelling, hardware designing, and web development using HTML, WordPress, and Django.