0% found this document useful (0 votes)
31 views

Practical File Iot - For Merge

The document outlines the steps to implement an MQTT-based IoT communication system including identifying requirements, choosing an MQTT broker, setting up the broker, connecting IoT devices, defining topics and payloads, handling security, developing applications, testing and deploying, and maintaining the system.

Uploaded by

saurav yadav
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Practical File Iot - For Merge

The document outlines the steps to implement an MQTT-based IoT communication system including identifying requirements, choosing an MQTT broker, setting up the broker, connecting IoT devices, defining topics and payloads, handling security, developing applications, testing and deploying, and maintaining the system.

Uploaded by

saurav yadav
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

MADHAV INSTITUTE OF TECHNOLOGY &

SCIENCE, GWALIOR (M.P.), INDIA


Deemed to be University
(Declared under Distinct Category by Ministry of Education, Government of India)
NAAC ACCREDITED WITH A++ GRADE

Practical File

of

IOT System Design

Submitted By:
Saurav Yadav
0901CD211051

Faculty Mentor:
Dr. Devesh Kumar Lal
Assistant Professor
CSE

Submitted to:

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


MADHAV INSTITUTE OF TECHNOLOGY & SCIENCE
GWALIOR - 474005 (MP) est. 1957

JAN-MAY 2024
INDEX

S.N EXPERIMENT NAME DATE SIGNATURE

1. Implementation of LED Blinking with arduino/ 01-01-2024


Rasberry Pi.

2. Implementation of Temperature and Humidity


Monitoring.

3. Interfacing between sensors and actuator.

4. Develop an intrusion detection system through motion


sensors.

5. Develop an IoT-based Fire Detection System

6. Develop an IoT-based Air Quality Monitoring.

7. Implementation of IoT-based Home Automation System

8. Implementation of MQTT-based IoT Communication.

9. Implementing a mechanism for IoT Data Logging to


Cloud.

10. Implement a mechanism to control the state of an LED


using a Bluetoothenabled microcontroller.

11. Implementation of RFID-based Access Control System.


Experiment = 1

Implementation of LED Blinking with arduino/ Rasberry Pi.

void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);

OUTPUT :
Experiment = 2

Implementation of Temperature and Humidity Monitoring.

#include <DHT.h>;

//Constants
#define DHTPIN 7
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

//Variables
float hum; //Stores humidity value
float temp; //Stores temperature value

void setup()
{
Serial.begin(100);
dht.begin();
}

void loop()
{
delay(2000);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
delay(10000);
}
OUTPUT
Experiment = 3

Interfacing between sensors and actuator.

 Servo motor (Actuator) :

#include <Servo.h>

Servo myservo; // create servo object to control a servo


// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo
object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) {
// in steps of 1 degree
myservo.write(pos);
delay(15);
}
for (pos = 180; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(15);
}
}

OUTPUT :
 Ultrasonic Sensor :

const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor


const int echoPin = 6; // Echo Pin of Ultrasonic Sensor

void setup() {
Serial.begin(9600); // Starting Serial Terminal
}

void loop() {
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}

long microsecondsToInches(long microseconds) {


return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {


return microseconds / 29 / 2;
}
OUTPUT :
Experiment = 4

Develop an intrusion detection system through motion sensors.

//Defining pins

int pir = 2;

void setup()
{

// Sets the buzzer as an OUTPUT & PIR sensor as an INPUT


pinMode(pir, INPUT);

// Serial Communication is starting with 9600 of baudrate speed


Serial.begin(9600);
}

void loop()
{
//Read data from the sensor
int status = digitalRead(pir);

if(status == HIGH)
{
Serial.println("Motion Detected");
// tone(buzz,1000,700);
delay(2000);
}
else
{
Serial.println("No one is there");
delay(1000);
}

}
OUTPUT :
Experiment = 5

Develop an IoT-based Fire Detection System.

#include <DHT.h>;

//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

//Variables
float hum; //Stores humidity value
float temp; //Stores temperature value

void setup()
{
Serial.begin(100);
dht.begin();
}

void loop()
{
delay(2000);
//Read data and store it to variables temp
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
if(temp > 40){
Serial.println("fire is detected");
}
delay(10000); //Delay 2 sec.
}
OUTPUT :
Experiment = 6

Develop an IoT-based Air Quality Monitoring .

int led=13;
int MQ2pin=A0;

void setup(){
Serial.begin(9600);
}

void loop(){
float sensor=value;

sensorValue=analogRead(MQ2pin);
if(sensorValue>=250){
digitalWrite(led,HIGH);
Serial.print(sensorValue);
Serial.println(" Gas Detected ");

else{
digitalWrite(led,LOW);
Serial.println("Sensor Value : ");
Serial.println(sensorValue);

}
delay(1000);
}

OUTPUT :
Experiment = 7

Implementation of IoT-based Home Automation System .

char Incoming_value = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0)
{
Incoming_value = Serial.read();
Serial.print(Incoming_value);
Serial.print("/n");
if (Incoming_value == 'on')
digitalWrite(13,HIGH);
else if(Incoming_value == 'off')
digitalWrite(13,LOW);
}
}

OUTPUT : Done in lab


Experiment = 8

Implementation of MQTT-based IoT Communication .

Implementing an MQTT-based IoT system involves several steps. MQTT (Message Queuing
Telemetry Transport) is a lightweight messaging protocol ideal for IoT applications due to its
low bandwidth usage, low power consumption, and efficient communication between
devices. Here's a high-level overview of how you can implement such a system:

 Identify Requirements: Understand the requirements of your IoT application,


including the types of devices you'll be connecting, the data you need to collect, and
the actions you need to perform based on that data .

 Choose an MQTT Broker: Select an MQTT broker that will serve as the central hub
for communication between devices. Popular MQTT brokers include Mosquitto,
HiveMQ, and RabbitMQ.

 Set Up the MQTT Broker: Install and configure the chosen MQTT broker on a
server or cloud platform. Ensure that it's accessible to all your IoT devices and
applications.

 Connect IoT Devices: Implement MQTT client libraries on your IoT devices. These
libraries enable devices to publish data (e.g., sensor readings) and subscribe to topics
to receive commands or updates.

 Define Topics and Payloads: Define a topic structure that reflects the different types
of data your IoT devices will publish and subscribe to. Topics can represent sensors,
devices, or specific data types. Decide on the payload format (e.g., JSON, XML) for
exchanging data between devices and applications.

 Handle Security: Implement security measures to protect your MQTT-based IoT


system from unauthorized access and data breaches. This may include using TLS/SSL
encryption, authentication mechanisms (e.g., username/password, client certificates),
and access control lists (ACLs) on the MQTT broker.
 Develop IoT Applications: Build applications or services that interact with the
MQTT broker to collect, process, and analyze IoT data. These applications may
include dashboards for monitoring devices, automation systems for controlling
actuators, or analytics engines for deriving insights from the data.

 Testing and Deployment: Test your MQTT-based IoT system in a controlled


environment to ensure reliability, scalability, and security. Once validated, deploy the
system to production, and monitor its performance over time.

 Maintenance and Updates: Regularly maintain and update your MQTT-based IoT
system to address any security vulnerabilities, optimize performance, and add new
features as needed. This may involve software updates for devices, firmware updates
for IoT gateways, or upgrades to the MQTT broker.

 Scalability and Optimization: As your IoT deployment grows, consider strategies


for scaling your MQTT infrastructure to handle increased traffic and device
connections. Optimize your system architecture and configurations to minimize
latency, reduce resource usage, and improve overall efficiency.

By following these steps, you can successfully implement an MQTT-based IoT system
tailored to your specific application requirements.
Experiment = 9

Implementing a mechanism for IoT Data Logging to Cloud.

#include <WiFi.h>

#include <HTTPClient.h>

#include "DHT.h"

#define DHTPIN 5

#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "R";

const char* password = "11223377";

// Domain Name with full URL Path for HTTP POST Request

const char* serverName = "http://api.thingspeak.com/update";

// write API Key provided by thingspeak

String apiKey = "OTULNYGTXX8DHCIE";

void setup() {

Serial.begin(115200);

// WiFi.begin(ssid, password);
WiFi.begin("Wokwi-GUEST", "");

dht.begin();
Serial.println("Connecting");

while(WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

Serial.println("");

Serial.print("Connected to WiFi network with IP Address: ");

Serial.println(WiFi.localIP());

void loop() {

if(WiFi.status()== WL_CONNECTED){

WiFiClient client;

HTTPClient http;

delay(10000); // wait for 10 seconds

//float h = dht.readHumidity();

float t = dht.readTemperature();

if (isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Your Domain name with URL path or IP address with path

http.begin(client, serverName);

// Specify content-type header

http.addHeader("Content-Type", "application/x-www-form-urlencoded");
// Data to send with HTTP POST

String httpRequestData = "api_key=" + apiKey + "&field1=" + String(t);

// Send HTTP POST request

int httpResponseCode = http.POST(httpRequestData);

Serial.print("HTTP Response code: ");

Serial.println(httpResponseCode);
http.end();

else {
Serial.println("WiFi Disconnected");
}

OUTPUT :
Experiment = 10

Implement a mechanism to control the state of an LED using a Bluetoothenabled


microcontroller .

char Incoming_value = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0)
{
Incoming_value = Serial.read();
Serial.print(Incoming_value);
Serial.print("/n");
if (Incoming_value == 'on')
digitalWrite(13,HIGH);
else if(Incoming_value == 'off')
digitalWrite(13,LOW);
}
}

OUTPUT : Done in lab


Experiment = 11

Implementation of RFID-based Access Control System.

Planning and Requirements Gathering:

 Define the access control requirements: Determine what areas or assets need to be
secured and who should have access to them.

 Identify RFID technology requirements: Choose the appropriate RFID frequency


(e.g., LF, HF, UHF), tags, readers, and antennas based on the environment and
application needs.

 Consider integration: Determine if the access control system needs to integrate with
other systems such as security cameras, alarms, or databases.

System Design:

 Design the RFID infrastructure: Plan the placement of RFID readers and antennas
to ensure adequate coverage and read range for the intended application.

 Select access control software: Choose or develop software that can manage user
credentials, access permissions, and event logging.

 Design user interface: Determine how users will interact with the system, whether
through RFID cards, key fobs, mobile devices, or a combination.
Hardware Installation:

 Install RFID readers and antennas: Mount readers and antennas in strategic
locations according to the system design.

 Install RFID tags: Affix RFID tags to access cards, key fobs, or other items that
users will carry for access.

Software Configuration:

 Configure access control software: Set up user accounts, access levels, and
permissions in the software.

 Integrate with other systems: If necessary, configure integration with other security
or management systems.

Testing and Validation:

 Conduct system testing: Test the RFID readers, antennas, and software to ensure
proper functionality and reliability.

 Validate access control: Verify that users can access permitted areas and that
unauthorized access attempts are denied.

Deployment:

 Roll out the access control system: Deploy the system to the intended users and
locations.

 Train users and administrators: Provide training on how to use the access control
system, including how to present RFID credentials and manage access permissions.
Maintenance and Monitoring:

 Perform regular maintenance: Monitor system performance, conduct periodic


checks of RFID hardware, and replace batteries in RFID tags if necessary.

 Update software: Install software updates and security patches to keep the access
control system secure and up to date.

 Monitor access logs: Review access logs regularly to identify any anomalies or
security incidents.

You might also like