How to use NodeMCU with Arduino IDE for programming?

In the era of science and technology, we all want our work to be automatically done without us to be involved in the process. For that we have the automation systems that helps us to finish our work with the ease. For the process of automation we have different control units with us that will automate all our tasks and one of these kind of controlling unit is NodeMCU. To make the automated device you need to write a program to control your appliances and to program your NodeMCU you need a compiler that will read/write the program according your your task and the one we will use in this post is Arduino IDE which is a compiler for your Arduino board.

In this post you will learn how to write a program for NodeMCU in Arduino IDE to write a program for your NodeMCU in an easier and effective way and also you will write your first program to test the blinking of LED using NodeMCU using Arduino IDE.

Getting Started

Firstly we will start by adding the link that will show you an option to download NodeMCU board to Arduino IDE because when you will open Arduino IDE for the first time to select the board as NodeMCU, you will not get any board option for NodeMCU. So, we have to downoad it and then use it.

Setting up the URLadd NodeMCU

To download the board manager for NodeMCU follow the steps.

Go to File > Preferences  and you will see a window like this :

and in this window you have to add a link in the option "Additional Board Manager URLs" which is as given:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

After adding the link click "OK". Now you have added the link to add the additional board manager. Now, your next step is to download the board manager and for that go to: Tools > Board >Board Manager...

and a new window will open on your screen something like this:

After you will get this window now search for NodeMCU in the search field as shown here and now you will get the below options in the window you have on your screen. Now, clock on the option you can see and click install to install the board manager for NodeMCU.

This will take some time to download the board manager and when it's done click on "Close" and go to Tools > Board  and search for NodeMCU options. If you are able to see the options that means you have successfully installed the NodeMCU Board on Arduino IDE. If in case you are not able to see the options on your screen then repeat the steps above and try again. Also check the video here to see the practical setup of the board manager for NodeMCU.

Writing your first program

After the successful installation of the board manager for NodeMCU try the below code for the blinking of LED to check that your NodeMCU is working or not. First write the below code in a new file, for that go to File  > New

and now write the below code to test the blink of LED on the by default connected LED of NodeMCU connected to pin D4.

#define LED_BUILTIN D4

void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

When you are done with the program now it's time to upload your code to NodeMCU to test the working of your NodeMCU and LED blinking program.

Go to  Tools  >  Board >"NodeMCU 0.9 (ESP-12 Module)"

and also connect your NodeMCU to your system and go to  Tools  > Port >"select the port that you will see after connecting your NodeMCU"

Now click on "Upload" button and your program will start uploading to NodeMCU and when it's done you will notice the blinking of LED on your NodeMCU.

I hope everything was clearly mentioned in this post but still if you are facing any difficulty in the setting up or writing the first program then leave a comment below in the comment section.

1 thought on “How to use NodeMCU with Arduino IDE for programming?”

Leave a Reply

Your email address will not be published. Required fields are marked *