Getting Started With NodeMCU

About: " Work until you no longer have to introduce yourself " Show some love on Instagram @it.is.prem & Motivate me on YouTube @TheCircuit

NodeJS is a good microcontroller to get started with IoT (Internet of Things) related projects. For less than 5 dollars, you get an Arduino compatible board with on board WiFi module. At the heart of the NodeMCU runs an ESP8266-12 SoC and It is programmed in its own language LUA script. LUA script is similar to programming with JavaScript, beside LUA it can also be programmed in C and Python.

In this instructable, I'm going to show you how to get started with creating projects with the NodeMCU. This instructable will show you how to program the NodeMCU using the Arduino IDE and micro-python. And upload and run a few test programs.

Step 1: Tools & Components Required

Here is the list of components required to get started with the NodeMCU,

Hardware Components

  • NodeMCU
  • BreadBoard
  • Micro USB cable
  • LED
  • 330 Ohm Resistor
  • A Cup of Coffee (Helpful when you wait for the Software tools to download)

Software Tools

  • Arduino IDE
  • LUA script Flasher

Step 2: Circuit

Before we start programming it lets get the hardware up and running, the circuit is very simple to build. All you need to do is connect the anode of the LED to digital pin 2 and the cathode to ground via a 220 ohm resistor, as shown in the picture. The circuit consists of one LED and a current limiting resistor connected in series with it.

The whole circuit is assembled on a breadboard hence no soldering skill are required. In the next few steps we will target uploading the code to the NodeMCU in 2 different tools and languages.

Step 3:

To get started we need to download the arduino IDE and some necessary drivers. The Arduino IDE can be downloaded via this link

www.arduino.cc

After downloading the Arduino IDE navigate to File => Preferences and in the additional boards URLs add the below URL

http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json

After that navigate to the Tools > Boards > Board Manager and scroll down the list till you can find ESP8266 click on it and then hit install. Now you have set up the Arduino IDE to work along with the node MCU. Additionally, you need to install the drivers if you are on a windows based computer. The drivers can be downloaded and install from the below link

https://github.com/nodemcu/nodemcu-devkit

Step 4: Uploading Your First Code

Once the driver is installed it is time to program the NodeMCU, for this select the NodeMCU 1.0 board from the Tools => Boards menu of the Arduino IDE.

Now need to find the specific port to which the NodeMCU is connected to the computer. This can be found in device manager. In Tools => Ports make sure you select the right port as seen before. Then Create a new sketch and paste the code below in the Arduino IDE and hit upload.

void setup() {

pinMode(LED_BUILTIN, OUTPUT); //Set the Built in LED to pin to act as an output pin
pinMode(16, OUTPUT); //Set the D0 to pin to act as an output pin

}

void loop() {

digitalWrite(LED_BUILTIN, LOW); //Turn off the LED
digitalWrite(16, LOW); delay(1000); // Wait for a second digitalWrite(LED_BUILTIN, HIGH);//Turn on the LED digitalWrite(16, HIGH); delay(1000); // Wait for a second

}

The code will take a few minutes to upload and Then you should see the LED blink at the interval set in the code.

Step 5: Programming in Python

The NodeMCU doesn't support a full python installation hence there is a smaller distribution of python named as micro python which is based on Python3. So you get all the basic functionality of Python3 on nodeMCU. You can learn more about micro python from the below URL.

Micropython Docs

Let's start with getting micro python running on the board, you can use NodeMCU flasher tool to flash micro python on to your board. NodeMCU flasher tool can be downloaded from here. After flashing it use putty or any other serial monitor to open the right com port and now you should have a python terminal open you can python commands via this shell.
Note:

Here are the official ESP8266 Arduino integration boards manager instructions:

https://github.com/esp8266/Arduino#installing-with-boards-manager

Specifically, there is a `stable` URL for ESP8266 packages:

http://arduino.esp8266.com/versions/2.4.2/package_esp8266com_index.json

If you have any queries, feel free to leave a comment below or PM me and I would try to help you.

Share

    Recommendations

    • Classroom Science Contest

      Classroom Science Contest
    • Frozen Treats Challenge

      Frozen Treats Challenge
    • Fandom Contest

      Fandom Contest

    Discussions