ESP8266 NODE MCU LED Blink

by Ramatronics Laboratory in Circuits > Microcontrollers

1446 Views, 5 Favorites, 0 Comments

ESP8266 NODE MCU LED Blink

WhatsApp Image 2023-04-07 at 12.17.03 PM.jpeg
WhatsApp Image 2023-04-07 at 12.27.34 PM.jpeg
WhatsApp Image 2023-04-07 at 12.27.35 PM.jpeg
WhatsApp Image 2023-04-07 at 12.27.36 PM.jpeg

INTRODUCTION:

Hello everyone!. Today in this instructables, I am going to introduce you about a more special microcontroller with wifi support. This microcontroller is ESP8266. most of you would have heard about this also. ESP8266 is a microcontroller which has wifi capability so you can control your projects form anywhere in the world using internet. Sounds awesome right. There are many ESP8266 based microcontroller boards available in the market but the one which is most popular and used is ESP8266 Node Mcu. One of the advantages of using this board is that we can program it using different high level programming languages i.e. C, C++, Micro Python and Circuit Python. In this project, I am going to use Micro Python high level programming language to program the ESP8266 Node Mcu board. I will make a simple Micro Python program to blink the on board LED of ESP8266 Node Mcu. I shall also blink an external LED. So let's get started.

Supplies

WhatsApp Image 2023-04-07 at 12.24.06 PM.jpeg
WhatsApp Image 2023-04-07 at 12.27.36 PM.jpeg

List of the Electronic components and Hardware:



https://quartzcomponents.com?sca_ref=3671286.DzEptz4I3w

ESP8266 Node Mcu

https://quartzcomponents.com/products/nodemcu-development-board?_pos=2&_sid=e28dbbfed&_ss=r

Bread Board

https://quartzcomponents.com/products/colored-breadboard-mb-102-830-point?_pos=1&_sid=474dc121a&_ss=r

Jumper Wires

https://quartzcomponents.com/products/65pcs-breadboard-jumper-cable?_pos=7&_sid=87f214f85&_ss=r

LED(color = Red, Size = 5mm)

https://quartzcomponents.com/products/red-5mm-led?_pos=1&_sid=cca959799&_ss=r

Resistor - 330 Ohm

https://quartzcomponents.com/products/330-ohm-1-4-watt-resistor-with-1-tolerance-pack-of-10?_pos=2&_sid=0eea45bca&_ss=r

Micro-B USB Cable.

https://quartzcomponents.com/products/raspberry-pi-cable-for-charging?_pos=1&_sid=243da5802&_ss=r


https://www.amazon.in/?

ESP8266 Node Mcu

https://www.amazon.in/JacobsParts-NodeMCU-ESP8266-ESP-12E-Development/dp/B07WBVCVB4/ref=sr_1_1_sspa?crid=2UO6IWIVN0SNV&keywords=esp8266&qid=1680840598&sprefix=esp8266%2Caps%2C333&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&th=1

Bread Board

https://www.amazon.in/OLatus-Ol-Breadboard-Gl-Points-Solderless-Circuit/dp/B06XZ54VTN/ref=sr_1_4_sspa?crid=2FTLKFDUVHKA9&keywords=breadboard&qid=1680840638&sprefix=Bread%2Caps%2C312&sr=8-4-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

Jumper Wires

https://www.amazon.in/INVENTO-Solderless-Flexible-Breadboard-Arduino/dp/B07PGHD2M8/ref=sr_1_39?crid=3PILBS3H9XYBA&keywords=jumper+wires&qid=1680840688&sprefix=jumper+w%2Caps%2C1049&sr=8-39

LED(color = Red, Size = mm)

https://www.amazon.in/LED-3MM-Red-100-pcs/dp/B09Z8F9WCW/ref=sr_1_13?crid=1645QG8IT7QUB&keywords=red+led&qid=1680840734&sprefix=red+led%2Caps%2C1357&sr=8-13

Resistor = 330 Ohm

https://www.amazon.in/0-5W-METAL-FILM-RESISTOR-PACK/dp/B08K99DJJP/ref=sr_1_14?crid=3RJNGATINFGB1&keywords=330+ohm+resistor&qid=1680840781&sprefix=330+ohm+resist%2Caps%2C1475&sr=8-14

Micro-B USB Cable

https://www.amazon.in/boAt-Micro-USB-Tangle-Free-Transmission/dp/B08WRWPM22/ref=sr_1_9?crid=UJL59UMQDQ7I&keywords=usb+cable&qid=1680840872&sprefix=usb+ca%2Caps%2C1584&sr=8-9

Downloading and Installing Thonny IDE

Thoony.png

Thonny is an integrated development environment (IDE). Which is use to program program microcontroller boards that supports Micro Python and Circuit Python programming languages. It is easy to use for beginners. You can download the latest version of Thonny from the link given below:

https://thonny.org/

Downloading and Installing CP2102 USB Driver

Driver.png

ESP8266 Microcontroller does not support USB interface, so The ESP8266 Node Mcu uses either CH340G or CP2102 Chip to connect ESP8266 to computer. I have provided the link below to download the Driver for both Chips:

Download driver for CH340 Chip:

https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all


Download driver for CP2102 Chip:

https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers

Downloading & Installing the Firmware on ESP8266 Node Mcu

image2.png
image1.png

You can download the latest version of ESP8266 Micro Python firmware from the link given below:

https://micropython.org/download/esp8266/

To program the ESP8266 Node Mcu with Thonny IDE, first we need to install the Micro Python firmware on ESP8266. For proper installation of firmware follow the given steps:

Connect ESP8266 Node Mcu to your computer. Run Thonny IDE on your computer and click on 'Tools' then choose 'options...' further click on interpreter. Now two options will appear on the IDE. In the first option, we have to select the MicroPython(ESP8266). In second option we have to choose the COM port on which our ESP8266 Node Mcu is connected to.

At the bottom you will see this option:- 'Install or update MicroPython'. click on this option and then again choose the PORT of your ESP8266 Node Mcu and in the second option we have to choose the location of the folder in which we have saved the ESP8266 Node Mcu firmware. Now just click on install option and firmware starts installing on the ESP8266.

After successfully installation of firmware you will be able to see this

MicroPython v1.19.1 on 2022-06-18; ESP module with ESP8266 Type "help()" for more information.

in the shell area of your Thonny IDE. Now type print('hello word') in the shell area and click enter and then ESP8266 prints hello world in the next line. This indicates that everything is working properly. Now we are ready to write and run the blink script on the ESP8266 Node Mcu board.

You can also download the firmware from my GitHub repository:

https://github.com/ramjipatel041/ESP8266-Node-Mcu

Blink the Onboard LED

WhatsApp Image 2023-04-07 at 12.22.09 PM.jpeg
WhatsApp Image 2023-04-07 at 12.22.10 PM.jpeg

The ESP8266 Node Mcu has two on board LEDs. The following Micro Python script blinks the on board LED connected on GPIO-2 Pin.

from machine import Pin
import utime

led = Pin(2, Pin.OUT) #configure GPIO-16(D4) pin as output

while True:
  led.value(1)    #set led pin high
  utime.sleep(1)  #delay for 1 second
  led.value(0)    #set led pin low
  utime.sleep(1)  #delay for 1 second


Making Circuit on Bread Board

NodeMCU-Pinout-Image.jpg
Node MCU LED Blink_bb.jpg
WhatsApp Image 2023-04-07 at 12.18.32 PM.jpeg

Fix the ESP8266 and LED on the bread board as shown in the figures. Connect the cathode of the LED to the GND pin of the ESP8266 Board. Further connect the Anode of the LED to DO pin of ESP8266 with a 330 Ohm Resistor in series. Now connect the ESP8266 to computer using USB cable.

Blinking an External LED

WhatsApp Image 2023-04-07 at 12.18.11 PM.jpeg
WhatsApp Image 2023-04-07 at 12.17.03 PM.jpeg

To blink an external LED, I connect a 5mm Red led on GPIO-16 (D0) along a 330 Ohm resistor in series. Now write the following Micro Python script and run:

from machine import Pin
import utime

led = Pin(16, Pin.OUT) #configure GPIO-16(D0) pin as output

while True:
  led.value(1)    #set led pin high
  utime.sleep(1)  #delay for 1 second
  led.value(0)    #set led pin low
  utime.sleep(1)  #delay for 1 second