This article is the base on the Internet of things (IoT). IoT describes the network of physical objects—“things” or objects—that are embedded with sensors, software, and other technologies for the purpose of connecting and exchanging data with other devices and systems over the Internet. In this article 3 LEDs will be controlled by an android application (made using Blynk) over a wifi connection.
How to use NodeMCU with Blynk
If you want to start learn the Internet of Things (IoT) concept, then controlling a LED over the internet is the " Hello World!" of the IoT journey. Performing the " Hello World" task will be easy using NodeMCU micro-controller as the first client and Blynk as the 'broker' or server and Blynk android application as the second client. Now communication between two clients will happen through broker over the internet. Now lets, make this happen.
Components Required
For this activity we will need following components:
- NodeMCU ESP8266
- Bread Board
- Jumper Wires
- Resistor (320 Ohm)
- LED
- 5V Power Supply
- Smart Phone
You can purchase the above components using the link given from Amazon.
Circuit Diagram
Before Moving further in the tutorial, lets prepare the circuit diagram as per the image given below. Two Circuit diagram has been shown below - one is showing the power input to NodeMCu through USB connected with computer; while another one showing the power input to NodeMCU at Vin Pin using +5V DC Power Source.
Fig 1: Circuit Diagram for LED with NodeMCU (For power connected to computer using USB) |
Fig. 2: Circuit Diagram for LED with NodeMCU (Power at Vin using 5V DC Power Source) |
Preparing Arduino IDE for NodeMCU
Now we have to install NodeMCU ESP8266 board and Wifi Library in the board manager and Library of our Arduino IDE respectively. If you have done these steps before then leave this step.
Installing NodeMCu Board Manager in Arduino IDE
- Open Arduino IDE in your computer.
- Go to: File > Preferences
- Then paste the Following link in the "Addition Board Manager" option and click OK:
Link :
https://arduino.esp8266.com/stable/package_esp8266com_index.json
Installing Libraries in Arduino ID
Creating Account on Blynk
Next step is to creating profile on Blynk and getting the various credentials. We, also have to set the various parameters along with installing the Blynk Android Application.
After login create New Device on Blynk.cloud, on adding the New Device you will get Authorization code along with Template ID. This detail will be used at the top of code.
Creating Profile on Blynk Web Portal
Visit the Blynk web portal using the link - Blynk. Sign Up using the email ID and then login. Open the Quickstart Template.
After opening quickstart template, we will get firmaware configuration detail, this detail has to be copy and pasted at the begining of our Arduino Code.
we have to manage on two parameters for this tutorial:
Data Stream
Web Dashboard
Define a pin type for the LED Control by creating a Virtual Pin name as LED in the data stream as shown in figure below.
Web Dashboard: Similarly Prepare the Dash board by creating a ON - OFF Switch and assigning it the Virtual Pin - LED, as shown in figure below.
Now, We have completed the Blynk application or Web dashboard part. Next step is to prepare the Arduino code for this project and upload it on the NodeMCU board and check the working.
Arduino Code
At starting of the code we have to add Template ID, Device Name and Auth Token are provided by the Blynk.Cloud (See the Device Info tab, or Template settings).
#define BLYNK_TEMPLATE_ID "XXXXXXXXX"
#define BLYNK_DEVICE_NAME "XXXXXXXXX"
#define BLYNK_AUTH_TOKEN "XXXXXXXXX"
Next you have to add the following libraries in Arduino IDE: ESP8266WiFi.h, BlynkSimpleEsp8266.h, and Arduino.h
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino.h>
Next you have to add your WiFi SSID and Password details. You Can comment below for the complete code.
Now we are fully ready and lets see the working of our project.
Comments
Post a Comment