0% found this document useful (0 votes)
18 views46 pages

Ocs352 Iot

The document outlines a practical lab manual for the Department of Electrical and Electronics Engineering at Rajiv Gandhi College of Engineering, focusing on IoT concepts and applications. It includes various experiments such as introducing Arduino programming, exploring communication methods with IoT devices, and interfacing sensors with Raspberry Pi. Additionally, it provides detailed procedures and code examples for each experiment, emphasizing hands-on learning in IoT technologies.

Uploaded by

juliet
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)
18 views46 pages

Ocs352 Iot

The document outlines a practical lab manual for the Department of Electrical and Electronics Engineering at Rajiv Gandhi College of Engineering, focusing on IoT concepts and applications. It includes various experiments such as introducing Arduino programming, exploring communication methods with IoT devices, and interfacing sensors with Raspberry Pi. Additionally, it provides detailed procedures and code examples for each experiment, emphasizing hands-on learning in IoT technologies.

Uploaded by

juliet
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/ 46

RAJIV GANDHI COLLEGE OF ENGINEERING

(An ISO Certified Christian Minority Institution)


NEMILI, SRIPERUMBUDUR 602 105

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

OCS352– IoT CONCEPTS AND APPLICATIONS

NAME:

REGISTER NUMBER:

BATCH:

YEAR / SEM / SEC.:

BRANCH:
RAJIV GANDHI COLLEGE OF ENGINEERING
(An ISO Certified Christian Minority Institution)
NEMILI, SRIPERUMBUDUR 602 105

BONAFIDE CERTIFICATE
Certified that this is the bonafide record of the work done by
Mr./Ms. …………………………... Reg.No …………………………
Department of ………………………………, Semester ………...................
in the subject of ……………………………… during the year 20 - 20

Signature of the Lab In charge Signature of HOD

Submitted for the Practical Examination held on …………………………

Internal Examiner External Examiner


INDEX

Exp. PAGE
DATE NAME OF THE MARKS SIGNATURE
NO NO
EXPERIMENT (10)
INDEX

Exp. PAGE
DATE NAME OF THE MARKS SIGNATURE
NO NO
EXPERIMENT (10)
EX NO. 1 INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING

DATE:

AIM:

To introduce Arduino platform and programming.

THEORY:

Arduino is a project, open-source hardware, and software platform used to design and build
electronic devices. It designs and manufactures microcontroller kits and single-board
interfaces for building electronics projects. The Arduino boards were initially created to help
the students with the non-technical background. The designs of Arduino boards use a variety
of controllers and microprocessors. The Arduino board consists of sets of analog and digital
I/O (Input / Output) pins, which are further interfaced to breadboard, expansion
boards, and other circuits. Such boards feature the model, Universal Serial Bus (USB),
and serial communication interfaces, which are used for loading programs from the
computers.

PICTORIAL REPRESENTATION OF ARDUINO


Installing the Microcontroller Board in Arduino IDE:

ESP 32

Prerequisites: Arduino IDE Installed

Before starting this installation procedure, make sure you have the latest version of the
Arduino IDE installed in your computer. If you don’t, uninstall it and install it again.
Otherwise, it may not work. Installing ESP32 Add-on in Arduino IDE.

To install the ESP32 board in your Arduino IDE, follow these next instructions:

i. In your Arduino IDE, go to File> Preferences

ii. Enter the following into the “Additional Board Manager URLs” field:
https://raw.githubusercontent.com/espressif/arduino-sp32/ghpages/package_esp32_index.json
Then, click the “OK” button.

iii. Open the Boards Manager. Go to Tools > Board > Boards Manager

iv. Search for ESP32 and press install button for the “ESP32 by Espressif Systems”:
v. That is it. It should be installed after a few seconds.

Testing the Installation

Plug the ESP32 board to your computer. With your Arduino IDE open, follow these steps:

1. Select your Board in Tools > Board menu (in my case it’s the DOIT ESP32 DEVKIT
V1)
2. Select the Port (if you don’t see the COM Port in your Arduino IDE, you need to
install the CP210x USB to UART Bridge VCP Drivers)
3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan
4. A new sketch opens in your Arduino IDE
5. Press the Upload button in the Arduino IDE. Wait a few seconds while the code
compiles and uploads to your board.
6. If everything went as expected, you should see a “Done uploading.” message.

7. Open the Arduino IDE Serial Monitor at a baud rate of 115200.


8. Press the ESP32 on-board Enable button and you should see the networks available
near your ESP32.
PIN CONFIGURATIONS
1. IR SENSOR - ESP32
2. O/P GPIO 4
3. BUZZER/LED GPIO 13

PROGRAM:

i) //Same code for both LED and Buzzer (mention Pin no)

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin LED_BUILTIN as an output.

pinMode(LED_BUILTIN, OUTPUT);

// the loop function runs repeatedly forever

void loop() {

digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the

voltage level)

delay(2000); // wait for a second


digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the

voltage LOW

delay(1000); // wait for a second

OUTPUT:

ii) //Same code for both LED and IR sensor

// constants won't change. They're used here to set pin numbers:

const int buttonPin = 4; // the number of the pushbutton pin

const int ledPin = 13; // the number of the LED pin

// variables will change:

int buttonState = 0; // variable for reading the pushbutton status

void setup() {

// initialize the LED pin as an output:

pinMode(ledPin, OUTPUT);

// initialize the pushbutton pin as an input:

pinMode(buttonPin, INPUT);

}
void loop() {

// read the state of the pushbutton value:

buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:

if (buttonState == HIGH) {

// turn LED on:

digitalWrite(ledPin, LOW);

else {

// turn LED off:

digitalWrite(ledPin, HIGH);

OUTPUT:
RESULT:

Thus, Arduino IDE was installed and basic program was executed.
EX NO 2 EXPLORE DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES (ZIGBEE, GSM, BLUETOOTH)

DATE:

AIM:

To study various communication methods with IoT devices ZigBee, GSM, Bluetooth.

THEORY:

Zigbee

ZigBee is similar to Bluetooth and is majorly used in industrial settings. It has some
significant advantages in complex systems offering low-power operation, high security,
robustness and high and is well positioned to take advantage of wireless control and sensor
networks in IoT applications. The latest version of ZigBee is the recently launched 3.0, which
is essentially the unification of the various ZigBee wireless standards into a single standard.

Bluetooth
An important short-range IoT communications Protocols / Technology. Bluetooth,
which has become very important in computing and many consumer product markets. It is
expected to be key for wearable products, again connecting to the IoT albeit probably via a
smartphone in many cases. The new Bluetooth Low-Energy (BLE) – or Bluetooth Smart, as it
is now branded – is a significant protocol for IoT applications. Importantly, while it offers a
similar range to Bluetooth it has been designed to offer significantly reduced power
consumption.
How to Set Up and Test Arduino Bluetooth Connection

This works with android phones and the HC-05 and HC-06 bluetooth modules, as well as
pretty much any arduino or arduino clone.

Step 1: Connect the Bluetooth module to the Arduino like so

RX-pin2

TX-pin 3

GND-GND

VCC-5v

Step 2: Plug in the Arduino and Upload the Sketch

Download the ino file and upload it to the arduino.

(DOWNLOAD THIS FILE FROM :https://www.instructables.com/How-to-Set-Up-and-Test-


Arduino-Bluetooth-Connection//)

Step 3: Connect to the Bluetooth on Your Phone


Open up the bluetooth settings on your phone and look for the module. Mine is named
Sailfish but yours should be named either hc-05 or hc-06. The password is almost always
1234, if not, try 0000.

Step 4: Connect to the Bluetooth Module

Download a Bluetooth terminal app from the Appstore, this one work great:
https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal&hl=en and open it
up. Open the app, hit connect to a device - insecure and select your Bluetooth module from
the list.
Step 5: Ready to Go!

Finally open up the Serial Monitor in the Arduino IDE by hitting the magnifying glass in the
top right corner, and you should be good to go. You now have a back and forth extremely
simple connection between your phone and your Arduino via Bluetooth.

Cellular

Any IoT application that requires operation over longer distances can take advantage of
GSM/3G/4G cellular communication capabilities. While cellular is clearly capable of sending
high quantities of data, especially for 4G, the cost and power consumption will be too high
for many applications. But it can be ideal for sensor-based low-bandwidth-data projects that
will send very low amounts of data over the Internet.
PIN CONFIGURATION

1. DHT 11 - ESP 32
2. O/P - GPIO 2

PROGRAM:

#include <BluetoothSerial.h>

#include "DHT.h"

#define dhtPin 2

#define DHTTYPE DHT11

DHT dht(dhtPin, DHTTYPE);

BluetoothSerial SerialBT;

void setup() {

Serial.begin(115200);

SerialBT.begin("ESP32_BT_Server"); // Set a name for Bluetooth server

dht.begin();

void loop() {

float temperature = dht.readTemperature(); // Read temperature value in

float humidity = dht.readHumidity(); // Read humidity value


if (isnan(temperature) || isnan(humidity)) {

Serial.println("Failed to read from DHT sensor!");

SerialBT.println("Failed to read from DHT sensor!");

return;

SerialBT.print("Temperature: ");

SerialBT.print(temperature);

SerialBT.print(" °C\t");

SerialBT.print("Humidity: ");

SerialBT.print(humidity);

SerialBT.println(" %");

delay(2000);

OUTPUT:
PIN CONFIGURATION

1. DHT 11 - ESP 32
2. O/P - GPIO 2(On Board LED)

PROGRAM:

#include <BluetoothSerial.h>

#if !defined(CONFIG_BT_ENABLED) ||

!defined(CONFIG_BLUEDROID_ENABLED)

#error Bluetooth is not enabled! Please run `make menu config` to and enable

it

#endif

#define ledPin 2

BluetoothSerial SerialBT;

// Handle received and sent messages

String message = "";

char incomingChar;

void setup() {

pinMode(ledPin, OUTPUT);

Serial.begin(115200);

SerialBT.begin("ESP32"); //Bluetooth device name

Serial.println("The device started, now you can pair it with bluetooth!");

void loop() {

if (SerialBT.available()){

char incomingChar = SerialBT.read();

if (incomingChar != '\n'){

message += String(incomingChar);
}

else{

message = "";

Serial.write(incomingChar);

// Check received message and control output accordingly

if (message =="on"){

digitalWrite(ledPin, HIGH);

else if (message =="off"){

digitalWrite(ledPin, LOW);

delay(20);

}
OUTPUT:

RESULT:

Thus, study various communication methods with IoT devices ZigBee, GSM, Bluetooth was
done.
EX NO 3 INTRODUCTION TO RASPBERRY PI PLATFORM AND
PYTHON PROGRAMMING

DATE:

AIM:

To introduce Raspberry Pi Platform and Python programming.

THEORY:

Raspberry Pi, developed by Raspberry Pi Foundation in association with Broadcom, is a


series of small single-board computers and perhaps the most inspiring computer available
today. From the moment you see the shiny green circuit board of Raspberry Pi, it invites you
to tinker with it, play with it, start programming, and create your own software with it.
Earlier, the Raspberry Pi was used to teach basic computer science in schools but later,
because of its low cost and open design, the model became far more popular than anticipated.
It is widely used to make gaming devices, fitness gadgets, weather stations, and much more.
But apart from that, it is used by thousands of people of all ages who want to take their first
step in computer science. It is one of the best-selling British computers and most of the
boards are made in the Sony factory in Pencoed, Wales. In 2012, the company launched the
Raspberry Pi and the current generations of regular Raspberry Pi boards are Zero, 1, 2, 3, and
4.

Generation 1 Raspberry Pi had the following four options −

• Model A
• Model A +
• Model B
• Model B +

Among these models, the Raspberry Pi B models are the original credit-card sized format.

On the other hand, the Raspberry Pi A models have a smaller and more compact footprint and
hence, these models have the reduced connectivity options.

Raspberry Pi Zero models, which come with or without GPIO (general-purpose input output)
headers installed, are the most compact of all the Raspberry Pi boards types.
PROGRAM:

CONTROL LED:

import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BCM)

GPIO.setup(18,GPIO.OUT)

while True:

GPIO.output(18,True)

time.sleep(1)

GPIO.output(18,False)

time.sleep(1)
OUTPUT:

RESULT:

Thus, Raspberry Pi is introduced and python program for controlling LED is executed.
EX NO 4 INTERFACING SENSORS WITH RASPBERRY PI

DATE:

AIM:

To interface sensors with Raspberry Pi.

THEORY:

The Raspberry Pi IR Sensor Interface can be converted into a Proximity Detector,


where the application will detect if the object is too close to the sensor.

CIRCUIT DIAGRAM:

COMPONENTS REQUIRED:

• Raspberry Pi 3 Model B
• IR Sensor
• 5V Buzzer
• Mini Breadboard
• Connecting Wires
• Power Supply
• Computer

CIRCUIT DESIGN:

The IR Sensor Module has only three Pins: VCC, GND and Data. Connect the VCC and
GND pins of the IR Sensor to +5V and GND pins of the Raspberry Pi. Then connect the Data
pin of the IR Sensor to GPIO23 i.e., Physical Pin 16 of the Raspberry Pi. To indicate the
alarm, I have used a simple 5V Buzzer. Connect one terminal of the buzzer to GND of
Raspberry Pi and the other terminal (usually marked +) to GPIO24 i.e., Physical Pin 18 of
Raspberry Pi.

1) BUTTON AND LED INTERFACE


from machine import Pin
import utime as time
led = Pin(27, Pin.OUT)
sensor = Pin(28, Pin.IN)
while True:
time.sleep(1)
print(sensor.value())
if sensor.value()==0:
led.value(1)
else:
led.value(0)

OUTPUT:

2) RASPBERRY PI PICO AND DHT11 INTEFACE


from machine import Pin, I2C
import utime as time
import sys
import dht
sensor = dht.DHT11(Pin(28))
while True:
time.sleep(5)
sensor.measure()
t = (sensor.temperature)
h = (sensor.humidity)
print("Temperature: {}".format(sensor.temperature))
print("Humidity: {}".format(sensor.humidity))

OUTPUT:

3) RGB LIGHT
from machine import Pin
import utime
red = Pin(11, Pin.OUT)
green = Pin(12, Pin.OUT)
blue = Pin(13, Pin.OUT)
while True:
red.value(0)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(1)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(0)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(0)
green.value(1)
blue.value(0)
utime.sleep(2)

red.value(0)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(0)
green.value(0)
blue.value(1)
utime.sleep(2)

OUTPUT:

RESULT:

The sensors are interfaced with Raspberry Pi successfully.


EX NO 5 SETUP A CLOUD PLATFORM TO LOG THE DATA

DATE:

AIM:

To setup a cloud platform to log the data.

PROCEDURE: -

1. Creating an Arduino Account

To starting using the Arduino IoT cloud, we first need to log in or sign up to Arduino.

2. Go to the Arduino IoT Cloud

After we have signed up, you can access the Arduino IoT Cloud from any page on arduino.cc
by clicking on the four dots menu in the top right corner. You can also go directly to the
Arduino IoT Cloud.

Navigating to the cloud.

3. Creating a Thing

The journey always begins by creating a new Thing. In the Thing overview, we can choose
what device to use, what Wi-Fi network we want to connect to, and create variables that we
can monitor and control. This is the main configuration space, where all changes we make are
automatically generated into a special sketch file.
The Thing overview

4. Configuring a Device

Devices can easily be added and linked to a Thing. The Arduino IoT Cloud requires your
computer to have the Arduino Create Agent installed. The configuration process is quick and
easy, and can be done by clicking on the “Select device” button in the Thing overview. Here,
we can choose from any board that has been configured, or select the “Configure new device”
option.

Configuring a device

We can also get a complete overview of our devices by clicking the “Devices" tab at the top
of the Arduino IoT Cloud interface. Here we can manage and add new devices.
The device tab

5. Creating Variables

The variables we create are automatically generated into a sketch file. There are several data
types we can choose from, such as int, float, boolean, long, char. There are also special
variables, such as Temperature, Velocity, Luminance that can be used. When clicking on the
“Add variable” button, we can choose name, data type, update setting and interaction mode.

Creating variables

6. Connecting to a Network

To connect to a Wi-Fi network, simply click the “Configure” button in the network section.
Enter the credentials and click “Save”. This information is also generated into your sketch
file!
Entering network credentials

7. Editing the Sketch

An automatically generated sketch file can be found in the “Sketch” tab. It has the same
structure as a typical .ino file, but with some additional code to make the connection to your
network and to the cloud. A sketch that, for example, reads an analog sensor, and use the
cloud variable to store it. When the sketch has been uploaded, it will work as a regular sketch,
but it will also update the cloud variables that we use. Additionally, each time we create a
variable that has the Read & Write permission enabled, a function is also generated, at the
bottom of your sketch file. Each time these variable changes, it will execute the code within
this function! This means that we can leave most of the code out of the loop () and only run
code when needed.To upload the program to our board, simply click the "Upload" button.
The editor also has a Serial Monitor Tool, which can be opened by clicking the magnifying
glass in the toolbar. Here you can view information regarding your connection, or commands
printed via

Serial.print()

The Serial Monitor Tool

After we have successfully uploaded the code, we can open the “Serial Monitor” tab to view
information regarding our connection. If it is successful, it will print “connected to
network_name” and “connected to cloud”. If it fails to connect, it will print the errors here as
well. The cloud editor is a mirrored "minimal" version of the Web Editor. Any changes you
make will also be reflected in the Web Editor, which is more suitable for developing more
advanced sketches.

8. Creating a Dashboard

Now that we have configured the device & network, created variables, completed the sketch
and successfully uploaded the code, we can move on to the fun part: creating dashboards!
Visualize your data

Dashboards are visual user interface for interacting with your boards over the cloud, and we
can setup many different setups depending on what your IoT project needs. We can access
our dashboards by clicking on the “Dashboards” tab at the top of the Arduino IoT Cloud
interface, where we can create new dashboards, and see a list of dashboards created for other
Things.

Navigating to dashboards

If we click on “Create new dashboard”, we enter a dashboard editor. Here, we can create
something called widgets. Widgets are the visual representation of our variables we create,
and there are many different to choose from. Below is an example using several types of
widgets.
The different widgets available

When we create widgets, we also need to link them to our variables. This is done by clicking
on a widget we create, select a Thing, and select a variable that we want to link. Once it is
linked, we can either interact with it, for example a button, or we can monitor a value from a
sensor. As long as our board is connected to the cloud, the values will update.

Let's say we have a temperature widget that we want to link to the temperature variable inside
the Cloud project thing.

Linking a variable to a widget.

Note that not all widgets and variables are compatible. A switch and an integer can for
example not be linked, and will not be an option while setting up your dashboard.

We can also have several things running at once, depending on your Arduino IoT Cloud plan,
which we can include in the same dashboard. This is a great feature for tracking multiple
boards in for example a larger sensor network, where boards can be connected to different
networks around the world, but be monitored from the same dashboard.

RESULT:

Thus, IOT devices are logged in cloud successfully.


EXP NO 6 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE
CLOUD PLATFORM

DATE:

AIM:

To log data using Raspberry Pi and upload data to the cloud platform.

THEORY:

ThingSpeak is an open IoT platform for monitoring your data online. In ThingSpeak channel
you can set the data as private or public according to your choice. ThingSpeak takes
minimum of 15 seconds to update your readings. Its a great and very easy to use platform for
building IOT projects.

There are also some other platforms available for monitoring your data online which we will
cover in later articles but there are some advantages of ThingSpeak over other platforms like
it is very easy to set up and it also has many options to plot graph.

Components Required

1. Raspberry Pi

2. Power Cable

3. WiFi or Internet

Step 1: Go to https://thingspeak.com.

Step 2: Create an account using Email-id.

Step 3: Now, create a channel.


Step 4: After the creation of channel ,go to the API Keys and copy the Write API Key.

Step 5: And now paste the Write API Key in your code and your channel number in place of
“myChannelNumber” and “myWriteAPIKey”.

Step 6: After pasting the API key and Channel number, now you can upload the code to
ESP32.

Step 7: Now you can view the temperature and humidity data in the form of graph in your
channel i.e., in the private view.
PROGRAM:

#include <WiFi.h> // Install the WiFi library

#include <DHT.h> //Install the DHT library

#include <ThingSpeak.h> //Install the ThingSpeak library

char* ssid = "SSID"; //enter SSID

char* passphrase = "PASS"; // enter the password

WiFiServer server(80);

WiFiClient client;

unsigned long myChannelNumber = CHANNEL NUMBER;

const char * myWriteAPIKey = "API KEY";

unsigned long lastTime = 0;

unsigned long timerDelay = 1000;

// --- DHT declarations

#define DHTPIN 4 // Digital pin connected to the DHT sensor

#define DHTTYPE DHT11 // DHT 11

// Initializing the DHT11 sensor.

DHT dht(DHTPIN, DHTTYPE);

void setup()

Serial.begin(115200); //Initialize serial

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, passphrase);

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

delay(500);

Serial.print(".");

}
// Print local IP address and start web server

Serial.println("");

Serial.println("WiFi connected.");

Serial.println("IP address: ");

Serial.println(WiFi.localIP());

server.begin();

// --- nitialize dht11

dht.begin();

ThingSpeak.begin(client); // Initialize ThingSpeak

void loop ()

if ((millis() - lastTime) > timerDelay)

delay(2500);

// Reading temperature or humidity takes about 250 milliseconds!

float t = dht.readTemperature ();

// Read temperature as Celsius (the default)

float h = dht.readHumidity ();

float f = dht.readTemperature(true);

if (isnan(h) || isnan(t) || isnan(f)) {

Serial.println(F("Failed to read from DHT sensor!"));

return;

Serial.print("Temperature (ºC): ");

Serial.print(t);

Serial.println("ºC");
Serial.print("Humidity");

Serial.println(h);

ThingSpeak.setField(1, t);

ThingSpeak.setField(2, h);

// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to

store up to 8 different

// pieces of information in a channel. Here, we write to field 1.

int x = ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);

if(x == 200){

Serial.println("Channel update successful.");

else{

Serial.println("Problem updating channel. HTTP error code " + String(x));

lastTime = millis();

}
OUTPUT:

RESULT:

The cloud platform is setup and log the data to the cloud is done.
EX NO 7 DESIGN AN IOT BASED SYSTEM

DATE:

AIM:

To design an IoT based system for Home Automation.

THEORY:

IoT devices and applications become more prevalent, it’s important to consider the ethical
implications of IoT design. Some key ethical considerations include privacy, security, data
ownership, and transparency. For example, imagine a smart home security system that uses
cameras and sensors to monitor a family’s activity. While the system may be effective in
preventing theft or intruders, it could also collect personal data about the family’s daily
routines and habits, which could be used for nefarious purposes if it falls into the wrong
hands.

How IoT engineers can address this issue:

1. Implement security measures: IoT designers should implement security measures


such as encryption and authentication to protect user data from unauthorized access.

2. Develop transparent data policies: IoT designers should develop transparent data
policies that clearly explain what data is being collected and how it will be used, as
well as obtain user consent before collecting any personal data.

3. Consider the impact on vulnerable populations: IoT designers should consider the
potential consequences of their designs, particularly for vulnerable populations such
as children, the elderly, or people with disabilities, and work to ensure that their
products are accessible and inclusive to all users.

4. Prioritize privacy by design: IoT designers should prioritize privacy by design,


which involves incorporating privacy considerations into the design process from the
beginning, rather than as an afterthought.

5. Educate users: IoT designers should provide clear and concise instructions on how
to use their products safely and securely, as well as provide resources for users to
learn more about IoT security and privacy best practices.

PROGRAM:

HOME AUTOMATION USING IOT

#define BLYNK_TEMPLATE_ID "TMPL3Wh1hKBQP"

#define BLYNK_TEMPLATE_NAME "Relay"

#define BLYNK_AUTH_TOKEN "ZnGEt8jHHcQ4pJ_Xj976QGkswyCgw5nG"


#define BLYNK_PRINT Serial

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

#include "DHT.h"

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "your_ssid";

char pass[] = "pass";

#define DHTPIN 4 // Mention the digital pin where you

connected

#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer;

void sendSensor(){

float h = dht.readHumidity();

float t = dht.readTemperature(); // or

dht.readTemperature(true) for Fahrenheit

if (isnan(h) || isnan(t)) {

Serial.println("Failed to read from DHT sensor!");

return;

Blynk.virtualWrite(V0, t);

Blynk.virtualWrite(V1, h);

Serial.print("Temperature : ");

Serial.print(t);

Serial.print(" Humidity : ");

Serial.println(h);
}

int ledpin = 2;

void setup(){

Serial.begin(115200);

Blynk.begin(auth, ssid, pass);

pinMode(ledpin,OUTPUT);

dht.begin();

timer.setInterval(1000L, sendSensor);

void loop(){

Blynk.run();

timer.run();

OUTPUT:

RESULT:

An IoT based system for Home Automation is been created.

You might also like