Using NodeMCU with Arduino IDE

In this blog we will see how to use NodeMCU with Arduino IDE. Once you are done with the setup you will be run arduino sketches on NodeMCU. First we need to setup the IDE.

we need to add the NodeMCU to board manager.

Goto File->Preferences and paste the following URL in additional board manager URL

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

Then goto Tools->Board->Board Manger

You should entry for ESP

Click on esp8266 entry , you will get option to install it. Once the installation is completed , you will have new boards in the board selection menu.

Now we can run the blinking LED program on NodeMCU.

void setup() {
// initialize digital pin D3 as an output.
pinMode(0, OUTPUT);
Serial.begin(115200);
Serial.println("App started");
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Nodemcu pinmapping

In case of NodeMCU , the pin numbers does not match with the pin numbers on NodeMCU. Here is the mapping between Arduino code and NodeMCU (the nodemcu onboard led pin is D0,means you need to write to pin 16 like digitalWrite(16,HIGH))

NodeMCU to Arduino program – Pin Mapping

Code for Blinking NodeMCU On BoardLED:

void setup() {
// initialize digital pin LED PIN as an output.
pinMode(16, OUTPUT);// you can also use D0
}
void loop() {
digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(16, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}