SRI SAI RAM ENGINEERING COLLEGE
SAI LEO NAGAR, WEST TAMBARAM, CHENNAI-44
           (An Autonomous Institution)
   NAME                :
   REGISTER NUMBER :
          20AIPL503 – IOT LABORATORY
                (III YEAR / V SEM)
               (BATCH: 2022 – 2026)
 B.E CSE (ARTIFICIAL INTELLIGENCE AND MACHINE
                   LEARNING)
           ACADEMIC YEAR: 2024 – 2025
                                Certificate
                                             Register No. :
        Certif ied that this is the Bonafide Record of the work done by
Mr./Ms.                                                        in the Semester - V
Of Degree Course B.E CSE(ARTIFICIAL INTELLIGENCE & MACHINE LEARNING)
in the 20AIPL503 – IOT LABORATORY during the academic year ___________.
 Station : Chennai - 600 044
 Date     :
  STAFF IN-CHARGE                                 HEAD OF THE DEPARTMENT
 Submitted for University Practical Examination held on
 at Sri Sai Ram Engineering College, Chennai – 600 044.
    INTERNAL EXAMINER                                     EXTERNAL EXAMINER
                                INDEX
EXP                                                       PAGE
       DATE       NAME OF THE EXPERIMENT                         SIGNATURE
NO.                                                       NO.
                 Sense the Available Networks Using
 1.                                                        1
                              Arduino
               Measure the Distance Using Ultrasonic
 2.                                                        4
              Sensor and Make Led Blink Using Arduino
               Detect the Vibration of an Object Using
 3.                                                        7
                              Arduino
               Connect with the Available Wi-Fi Using
 4.                                                        10
                              Arduino
              Sense a Finger When it is Placed on Board
 5.                                                        13
                           Using Arduino
 6.            Temperature Notification Using Arduino      16
               LDR to Vary the Light Intensity of LED
 7.                                                        19
                           Using Arduino
                  MySQL Database Installation in
 8.                                                        22
                            Raspberry Pi
                 SQL Queries by Fetching Data from
 9.                                                        25
                      Database in Raspberry Pi
                Switch Light On and Off Based on the
 10.                                                       27
                  Input of User Using Raspberry Pi
 EX. NO. 1
                             SENSE THE AVAILABLE NETWORKS USING ARDUINO
 DATE:
AIM:
To write a program to sense the available networks using Arduino.
COMPONENTS REQUIRED:
    1. WiFi Module or ESP 8266 Module.
    2. Connecting cable or USB cable.
ALGORITHM:
    1. Start ->Arduino IDE -1.8.8
    2. Then enter the coding in Arduino Software.
    3. Compile the coding in Arduino Software.
    4. Connect the USB cable to WiFi module.
    5. Select tools -> select board -> Module node Mch.0.9CE ESP 1.2 modules -> select port.
    6. Upload the coding in ESP Module node Mch.0.9CE and open serial monitor to view the
       available networks.
    7. Stop the process.
BLOCK DIAGRAM:
PROGRAM:
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
                                                 1
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
}
void loop()
{
Serial.println("scan start");
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0) {
Serial.println("no networks found");
}
else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
delay(10);
}
}
Serial.println("");
                                             2
delay(5000);
}
OUTPUT:
RESULT:
Thus, the output for sensing the available networks using Arduino has been successfully
executed.
                                                3
 EX. NO. 2             MEASURE THE DISTANCE USING ULTRASONIC SENSOR AND
                                MAKE LED BLINK USING ARDUINO
 DATE:
AIM:
To write a program to measure the distance using an ultrasonic sensor using Arduino.
COMPONENTS REQUIRED:
   1. Ultrasonic distance sensor (28015 REVC)-1 Nos.
   2. Jumper wires-4 Nos.
   3. Connecting cable-1 Nos.
   4. Arduino UNO R3-1 Nos.
ALGORITHM:
   1. Connect the ultrasonic sensor to digital pin 9 (trigPin) and pin 3 (echoPin) on the
       Arduino.
   2. Set trigPin as output and echoPin as input in the code.
   3. Initialize serial communication at 9600 baud in the setup function.
   4. Send a 10-microsecond pulse from the trigPin to trigger a measurement.
   5. Measure the echo duration using pulseIn on the echoPin.
   6. Calculate the distance with the formula: distance = duration * 0.034 / 2.
   7. Print the distance to the serial monitor.
   8. Add a 1-second delay before the next measurement.
BLOCK DIAGRAM:
                                                  4
CONNECTION DIAGRAM:
PROGRAM:
const int trigPin = 9;
const int echoPin = 3;
long duration;
int distance;
void setup() {
    Serial.begin(9600);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);\
}
void loop() {
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH);
    distance = duration * 0.034 / 2;
    Serial.print("Distance: ");
    Serial.print(distance);
                                         5
    Serial.println(" cm");
    delay(1000);
}
OUTPUT:
RESULT:
Thus, the output for measuring the distance using ultrasonic sensor using Arduino has been
successfully executed.
                                                6
 EX. NO. 3
                         DETECT THE VIBRATION OF AN OBJECT USING ARDUINO
 DATE:
AIM:
To write a program to detects the vibration of an object with sensor using Arduino.
COMPONENTS REQUIRED:
   1. RBX Vibration sensor – 1 Nos.
   2. Jumper wires – 3 Nos.
   3. USB cable-1 Nos.
   4. Arduino UNO R3-1 Nos.
ALGORITHM:
   1. Connect the RBX vibration sensor to analog pin A0 on the Arduino.
   2. Define the vibration sensor pin as vib and set it as an input in the code.
   3. Initialize serial communication at 9600 baud in the setup function.
   4. In the loop, read the vibration measurement using pulseIn on the vib pin.
   5. Add a slight delay of 50 microseconds after the measurement.
   6. Print the vibration measurement value in Hertz to the serial monitor.
BLOCK DIAGRAM:
                                                  7
CONNECTION DIAGRAM:
PROGRAM:
int vib=A0;
void setup()
{
  pinMode(vib,INPUT);
  Serial.begin(9600);
}
void loop()
{
  long measurement=pulseIn(vib,HIGH);
  delayMicroseconds(50);
  Serial.print("VIB:v001:hertz:");
  Serial.println(measurement);
}
                                        8
OUTPUT:
RESULT:
Thus, the output for detecting the vibrations of an object with vibration sensor using Arduino
has been successfully executed.
                                                 9
 EX. NO. 4
                            CONNECT WITH THE AVAILABLE WI-FI USING ARDUINO
 DATE:
AIM:
To write a program to connect with the available Wi-Fi using Arduino.
COMPONENTS REQUIRED:
   1. WiFi Module or ESP 8266 Module.
   2. Connecting cable or USB cable.
ALGORITHM:
   1. Start ->Arduino IDE -1.8.8.
   2. Include the file directory ESP 8266 in Arduino.
   3. Then enter the coding to Wi-Fi module or ESP 8266 module.
   4. Then enter the coding in Arduino software.
   5. Connect the USB cable to the Wi-Fi module and the Arduino connected system with
       available network.
   6. Select tools -> Select board -> Node MCU 0.9C ESP-12 module and then Select -> Port.
   7. Upload the coding to ESP 8266 module and open serial monitor to View the available
       network connects IP address.
   8. Stop the process.
BLOCK DIAGRAM:
PROGRAM:
#include <ESP8266WiFi.h>
const char* ssid = "Error";
const char* password = "networkerror";
                                               10
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println('\n');
WiFi.begin(ssid, password);
Serial.print("Connecting to ");
Serial.print(ssid);
Serial.print(“...") int i = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(++i);
Serial.print(' ');
}
void loop() {
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP());
}
}
                                             11
OUTPUT:
RESULT:
Thus, the output for connecting with the available Wi-Fi using Arduino has been successfully
executed.
                                               12
 EX. NO. 5                SENSE A FINGER WHEN IT IS PLACED ON BOARD USING
                                             ARDUINO
 DATE:
AIM:
To write a program to sense a finger when it is placed on the board Arduino.
COMPONENTS REQUIRED:
   1. Touch sensor (HW139) – 1 Nos.
   2. jumper wires – 3 Nos.
   3. USB cable – 1 Nos.
   4. Arduino UNO R3 – 1 Nos
ALGORITHM:
   1. Connect the touch sensor (HW139) to digital pin 2 on the Arduino.
   2. Set SENSOR_PIN to 2 and initialize lastState and currentState variable.
   3. Initialize serial communication at 9600 baud and configure SENSOR_PIN as input.
   4. Continuously read the current state of the touch sensor in the loop.
   5. Detect a change from LOW to HIGH to indicate the sensor is touched.
   6. Print "The sensor is touched." to the serial monitor when touched.
   7. Update lastState with currentState for the next iteration
BLOCK DIAGRAM:
                                                13
CONNECTION DIAGRAM:
PROGRAM:
const int SENSOR_PIN = 2;
int lastState = LOW;
int currentState;
void setup() {
    Serial.begin(9600);
    pinMode(SENSOR_PIN,INPUT);
}
void loop() {
    currentState = digitalRead(SENSOR_PIN);
    if(lastState == LOW && currentState == HIGH)
    Serial.println("The sensor is touched.");
    lastState = currentState;
}
                                                14
OUTPUT:
RESULT:
Thus, the output for sensing a finger when it is placed in board Arduino has been successfully
executed.
                                                15
 EX. NO. 6
                               TEMPERATURE NOTIFICATION USING ARDUINO
 DATE:
AIM:
To write a program to get temperature notification using Arduino.
COMPONENTS REQUIRED:
   1.   Temperature and humidity sensor (DH11) – 1 Nos.
   2.   Jumper wires – 3 Nos.
   3.   USB cable – 1 Nos.
   4.   Arduino UNO R3 – 1 Nos.
ALGORITHM:
   1. Connect the DHT11 temperature and humidity sensor to digital pin 2 on the Arduino.
   2. Include the DHT library and define DHTPIN as 2 and DHTTYPE as DHT11 in the code.
   3. Initialize the DHT sensor in the setup function and start serial communication at 9600
        baud.
   4. In the loop, read humidity and temperature from the DHT sensor.
   5. Check if the readings are valid; if not, print an error message.
   6. Print the temperature in Celsius and humidity percentage to the serial monitor.
   7. Add a delay of 2 seconds before the next reading.
BLOCK DIAGRAM:
                                                 16
CONNECTION DIAGRAM:
PROGRAM:
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
   Serial.begin(9600);
   dht.begin();
 }
    void loop() {
     float humidity = dht.readHumidity();
      float temperatureC = dht.readTemperature();
     if (isnan(humidity) || isnan(temperatureC)) {
       Serial.println("Failed to read from DHT sensor!");
       return;
     }
     Serial.print("Temperature: ");
     Serial.print(temperatureC);
     Serial.println(" °C");
     Serial.print("Humidity: ");
     Serial.print(humidity);
     Serial.println(" %");
     delay(2000);
}
                                                 17
OUTPUT:
RESULT:
Thus, the output to get temperature notification using Arduino has been successfully executed.
                                                18
 EX. NO. 7
                       LDR TO VARY THE LIGHT INTENSITY OF LED USING ARDUINO
 DATE:
AIM:
To write a program for LDR to vary the light intensity of LED using Arduino.
COMPONENTS REQUIRED:
   1. LDR Light sensor module – 1 Nos.
   2. Jumper wires – 5 Nos.
   3. LED – 1 Nos.
   4. Arduino UNO R3 – 1 Nos.
ALGORITHM:
    1. Connect the LDR to analog pin A0 and the LED to digital pin D2 on the Arduino.
    2. Set pin A0 as the LDR input and pin D2 as the LED output in the code.
    3. Continuously read the light level from the LDR connected to A0.
    4. Turn on the LED (D2) when it’s dark and turn it off when there’s light.
    5. Display the LDR readings in the serial monitor.
    6. Add a short delay (e.g., 100 ms) between readings for stability.
BLOCK DIAGRAM:
                                                19
CONNECTION DIAGRAM:
PROGRAM:
const intldr_pin = 3; const int
led_pin = 2;
void setup () {
pinMode(ldr_pin, INPUT);
pinMode(led_pin, OUTPUT); Serial.begin(9600);
}
void loop () {
if( digitalRead( ldr_pin ) == 1){
digitalWrite(led_pin, HIGH);
}
else {
digitalWrite(led_pin , LOW);
}
Serial.println(digitalRead( ldr_pin ));
delay (100);
}
                                           20
OUTPUT:
RESULT:
Thus, the output for LDR to vary the light intensity of LED using Arduino has been successfully
executed.
                                                21
 EX. NO. 8
                            MYSQL DATABASE INSTALLATION IN RASPBERRY PI
 DATE:
AIM:
To write a program to install MySQL database in Raspberry pi.
COMPONENTS REQUIRED:
   1. Raspberry pi
   2. HDMI
   3. Micro USB power input.
ALGORITHM:
   1. Start the process.
   2. Connect micro USB power input to Raspberry pi.
   3. Connect HDMI to the system to act as monitor for Raspberry pi.
   4. Connect USB port to mouse and keyboard.
   5. Then enter the coding in terminal for installing MySQL to Raspberry pi.
   6. Stop the process.
PROGRAM:
sudo apt-get install mysql-server sudo apt
update
sudo apt upgrade
sudo apt install mariadb-server
sudomysql_secure_installation sudomysql -u
root –p
OUTPUT:
                                              22
23
RESULT:
Thus, the output to install MySQL database in Raspberry pi has been successfully executed.
                                               24
 EX. NO. 9                 SQL QUERIES BY FETCHING DATA FROM DATABASE IN
                                            RASPBERRY PI
 DATE:
AIM:
To write a program to work with basic MySQL queries by fetching data from database in
Raspberry pi.
COMPONENTS REQUIRED:
   1. Raspberry pi
   2. HDMI
   3. Micro USB power input.
ALGORITHM:
   1. Start the process.
   2. Connect micro USB power input to Raspberry pi.
   3. Connect HDMI to the system to act as monitor for Raspberry pi.
   4. Connect USB port 2.0 to mouse and keyboard.
   5. Then enter the coding in the terminal to update and upgrade package using commands.
   6. Create database in MySQL and basic SQL queries by fetching data from database by
       using insert, update and delete queries.
   7. Stop the process.
PROGRAM:
sudomysql -u root –p
CREATE DATABASE exampledb;
CREATE USER 'exampleuser'@'localhost' IDENTIFIED BY 'pimylifeup';
CREATE TABLEBooks(Id INTEGER PRIMARY KEY, Title VARCHAR(100), Author
VARCHAR(60));
INSERT INTO Books(Title, Author) VALUES (1,‘War and Peace’, ‘Leo Tolstoy’);
SELECT * FROM Books;
UPDATE Books SET Author='Lev Nikolayevich Tolstoy' WHERE Id=1;
DELETE FROM Books2 WHERE Id=1;
                                                  25
OUTPUT:
RESULT:
Thus, the output to fetch data from database using SQL queries in Raspberry pi has been
successfully executed.
                                               26
 EX. NO. 10                SWITCH LIGHT ON AND OFF BASED ON THE INPUT OF USER
                                          USING RASPBERRY PI
 DATE:
AIM:
To write a program to switch light on when the input is 1 and switch the light off when the input
is 0 using Raspberry pi.
COMPONENTS REQUIRED:
   1. Raspberry pi
   2. Breadboard
   3. Jumperwires
   4. Resistor
   5. LED
ALGORITHM:
   1. Start the process.
   2. Connect micro USB power input to Raspberry pi.
   3. Connect HDMI to the system to act as monitor for Raspberry pi.
   4. Connect USB port 2.0 to mouse and keyboard.
   5. Enter the coding in the terminal for installing python and GPTO.
   6. Open notepad →enter coding →save as →file extension python or py.
   7. Copy file location → open terminal → paste file location in terminal → press enter.
   8. In the terminal window to get output enter 0 or 1, to switch light ON when the input is 1
       and switch light OFF when the input is 0 in breadboard using Raspberry pi.
   9. Stop the process.
PROGRAM:
sudo apt-get install python-pip sudo apt-get
install python-dev sudo pip install RPi.GPIO
sudo –i #python
importRPi.GPIO as GPIO import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
                                                 27
GPIO.setup(18,GPIO.OUT)
ip=int(input("enter the value: "))
ifip==1:
print "LED on"
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
elifip==0:
print "LED off"
GPIO.output(18,GPIO.LOW)
time.sleep(1)
OUTPUT:
RESULT:
Thus, the output to switch light ON/OFF using Raspberry pi has been successfully executed.
                                               28