0% found this document useful (0 votes)
6 views8 pages

22bcs10114 - Ayush Gupta Iot

The document outlines an experiment to build a security system using sensors integrated with the Blynk platform for real-time alerts. It details the aim, objectives, hardware requirements, setup procedure, and code implementation for using a PIR motion sensor and ESP8266 microcontroller. The conclusion emphasizes the effectiveness of the system in enhancing security through motion detection and remote notifications.

Uploaded by

Dell computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

22bcs10114 - Ayush Gupta Iot

The document outlines an experiment to build a security system using sensors integrated with the Blynk platform for real-time alerts. It details the aim, objectives, hardware requirements, setup procedure, and code implementation for using a PIR motion sensor and ESP8266 microcontroller. The conclusion emphasizes the effectiveness of the system in enhancing security through motion detection and remote notifications.

Uploaded by

Dell computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 4
Student Name: Ayush Gupta UID: 22BCS10114
Branch: BE-CSE Section/Group: 625/A
Semester: Sixth Date of Performance: 17-02-2025
Subject Name: Foundation of Cloud IOT Edge ML Lab (22CSP-367)

1. Aim: Build a security system with any sensor and alerts using Blynk..

2. Objective: To design and implement a security system using sensors (e.g., PIR motion sensor,
magnetic door sensor, or ultrasonic sensor) and integrate it with the Blynk platform to send
real-time alerts.

3. Requirements:
a) PIR Motion Sensor (HC-SR501)
b) ESP8266/NodeMCU (or any Wi-Fi-enabled microcontroller)
c) Buzzer/LED (for local alerts, optional)
d) Blynk App (installed on your smartphone)
e) Breadboard and jumper wires
f) Ultrasonic Sensor (HC-SR04)

4. Procedure:
1. Connect the Hardware: PIR Sensor Pinout:
• VCC: Connect to 3.3V or 5V (depending on the sensor model).
• GND: Connect to GND.
• OUT: Connect to a digital pin on ESP8266 (e.g., D5).

Wiring Diagram:
• PIR VCC → NodeMCU 3.3V
• PIR GND → NodeMCU GND
• PIR OUT → NodeMCU D5
• Buzzer/LED (optional) → D2

2. Set Up Blynk:
• Download and install the Blynk app
• Create a new project and select ESP8266 as the device.
• Note down the Auth Token sent to your email.
• Add a Notification Widget in the app for alerts.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

3. Install Required Libraries:


• Blynk Library:
▪ Go to Tools > Manage Libraries and search for Blynk.
▪ Install the Blynk library.
• ESP8266 Board Support
.
5. Code:

/**void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, Muthu");
Serial.println("Let's Go!!");
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}
PIR output connectted in ESP pin 13
DHT22 output connectted in ESP pin 14
LED(assume LED as Buzzer) output connectted in ESP pin 15
Button output connectted in ESP pin 18
**/
#define BLYNK_TEMPLATE_ID "TMPL6WDk9AYgF"
#define BLYNK_TEMPLATE_NAME "EXP 4"
#define BLYNK_AUTH_TOKEN "2wjduz1ULBIH1fqyZxsbEgskupZX4swl"
#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

#include <BlynkSimpleEsp32.h>
#include <DHT.h>
// Blynk Authentication Token
char auth[] = BLYNK_AUTH_TOKEN;
// WiFi credentials
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// DHT sensor settings
#define DHTPIN 14
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
// PIR sensor pin
const int pirPin = 13;
// Buzzer pin
const int buzzerPin = 15;
// LED pin
const int ledPin = 16;
const int ledPin1 = 17;
// Button pin
const int buttonPin = 18;
// Variables
int pirState = LOW;
int buttonState = LOW;
int oldValue = HIGH;
void setup() {
// Initialize serial communication
Serial.begin(115200);
// Initialize Blynk
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Blynk.begin(auth, ssid, pass);


// Initialize DHT sensor
dht.begin();
// Initialize pins
pinMode(pirPin, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
Blynk.run();
readSensors();
}
void readSensors() {
// Read PIR sensor
pirState = digitalRead(pirPin);
if (pirState == HIGH) {
Serial.println(pirState);
digitalWrite(buzzerPin, HIGH);
digitalWrite(ledPin, HIGH);
delay(1000);
Blynk.virtualWrite(V2, 1); // Trigger virtual pin for motion notification
} else {
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
delay(1000);
Blynk.virtualWrite(V2, 0); // Reset virtual pin for motion notification
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

}
//Read button (door/window sensor)
buttonState = digitalRead(buttonPin);
/**
if (buttonState == LOW) {
digitalWrite(ledPin1, HIGH);
delay(1000);
Blynk.virtualWrite(V3, 1); // Trigger virtual pin for door/window notification
} else {
Blynk.virtualWrite(V3, 0); // Reset virtual pin for door/window notification
}
**/
int newValue = buttonState;
// Check if the value was changed,
// by comparing it with the previous value.
if(newValue != oldValue)
{
if(newValue == LOW)
{
digitalWrite(ledPin1, HIGH);
//delay(2000);
Blynk.virtualWrite(V3, 1); // Trigger virtual pin for door/window notification
delay(2000);
Serial.println("The button is pressed.");
}
else
{
digitalWrite(ledPin1, LOW);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Blynk.virtualWrite(V3, 0); // Reset virtual pin for door/window notification


delay(2000);
Serial.println("The button is released.");
}
// Remember the value for the next time.
oldValue = newValue;
}
// Read DHT sensor
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Send sensor data to Blynk
Blynk.virtualWrite(V0, t); // Temperature
Blynk.virtualWrite(V1, h); // Humidity
delay(100);
}

6. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

7. Conclusion:

The combination of ESP32 and Blynk showcases how modern microcontrollers and IoT platforms
can improve security. The system efficiently detects motion using a PIR sensor and monitors
ambient light to differentiate between day and night. Alerts and notifications are managed via the
Blynk app, enabling real-time updates and remote access. ESP32 ensures smooth communication
and processing, while the PIR sensor accurately detects movement, triggering alarms as needed. The
light sensor enhances intrusion detection in low-light settings, making the system more responsive
and effective.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy