Blink LED with NodeMCU

Description:

Node-MCU is an open source IoT platform. It includes firmware which runs on the ESP8266 WiFi -SoC from Express if, and hardware which is based on the ESP-12 module. The term “Node-MCU” by default refers to the firmware rather than the dev kits. The firmware ESP8266 uses the c/c++/Lua scripting language. It is built on the  ESP8266. It uses many open source projects. LUA based interactive firmware for Express if ESP8622 Wi-Fi-SoC, as well as an open-source hardware board that contrary to the $3 ESP8266 Wi-Fi modules includes a CP2102 TTL to USB chip for programming and debugging, is breadboard-friendly, and can simply be powered via its micro USB port.

Features:

  • Wi-Fi Module – ESP-12E module similar to the ESP-12 module but with 6 extra GPIOs.
  • USB – micro USB port for power, programming and debugging
  • Headers – 2x 2.54mm 15-pin header with access to GPIOs, SPI, UART, ADC, and power pins Misc – Reset and Flash buttons
  • Power – 5V via micro USB port
  • Dimensions – 49 x 24.5 x 13mm

Before programming NodeMCU open the Arduino-IDE
Go to files and click on the preference in the Arduino IDE

copy the below link in the Additional Boards Manager URLs:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

click OK to close the preference Tab.

After completing the above steps, go to Tools and board, and then select board Manager

Navigate to esp8266 by esp8266 community and install the software for Arduino. Once all the above process been completed we are ready to program our esp8266 with Arduino IDE.

Note:

For this example, I have used Node-MCU esp8266 and if you are using any other vendor wifi chips or generic wifi module please check with the esp8266 Pin mapping which is essential to make things works.

The reason why I used the D7 pin for this example is, I uploaded the basic blink program that comes with the examples program in the Arduino IDE which is connected with 13 pins of Arduino. The 13th pin is mapped into the D7 pin of Node-MCU.

Go to the board and select the type of esp8266 you are using. and select the correct COM port to run the program on your esp8266 device.

Step 1: Material Preparation:

Before you are getting started, prepare all the item needed:

  1. Breadboard
  2. ESP8266 Node-MCU
  3. LED
  4. Jumper (if needed)
  5. micro USB

Step 2: Pin Connection

This is one of the most simple connection and suitable for a beginner. What u need is to connect LED’s anode to ESP8266’s GND pin and LED’s cathode to ESP8266 D1.

Step 3: Source Code

1
Blink LED Using ESP8266 Node-MCU
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Note that this sketch uses BUILTIN_LED to find the pin with the internal LED

*/

#define BUILTIN_LED 5

void setup() {

pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level

// but actually the LED is on; this is because

// it is acive low on the ESP-01)

delay(1000);                      // Wait for a second

digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH

delay(1000);                      // Wait for two seconds (to demonstrate the active low LED)
1
}

Step 4: Uploading

When you have successfully built your connection the on breadboard and write coding, you have to upload the coding into the ESP8266 by using a micro USB. Before uploading the coding, you have to install esp8266 into your Arduino IDE.

Result

Leave a Reply