Getting Started with NodeMCU using Arduino IDE

Writing sketch for NodeMCU using Arduino IDE.

69.2k views2 min readUpdated Aug 8, 2023
Getting Started with NodeMCU using Arduino IDE

Introduction

NodeMCU is Lua based firmware of ESP8266. Generally, ESPlorer IDE is referred for writing Lua scripts for NodeMCU. It requires to get familiar with ESPlorer IDE and Lua scripting language.

There is another way of developing NodeMCU with a well-known IDE i.e. Arduino IDE. We can also develop NodeMCU applications using the Arduino development environment. This makes things easy for Arduino developers than learning a new language and IDE for NodeMCU.

Let’s see about setting up Arduino IDE with NodeMCU.

First Download Arduino IDE (version 1.6+) https://www.arduino.cc/en/Main/Software

  • Open Arduino IDE and Go to File -> Preference.
Arduino IDE preferences
  • Now on the Preference window, Enter below link in Additional Boards Manager URLs

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

Arduino IDE Preferences window
  • Now close the Preference window and go to Tools -> Board -> Boards Manager
Arduino IDE Board manager option
  • In the Boards Manager window, Type esp in the search box, esp8266 will be listed there below. Now select the latest version of the board and click on install.
Arduino IDE Board manager window
  • After installation of the board is complete, open Tools->Board->and select NodeMCU 1.0(ESP-12E Module).
Arduino IDE select board
  • Now Your Arduino IDE is ready for NodeMCU

Example

Let’s see how to write a simple serial print sketch using Arduino IDE for NodeMCU.

First, connect NodeMCU Development Kit with PC as shown in the below figure.

NodeMCU connection with PC
NodeMCU connection with PC

 

  • After setting up Arduino IDE for NodeMCU, open Arduino IDE and write a simple sketch of serial print as shown in the below figure.
Arduino Serial sketch

Arduino Sketch

void setup() 
{
	Serial.begin(9600);  /* initialise serial communication */
}

void loop()
{
	Serial.println("ElectronicWings"); /* print Electronic Wings at new line per second */
	delay(1000);
}
  • Ensure that you have selected the correct board as shown in the below figure. Also, make sure that you have selected the appropriate COM port.
Arduino IDE board NodeMCU
  • Now compile & upload the written sketch directly to the NodeMCU DevKit by clicking on the upload button.
uploading arduino sketch
  • Now Click on the Serial Monitor (upper right corner) option to check the output on the serial monitor window of Arduino IDE.
Arduino serial monitor
  • The serial monitor output window will pop up with output as shown in the below figure.
output window

Components Used

Powered byMouser Electronics

Comments13

Join the discussion — share a question or tip.

  • PR
    PriyalAggarwal

    how to fix this error File extension '.bin' not recognized in PROGRAM property. Real Time Simulation failed to start.

  • PR
    PriyalAggarwal

    how to upload arduino ide file in esp8266 in proteus stimulation

  • MO
    MohamedFEZARI

    good tutorial

  • PR
    prachibansode12

    its working and thank you so much

  • JE

    Hi Sir, I tried connecting Arduino with ESP 8266. All the connections are correct but I was not getting the signal ( blue light not glowing ). Please help me find a solution for the issue. http://bigbelectronics.in/product.php?product=nodemcu-esp8266-cp2102-nodemcu-wifi-serial-wireless-module

    • MU
      muhammedimdaad16

      change the cable

    • NI
      nileshku

      Check the chip on NodeMCU. I am using Mac to connect Node MCU with CP2102. I had to install USB driver for CP210x separately. Once installed Choose right board and then Choose SLAB_USBtoUART in port. Link as below https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

  • AD
    adityakolekar143

    Hello,it shows error in boards manager window "Error downloading https://gitHub.com/esp8266/Arduino/releases/download/2.5.2/esp8266-2.5.2.zip What should I do now ??

    • HA
      hatemrabee

      hi jeevankumarvatturi, you have to exit anti virus

  • HA
    hatemrabee

    hi how could fix that error ? : cannot open linker script file local.eagle.app.v6.common.ld: No such file or directory collect2.exe: error: ld returned 1 exit status Error compiling.

    • AU
      authorized

      did you see this error in arduino ide ?

    • HA
      hatemrabee

      Replying to @authorized

      yes

    • HA
      hatemrabee

      Replying to @authorized

      Sorry, I have to download Arduino IDE (version 1.6+) to fix that error . Thanks