IOT Manual 2025
IOT Manual 2025
MANAGEMENT
Udaypura, Kanakpura Road, Opp: Art of Living, Bengaluru- 560082
LAB MANUAL
Lab In charge:
M2: To develop innovation and creativity among students enabling leadership and
entrepreneurship skills with ethical values.
PEO2: Graduates shall be technically competent with ability to analyze, design, develop,
optimize and implement Electronics and Communication systems to meet global needs.
i
Dayananda Sagar Academy of Technology and Management,
Bangalore
M1: To serve its region, state, the nation and globally by preparing students to make meaningful
contributions in an increasing complex global society challenge.
M2: To encourage reflection on and evaluation of emerging needs and priorities with state of art
infrastructure at institution.
M3: To support research and services establishing enhancements in technical, economic, human
and cultural development.
M4: To establish inter disciplinary center of excellence, supporting/promoting students
implementation.
M5: To increase the number of doctorate holders to promote research culture on campus.
M6: To establish IIPC, IPR, EDC innovation cells with functional MOU’s supporting student’s
quality growth.
ii
3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with
an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage
independent and life-long learning in the broadest context of technological change.
iii
Instruction to Students
1. Students keep their bags in the rack.
2. Students must take care of their valuable things.
3. Students must bring Observation book, record and manual along with pen, pencil, and
eraser Etc., no borrowing from others.
4. Students must handle the computers carefully, as they areexpensive.
5. Before entering to lab, must prepare for Viva for which they are going to conduct
experiment.
6. After execution of the program, students must show the programs to one of the faculties
or instructors.
7. Before leaving the lab, should check whether they have closed the specific software
application and keep their chairs properly.
iv
Rules for maintaining Laboratory Records
1. Put your name, USN and subject on the outside front cover of the record. Put that same
information on the first page inside.
2. Update Table of Contents every time you start each new experiment or topic.
3. Always use pen and write neatly and clearly.
4. Start each new topic (experiment, notes, calculation, etc.) on a right-side (odd numbered)
page.
5. Obvious care should be taken to make it readable even if you have bad handwriting.
6. The date should be written on every page in the top right corner.
7. On each right-side page
➢ Title of the experiment.
➢ Aim/Objectives
➢ Software Required
➢ Theory
➢ Program code
➢ Result
8. On each left side page
➢ Program output
9. Use labels and captions for figures and tables
10. Attach printouts of program output as needed. Stick printouts (A4 size) on the right side of
the lab record.
11. Strictly follow the instructions given by the Lab In-charge/ Lab Instructor.
v
Code Troubleshooting Hints
➢ Check syntax carefully. Look for missing semicolons, parentheses, or curly braces.
➢ Watch for uninitialized variables. Ensure both variables are declared and initialized before use.
➢ Check array boundaries. Ensure that you’re not accessing array elements beyond the declared
size.
➢ Verify that the pointers are correctly initialized and pointing to valid memory.
➢ If the program compiles but does not give the desired output, review the logic of the code.
➢ Avoid infinite loops. Make sure loops have appropriate exit conditions.
➢ Don’t ignore compiler warnings. They often provide useful hints about potential errors.
➢ Finally, ask your Lab Instructor.
vi
IoT (Internet of Things) Lab 23CECE48
EXPERIMENT – 1
To interface LED/Buzzer with Arduino/Raspberry Pi and write a program to ‘turn ON’ LED for
1 sec after every 2 seconds.
AIM: Write a program to turn ON LED/ Buzzer for 1 sec after every 2 seconds with
Raspberry Pi.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
CODING:
EXPERIMENT – 2
To interface Push button/LDR with Arduino/Raspberry Pi and write a program to ‘turn ON’ LED
when push button is pressed or at sensor detection.
AIM: Write a program to turn ON LED when push button is pressed using Arduino UNO.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
CODING:
CODING:
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, HIGH);
}
else
{
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
RESULT: Controlling LED by pressing push button using Arduino UNO has successfully
executed.
EXPERIMENT – 3
To interface DHT11 sensor with Arduino/Raspberry Pi and write a program to print temperature
and humidity readings.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
• Open Arduino IDE and navigate to Sketch > Include Library > Manage Libraries.
• Search for “DHTlib” and install the “DHTlib” library in the Arduino IDE.
CODING:
void setup() {
// We'll use the serial monitor to display readings
Serial.begin(9600);
Serial.println("Humidity and temperature");
dht.begin();
}
void loop() {
// Wait a few seconds between measurements
delay(2000);
//Read humidity
float h = dht.readHumidity();
RESULT: Interfacing of DHT11 with Arduino UNO to print temperature and humidity
readings has successfully executed.
EXPERIMENT – 4
To interface OLED with Arduino/Raspberry Pi and write a program to print temperature and
humidity readings on it.
AIM: Write a program to interface OLED with Arduino to print temperature and humidity
readings.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
• Open Arduino IDE and navigate to Sketch > Include Library > Manage Libraries.
• Search for “SSD1306” and install the “SSD1306” library from Adafruit in the
Arduino IDE.
EXPERIMENT – 5
To interface motor using relay with Arduino/Raspberry Pi and write a program to ‘turn ON’
motor when push button is pressed.
EXPERIMENT – 6
To interface Bluetooth with Arduino/Raspberry Pi and write a program to send sensor data to
smartphone using Bluetooth.
EXPERIMENT – 7
To interface Bluetooth with Arduino/Raspberry Pi and write a program to turn LED ON/OFF
when '1'/'0' is received from smartphone using Bluetooth.
Step 2: Import “Adafruit_GFX.h” & “Adafruit_SSD1306.h” header files in the code. Define
header file in the code
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Step 3: Connect I2C OLED display device to Arduino as per the circuit diagram.
Initially run I2C scanner which will find the address of I2C module that is connected to
Arduino. In this case address of I2C OLED module is 0x3C.
CODING:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#include <Adafruit_Sensor.h>
#include "DHT.h"
#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT);
#define DHTPIN 2 // Digital pin connected to the DHT sensor
void setup() {
Serial.begin(115200);
dht.begin();
display.begin(SH1106_SWITCHCAPVCC, 0x3C);
//display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
delay(2000);
display.clearDisplay();
display.setTextColor(WHITE);
//display.setTextColor(BLUE);
}
void loop() {
delay(2000);
// display temperature
display.setTextSize(1);
display.setCursor(0, 7);
// display.setTextColor(BLUE);
display.print("Temperature: ");
display.setTextSize(2);
display.setCursor(0, 12);
display.print(t);
display.print(" ");
display.setTextSize(1);
display.cp437(true);
display.write(167);
display.setTextSize(2);
display.print("C");
// display humidity
display.setTextSize(1);
display.setCursor(0, 37);
display.print("Humidity: ");
display.setTextSize(2);
display.setCursor(0, 50);
display.print(h);
display.print(" % ");
display.display();
}
(c) Displaying Temperature and Humidity values on I2C OLED using Arduino UNO
RESULT: Interfacing of OLED and DHT11 with Arduino UNO to print temperature and
humidity readings has successfully executed.
EXPERIMENT – 5
To interface motor using relay with Arduino/Raspberry Pi and write a program to
turn ON motor when push button is pressed.
AIM: Write a program to turn ON motor when push button is pressed using relay with
Arduino UNO.
COMPONENTS REQUIRED:
1. Arduino UNO.
2. Relay.
3. Resistor (10kΩ).
4. Motor.
5. Connecting cable or USB cable.
6. Breadboard.
7. Jumper wires.
CONNECTION DIAGRAM:
CODING:
int motor=9;
int button=4;
void setup() {
pinMode(motor, OUTPUT);
pinMode(button,INPUT);
}
void loop() {
if (digitalRead(button) == HIGH) {
digitalWrite(motor,HIGH);
}
else {
digitalWrite(motor, LOW);
}
}
RESULT: Motor turn ON/OFF operation when push button is pressed using relay with
Arduino UNO has successfully executed.
EXPERIMENT – 6
To interface Bluetooth with Arduino/Raspberry Pi and write a program to send
sensor data to smartphone using Bluetooth.
AIM: Write a program on ESP32 to send temperature value using DHT11 sensor to
smartphone using Bluetooth.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
RESULT: Sending Temperature data using DHT11 sensor to smartphone using Bluetooth
with ESP32 has successfully executed.
EXPERIMENT – 7
To interface Bluetooth with Arduino and write a program to turn LED ON/OFF
when '1'/'0' is received from smartphone using Bluetooth.
AIM: Write a program on ESP32 to turn LED ON/OFF from smartphone using Bluetooth
when '1'/'0' is received
COMPONENTS REQUIRED:
1. ESP32.
2. LED.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
void loop() {
while(Serial.available()>0)
{
data = Serial.read();
Serial.println(data);
if(data == '1')
{
digitalWrite(13, HIGH);
}
if(data == '0')
{
digitalWrite(13, LOW);
}
}
}
(b) Turning LED ON/OFF operation in ESP32 though smartphone using Bluetooth.
RESULT: LED ON/OFF from smartphone using Bluetooth based on received '1'/'0' data
AIM: Write a program on ESP32 to upload temperature and humidity value using DHT11
sensor to Thingspeak cloud.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
#include <DHT.h>
#include <WiFi.h> // library allows an pi pico w board to connect to the
internet
#include <WiFiClient.h>
#include <ThingSpeak.h>
#include <Adafruit_Sensor.h>
#define DHTPIN 16 // what digital pin we're connected to in our case digital
pin 16
#define DHTTYPE DHT11 // you need to define the DHT sensor type you're using.
In our example we're using the DHT11.
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "Sindu";
const char* password = "24kvsssin";
WiFiClient client;
unsigned long myChannelNumber = 2420596;
const char * myWriteAPIKey = "VJ0IWAGE4TVIWJ0P";
uint8_t temperature, humidity;
void setup()
{
Serial.begin(9600);
dht.begin();
delay(10);
// connect to Wifi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println(" ");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
ThingSpeak.begin(client);
}
void loop()
{
temperature = dht.readTemperature();
humidity = dht.readHumidity();
Serial.print("Temperature Value is :");
Serial.print(temperature);
Serial.println("C");
Serial.print("Humidity Value is :");
Serial.print(humidity);
Serial.println("%");
// 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 and 2.
RESULT: Sending temperature and humidity data using DHT11 sensor to Thingspeak
cloud with ESP32 has successfully executed.
EXPERIMENT – 9
Write a program on Arduino/Raspberry Pi to retrieve temperature and humidity data from
thingspeak cloud.
AIM: Write a program on ESP32 to retrieve temperature and humidity values using DHT11
sensor from Thingspeak cloud.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
#include <WiFi.h>
#include <ThingSpeak.h>
WiFiClient client;
void setup()
{
Serial.begin(9600);
ThingSpeak.begin(client);
WiFi.disconnect();
delay(3000);
Serial.println("START");
WiFi.begin("Sindu", "24kvsssin");
while ((!(WiFi.status() == WL_CONNECTED))) {
delay(300);
Serial.print("..");
}
Serial.println("Your IP is");
Serial.println((WiFi.localIP().toString()));
Serial.println("Connected");
}
void loop()
{
Serial.print("Temperature=");
Serial.println((ThingSpeak.readIntField(2420596,1,"VH42NQD7VW2J8Q4M")));
Serial.print("Humidity=");
Serial.println((ThingSpeak.readIntField(2420596,2,"VH42NQD7VW2J8Q4M")));
delay(3000);
}
EXPERIMENT – 10
To install MySQL database on Raspberry Pi and perform basic SQL queries.
(c) Displaying temperature and humidity data on serial monitor of Arduino IDE from Thingspeak cloud
RESULT: Retrieving temperature and humidity data from Thingspeak cloud with ESP32
has successfully executed.
EXPERIMENT – 10
To install MySQL database on Raspberry Pi and perform basic SQL queries.
AIM: To perform basic SQL queries by installing MySQL database on Rsapberry Pi.
PROCEDURE:
CRUD operations act as the foundation of database operations.
1.Create:
In CRUD operations, 'C' is an acronym for create, which means to add or insert data
into the SQL table. So, firstly we will create a table using CREATE command and then
we will use the INSERT INTO command to insert rows in the created table. Syntax for
table creation:
where,
➢ Table_Name is the name that we want to assign to the table.
➢ Column_Name is the attributes under which we want to store data of the table.
➢ Datatype is assigned to each column. Datatype decides the type of data that
will be stored in the respective column.
Prior to the creation of a table in SQL, we need to create a database or select an existing
database. Since we already had a database, we will select the database with the USE command.
To ensure that the table is created as per the column names, data types and sizes which we
have assigned during table creation, we will execute the following query:
Execute the following query to insert multiple records in the employee table:
2.Read:
In CRUD operations, 'R' is an acronym for read, which means retrieving or fetching the
data from the SQL table. So, we will use the SELECT command to fetch the inserted
records from the SQL table. We can retrieve all the records from a table using an asterisk
(*) in a SELECT query. There is also an option of retrieving only those records which
satisfy a particular condition by using the WHERE clause in a SELECT query.
Example : Write a query to fetch all the records stored in the employee table.
Here, an asterisk is used in a SELECT query. This means all the column values for every
record will be retrieved.
You will get the following output after executing the above query:
3. Update:
In CRUD operations, 'U' is an acronym for the update, which means making updates to the
records present in the SQL tables. So, we will use the UPDATE command to make changes
in the data present in tables.
Syntax:
Example: Write a query to update an employee's last name as 'Bose', whose employee id is 6.
Here in the SELECT query, we have used the SET keyword to update an employee's last
name as 'Bose'. We want to update an employee's last name only for the employee with
id 6, so we have specified this condition using the WHERE clause.
4. Delete:
In CRUD operations, 'D' is an acronym for delete, which means removing or deleting the
records from the SQL tables. We can delete all the rows from the SQL tables using the
DELETE query. There is also an option to remove only the specific records that satisfy a
particular condition by using the WHERE clause in a DELETE query.
Example:Write a query to delete the employee record from the employee table whose
salary is above 34000.
Here we have applied the DELETE query on the employee table. We want to delete only
the employee record whose salary is 34000, so we have specified this condition using the
WHERE clause.
execute the SELECT query to ensure that the employee record with salary as 34000 is deleted
successfully.
To remove all the records from the employee table, we will execute the DELETE query on
the employee table.
➢ Execute the SELECT query to ensure that all the records are deleted
successfully from the employee table.
RESULT: Performed basic SQL queries by installing MySQL database on Rsapberry Pi.