loading

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 mcirco-python. And upload and run a few test programs.

Step 1: Tools and Components

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

Hardware Components

  • NodeMCU
  • BreadBoard
  • MicroUSB
  • LEDs
  • 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: The Arduino Style

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...

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 setup 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.

http://arduino.esp8266.com/versions/2.3.0/package...

Step 4: Arduino Uploading 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 Pyhton

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

https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html

Lets start with getting micropython running on the board, you can use nodemcu flasher tool to flash micropython on to you 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.

<p>NodeJS is a good microcontroller to get started with IoT (Internet of Things) related projects.</p><p>I think its not &quot;NodeJS&quot;.it should be &quot;NodeMcu&quot;</p>
Thank you for posting such a good tutorial
<p>Great tutorial and very clear photos :) Thanks for sharing!</p>
<p>Thank You, I'm glad you like it.</p>

About This Instructable

1,489views

54favorites

License:

Bio: I love DIY Electronics
More by teamlighthouse:Getting Started With the Particle Photon (Internet Controlled LEDs) Getting Started With NodeMCU (All in One Guide) 
Add instructable to: