Maker Portal

View Original

NodeMCU Tutorial Series Part I: Arduino IDE and Blinking an LED

See this content in the original post

See this content in the original post

With the inclusion of NodeMCU, we no longer need a dedicated Arduino board. Instead, the ESP8266 SoC is fully integrated to handle microcontroller tasks so that all we need to create a WiFi-enabled node is a board and the Arduino IDE. The NodeMCU platform is inexpensive and popular, which means plentiful documentation and resources. This allows users to dive right into applications without worrying about the specifics of complex communication involved in WiFi-connected devices. If you want to read more about the specifics of NodeMCU, see one of the following resources:

See this content in the original post

This is the first entry into the exploration of NodeMCU, which will cover the board specifics, programming in the Arduino IDE, and a simple blink sketch.


See this content in the original post

The minimum hardware components needed for getting started with NodeMCU are: a NodeMCU board and a computer capable of handling the Arduino IDE. That’s it! However, I will be using a few external components that will indicate whether the microcontroller in the NodeMCU board is functioning properly and responding to Arduino commands as we expect it to. The parts list for this tutorial is as follows (with affiliate links):

  1. NodeMCU ESP8266 Board - $12.00 [Our Store]

  2. Raspberry Pi (or computer with Arduino IDE) - $38.40 [Amazon]

  3. LED - $9.95 (600 pcs) [Amazon]

  4. Resistor (100-1000 Ohm) - $10.86 (525 pcs) [Amazon]

  5. Jumper Wires - $0.30 (2 pcs) [Our Store]

  6. Mini Breadboard - $3.00 [Our Store]

See this content in the original post

The LED will be wired to pin D1 (GPIO 5) on the NodeMCU board, which we will program later to change state with a random interval between each on and off state. A pinout diagram for the NodeMCU is shown below for reference:

Image courtesy of: https://www.teachmemicro.com/nodemcu-pinout/

We will stick to using the available GPIO pins, but identify them with traditional Arduino D/A pins for referencing. In our case, we use D1 for GPIO 5. The wiring for the LED is shown below for D1:

In the next section, I will demonstrate the process involved in downloading the NodeMCU board framework onto the Arduino IDE and preparing the IDE to handle NodeMCU boards.


See this content in the original post

The ESP8266 community has spent a lot of time developing NodeMCU for the Arduino framework. Below, I outline the steps needed to download the board software for ESP8266 boards (NodeMCU) and how to program the board parameters to handle the specific NodeMCU 1.0 version referenced above.

After our NodeMCU 1.0 board is selected and the parameters match those above in step 5, we can finally upload a sketch to the board and emulate an Arduino board!

See this content in the original post

See this content in the original post

Uploading a sketch to a NodeMCU board is nearly identical to any Arduino board. You program in the IDE, and select ‘Upload.’ The NodeMCU board takes a bit more time than an Uno or Nano board, but much of the programming is identical in function. In our case, we will test that the board is being properly programmed by uploading a sketch that controls an LED on digital pin 1 (D1, GPIO 5). Scroll up to look at the pinout of the NodeMCU and verify that your board looks similar and has similar markings on the pins.

Copy and paste the code below and click ‘Upload.’

See this content in the original post

If everything was successful and you see ‘Done uploading’ without any errors in the IDE - then your NodeMCU as an Arduino board was successful!

Below is what you should see from the uploaded code above:

See this content in the original post

See this content in the original post

In this entry into the NodeMCU tutorial series I introduced the NodeMCU board and programming in the Arduino IDE. I demonstrated how to wire and program a NodeMCU board like an Arduino board to control an external LED. I have only scratched the surface of the NodeMCU framework and will continue the series by exploring the WiFi capabilities of the onboard ESP8266 chip, which will allow us to create multi-functional web-based applications like sensor nodes, independent servers, and WiFi control systems - all using an inexpensive, open-source NodeMCU board used in this tutorial.

See this content in the original post

See More in NodeMCU and IoT:

See this content in the original post