You are on page 1of 11

IIOT PRACTICAL

BLYNK CLOUD PRACTICAL


1.Problem Statement:
In this project we will learn how to control an LED using Blynk IoT mobile app and also via
the Blynk web dashboard.
Introduction:
In this programme we show how to control and LED using Blynk IoT software using the
NodeMCU ESP8266 we connect the D1 & D2 pin of the esp8266 o the anode of LED and
cathode to the ground pin of the esp8266.
Web Dashboard:

Procedure:
1. To setup from web dashboard.
• Open blynk Login with valid credentials.
• Open new template and enter any name and select the device: ESP8266 select
connection type to Wi-Fi and click on done
• Go to DataStream and click new DataStream and select digital, enter any name as
LED and select the pin as 2 and click create.
• Go to web dashboard, drag and drop the switch widget.
• Go to settings and select the data source led which we created in DataStream and
save it.
• Go to the search page and add a new device and click the new device button from
template, enter the template name and device name and create.
• Now copy the Template info and paste in program, go to tools in the board
NodeMCU and select the port and upload the program in NodeMCU board.

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

• Go back to Web Dashboard, now you can see device online, if you click on switch
the LED will glow if you off it the LED will turn off.
2. To setup from mobile app.
• Login to blynk app with valid credentials.
• Your template will be show on the app and click on it, click on setup dashboard
• Click on setting option, now click on + option now select button now tap on the
buttons.
• Choose the DataStream select on switch now go back.
• Now if you will turn on the switch in your app will led will glow.

Code:

#define BLYNK_TEMPLATE_ID "TMPLzY2KYi5U"


#define BLYNK_DEVICE_NAME "TWO LOADS"
#define BLYNK_AUTH_TOKEN "pSlEzyH7dJqhXWXelsC7V1PjoyXJxjPc"

#define BLYNK_PRINT Serial //case sensitive


#include<ESP8266WiFi.h> //this has to be in red mark,so we will not get error
#include<BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN; //CHARACTER BUFFER,

char ssid[] = "";


char pass[] = "";

BLYNK_WRITE(V0) //executes when the value of virtual pin 0 changes


{
if(param.asInt() == 0)
{
digitalWrite(D2,HIGH);
}
else
{
digitalWrite(D2,LOW);
}
}

BLYNK_WRITE(V1) //executes when the value of virtual pin 0 changes


{
if(param.asInt() == 0)
{
digitalWrite(D3,HIGH);
}
else
{
digitalWrite(D3,LOW);

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

}
}
BLYNK_WRITE(V2) //executes when the value of virtual pin 0 changes
{
if(param.asInt() == 0)
{
digitalWrite(D4,HIGH);
}
else
{
digitalWrite(D4,LOW);
}
}
BLYNK_WRITE(V3) //executes when the value of virtual pin 0 changes
{
if(param.asInt() == 0)
{
digitalWrite(D5,HIGH);
}
else
{
digitalWrite(D5,LOW);
}
}

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Blynk.begin(auth,ssid,pass);
pinMode(D2,OUTPUT);
pinMode(D3,OUTPUT);
pinMode(D4,OUTPUT);
pinMode(D5,OUTPUT);

void loop() {
// put your main code here, to run repeatedly:
Blynk.run(); //run is the function which is there in blynk app

Conclusion:
Thus, the controlling of LED using blynk is verified.

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

2.Problem Statement:
In this project we will learn how to control an Ultrasonic Sensor (HCSR-04) using Blynk IoT
mobile app and also via the Blynk web dashboard.
Introduction:
In this programme we show how to control and Ultrasonic Sensor (HCSR-04) using Blynk
IoT software using the NodeMCU ESP8266 we connect the D1 pin (trigger) & D2 pin (echo),
ground pin of the esp8266.
Web Dashboard:

Procedure:
1.To setup from web dashboard.
• Open blynk Login with valid credentials.
• Open new template and enter any name and select the device: ESP8266 select connection
type to Wi-Fi and click on done
• Go to DataStream and click new DataStream and select digital, enter any name as distance
and select the pin as 2 and click create.
• Go to web dashboard, drag and drop the switch widget.
• Go to settings and select the data source led which we created in DataStream and save it.
• Go to the search page and add a new device and click the new device button from template,
enter the template name and device name and create.
• Now copy the Template info and paste in program, go to tools in the board NodeMCU and
select the port and upload the program in NodeMCU board.

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

• Go back to Web Dashboard, now you can see device online, if you click on gauge the
ultrasonic sensor will measure distance of an object.
2.To setup from mobile app.
• Login to blynk app with valid credentials.
• Your template will be show on the app and click on it, click on setup dashboard
• Click on setting option, now click on + option now select button now tap on the buttons.
• Choose the DataStream select on switch now go back.
• Now in your app will senor will display in the form of gauge.
Code:
#include <HCSR04.h>
UltraSonicDistanceSensor distanceSensor(D5, D6);// D5 trig pin D6 echo pin

#define BLYNK_TEMPLATE_ID "TMPL8KPp-0zZ"


#define BLYNK_DEVICE_NAME "ULTRASONIC SENSOR"
#define BLYNK_AUTH_TOKEN "f4DoifdMMCk3jlqMp-iM5HOnPqvXWUjT"

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "iot";


char pass[] = "iot1234567890";

BlynkTimer timer;

void myTimerEvent()
{
float distance = distanceSensor.measureDistanceCm();

Blynk.virtualWrite(V0,distance);
}

void setup()
{
// Debug console
Serial.begin(115200);

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

Blynk.begin(auth, ssid, pass);

timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}

Conclusion:
Thus, the controlling of Ultrasonic Sensor (HCSR-04) using blynk is verified.

3.Problem Statement:
In this project we will learn how to control an Digital Humidity temperature sensor (DHT11)
using Blynk IoT mobile app and also via the Blynk web dashboard.
Introduction:
In this programme we show how to control and Digital Humidity temperature sensor
(DHT11) using Blynk IoT software using the NodeMCU ESP8266 we connect the D2 and
ground pin of the esp8266.
Web Dashboard:

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

Procedure:
1.To setup from web dashboard.
• Open blynk Login with valid credentials.
• Open new template and enter any name and select the device: ESP8266 select connection
type to Wi-Fi and click on done
• Go to DataStream and click new DataStream and select digital, enter any name as distance
and select the pin as 2 and click create.
• Go to web dashboard, drag and drop the switch widget.
• Go to settings and select the data source led which we created in DataStream and save it.
• Go to the search page and add a new device and click the new device button from template,
enter the template name and device name and create.
• Now copy the Template info and paste in program, go to tools in the board NodeMCU and
select the port and upload the program in NodeMCU board.
• Go back to Web Dashboard, now you can see device online, if you click on gauge the
DHT11 sensor will senses the current humidity & temperature.
2.To setup from mobile app.
• Login to blynk app with valid credentials.
• Your template will be show on the app and click on it, click on setup dashboard
• Click on setting option, now click on + option now select button now tap on the buttons.
• Choose the DataStream select on switch now go back.
• Now in your app will senor will display in the form of gauge.
Code:
#define BLYNK_TEMPLATE_ID "TMPL8KPp-0zZ"
#define BLYNK_DEVICE_NAME "HUMTEMP"
#define BLYNK_AUTH_TOKEN "f4DoifdMMCk3jlqMp-iM5HOnPqvXWUjT"

#define BLYNK_PRINT Serial

#include "DHT.h"
#define DHTPIN D2
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

char auth[] = BLYNK_AUTH_TOKEN;

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

char ssid[] = "iot";


char pass[] = "iot1234567890";

BlynkTimer timer;

void myTimerEvent()
{
float h = dht.readHumidity();

float t = dht.readTemperature();

Blynk.virtualWrite(V0,h);
Blynk.virtualWrite(V1,t);
}

void setup()
{
// Debug console
Serial.begin(115200);
dht.begin();

Blynk.begin(auth, ssid, pass);

timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}

Conclusion:
Thus, the controlling of Digital Humidity temperature sensor (DHT11) using blynk is
verified.

4.Problem Statement:
In this project we will learn how to control an Soil Moisture Sensor using Blynk IoT mobile
app and also via the Blynk web dashboard.
Introduction:

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

In this programme we show how to control and Soil Moisture Sensor using Blynk IoT
software using the NodeMCU ESP8266 we connect the A0 pin of the esp8266 ground pin of
the esp8266.
Web Dashboard:

Procedure:
1.To setup from web dashboard.
• Open blynk Login with valid credentials.
• Open new template and enter any name and select the device: ESP8266 select connection
type to Wi-Fi and click on done
• Go to DataStream and click new DataStream and select digital, enter any name as distance
and select the pin as 2 and click create.
• Go to web dashboard, drag and drop the switch widget.
• Go to settings and select the data source led which we created in DataStream and save it.
• Go to the search page and add a new device and click the new device button from template,
enter the template name and device name and create.
• Now copy the Template info and paste in program, go to tools in the board NodeMCU and
select the port and upload the program in NodeMCU board.
• Go back to Web Dashboard, now you can see device online, if you click on gauge the soil
moisture sensor will senses water content in the soil.
2.To setup from mobile app.
• Login to blynk app with valid credentials.
• Your template will be show on the app and click on it, click on setup dashboard

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

• Click on setting option, now click on + option now select button now tap on the buttons.
• Choose the DataStream select on switch now go back.
• Now in your app will senor will display in the form of gauge.
Code:
#define BLYNK_TEMPLATE_ID "TMPL8KPp-0zZ"
#define BLYNK_DEVICE_NAME "SOIL MOISTURE"
#define BLYNK_AUTH_TOKEN "f4DoifdMMCk3jlqMp-iM5HOnPqvXWUjT"

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "iot";


char pass[] = "iot1234567890";

BlynkTimer timer;

void myTimerEvent()
{
float sensor = analogRead(A0);
float moisture = (sensor/1024.0)*3.3;

Blynk.virtualWrite(V0,moisture);
}

void setup()
{
// Debug console
Serial.begin(115200);

Blynk.begin(auth, ssid, pass);

timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
Blynk.run();

D.R.R/EC/IIOT(20EC52I)
IIOT PRACTICAL

timer.run(); // Initiates BlynkTimer


}

Conclusion:
Thus, the controlling of Soil Moisture Sensor using blynk is verified.

D.R.R/EC/IIOT(20EC52I)

You might also like