Using WiFi in your next projects with the NodeMCU - Introduction
- 03 Feb, 2017
Being able to control or get information from your projects using WiFi is something that we all want to experiment with at some time or another.
An easy way to start, is using a development board that has WiFi built into it like the NodeMCU dev boards.
The NodeMCU is built around the popular ESP8266 WiFi module. Using the NodeMCU makes it easy to connect and use the capabilities of the ESP8266 as well as use the Arduino IDE we are familiar with to upload sketches.
As we make more tutorials using the NodeMCU boards we will go into more details on how these work, what inputs and outputs are available and the different ways you can program them.
In this first part we will control a Pixel stick (WS2812B) through a webpage to turn on and off, change the colours and we will use the Arduino IDE to program the NodeMCU.
We will be looking at two versions of the NodeMCU board: Version 2 and Version 3:
As you can see from the picture above, Version 3 (top) is a little bigger than Version 2 (bottom), also V3 of the NodeMCU board uses the CH340G USB to serial chip compared to V2 which uses the CP2102 serial chip.
Doesn’t make much of difference which one is used as long as you load the correct driver.
Version 2 also includes an extra LED onboard.
The pin out of both boards are pretty much the same except that V3 has one more Ground pin and also provides a USB power Out pin as you can see in the diagram below.
The connection for this tutorial are pretty minimal as you can see from the schematic.
To power the WS2812 Pixel Stick, we are using the 3.3V and GND pins of the NodeMCU.
The RX pin or D9 of the NodeMCU is connected to the D1 (Digital In) of the WS2812 Pixel Stick.
*Note: Since we are only using one WS2812 Pixel Stick we can power it using the NodeMcu.
In future tutorial we will use an external power supply since we will be using more LEDs..
We are using the NeoPixelBus library to control the WS2812 RGB Pixel stick.
You can find a link to download the library at the bottom of this tutorial page.
To install the NodeMCU board in the Arduino IDE you will need to go to:
FILE –> PREFERENCES — >
and add the following information in “Additional Boards Manager URLs:”
The code below will connect to a WiFi network and then create a webpage that will have 2 buttons to select which colors you want to display.
Remember to replace the “xxxxxxx” in the code with your own WiFi network name and password.
You can open the Serial Monitor windows at startup to see which IP is given to the NodeMCU by the WiFi network.
We will go into more detail and complexity in future tutorials using the NodeMCU.
As always, Don’t forget to watch our Tutorial video for more information.
Copy the above Sketch code in your Arduino IDE software to program your NodeMCU board.
Download The NeoPixel Library
created by ‘Makuna’ :
Once downloaded, just extract the content of the zip files inside your “arduino/libraries” folder, and make sure to restart the Arduino IDE (Close and Reopen) software so it detect this newly installed library.