For some time I have been posting tutorials around Arduino. It is a very easy to use and versatile microcontroller, but there are many options out there one of them being ESP dev boards. In this tutorial, we will learn particularly about ESP8266 NodeMCU. Before getting started, let’s learn more about this amazing board.
Introduction to ESP8266 NodeMCU:
NodeMCU (ESP8266) is a low cost microcontroller with built-in WiFi functionality. It is just like an Arduino but a bit more powerful. Here is a technical specification:
- NodeMcu Lua ESP-12E WIFI Development Board
- Wireless 802.11 b/g/n standard
- Support STA / AP / STA + AP three operating modes
- Built-in TCP / IP protocol stack to support multiple TCP Client connections (5 MAX)
- D0 ~ D8, SD1 ~ SD3: used as GPIO, PWM, IIC, etc., port driver capability 15mA
- AD0: 1 channel ADC
- Input: 4.5V ~ 9V (10VMAX), USB-powered
- Current: continuous transmission: ≈70mA (200mA MAX), Standby: <200uA
- Transfer rate:110-460800bps
- Support UART / GPIO data communication interface
- Remote firmware upgrade (OTA)
- Support Smart Link Smart Networking
- Working temperature: -40 ℃ ~ + 125 ℃
- Drive Type: Dual high-power H-bridge driver
ESP boards are very useful for wireless projects as it has WiFi connectivity. Home automation, Weather station and Robotics are some of the areas where this dev-board can be useful.
Let’s see what we need to start using this projects…
Setting Up The IDE:
Before being able to upload codes to ESP board, we need to prepare the Arduino IDE by installing the boards and proper libraries.
- First open the Arduino IDE.
- Goto >> Files >> Preferences and paste following Links in “Additional board manager URL’s”
- Click ok, Now Goto >> Tools >> Board >> Board Manager.
- Scroll down to find ESP8266 and click on install.
This will add all the ESP boards to the IDE.
Now to recognize the Board in a computer you have to install CP210X Drivers. It is very simple. Just visit the link and download the version compatible with your device.
Now you have to select the correct board, Here I have used NodeMCU 1.0 (ESP-12EModule).
- Goto >> Tools >> Board >> NodeMCU 1.0
After selecting the board, make sure the settings are set as bellow:
- Flash Size : “4M (3M SPIFFS)”
- Debug Port : “Disabled”
- Debug Level: “None”
- IWIP Variant: “V2 Lower Memory”
- CPU Frequency: “80Mhz”
- Upload Speed: “921600”
- Erase Flash: “Sketch On”
- Port : “COM port available” (where the device is connected should show up)
Now we are ready to upload codes to ESP board.
Uploading The Sketch:
Now that the IDE is setup for NodeMCU you can test it by uploading an Example sketch as follows:-
- In IDE Goto >> Files >> Examples >> ESP8266
- Select the Blink Example and upload it.
The on board LED should start to blink. That means you successfully programmed the board. The on board LED is connected to pin D0 of NodeMCU. You can add external LED to Pin D0.
Now for you to work with NodeMCU you have to know the pin outs and Arduino to ESP8266 Pin mapping.
Here I have listed the NodeMCU’s pin and corresponding Arduino pins:
- D0 = 16
- D1 = 5
- D2 = 4
- D3 = 0
- D4 = 2
- D5 = 14
- D6 = 12
- D7 = 13
- D8 = 15
- D9 = 3
- D10 = 1
So to use pin D0 of NodeMCU you have to use Pin 16 in Arduino IDE.
If you have any doubts, you can ask in the comments below.