0% found this document useful (0 votes)
32 views15 pages

Iot Practical

The document is a journal submitted by Afreen Bano Sagri for the Major course in Internet of Things (IoT) as part of her BSc. IT program. It includes a certificate of completion, an index of practical topics, and detailed procedures for various projects involving Raspberry Pi, such as setting up the device, programming in Python, controlling LEDs, and using an ultrasonic sensor. The journal serves as a practical guide for hands-on learning in IoT applications.

Uploaded by

darshuparmar67
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)
32 views15 pages

Iot Practical

The document is a journal submitted by Afreen Bano Sagri for the Major course in Internet of Things (IoT) as part of her BSc. IT program. It includes a certificate of completion, an index of practical topics, and detailed procedures for various projects involving Raspberry Pi, such as setting up the device, programming in Python, controlling LEDs, and using an ultrasonic sensor. The journal serves as a practical guide for hands-on learning in IoT applications.

Uploaded by

darshuparmar67
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/ 15

JOURNAL

IN THE MAJOR COURSE


INTERNET OF THINGS (IoT)
SUBMITTED BY
AFREEN BANO SAGRI
OF
TY BSc. IT
TDIT-055A
SEMESTER V
UNDER THE GUIDANCE OF
Asst. Professor Vishesh Shrivastava
ACADEMIC YEAR
2024 – 2025

1|Page
CERTIFICATE

This is to certify that AFREEN BANO SAGRI of THIRD year of


INFORMATION TECHNOLOGY. Div.: A Roll No. TDIT055A of
Semester V (2024 - 2025) has successfully completed the Journal for
the Major course Internet of Things (IoT) as per the guidelines of
KES’ Shroff College of Arts and Commerce, Kandivali (W), Mumbai-
400067.

Teacher In-charge: Principal


Asst. Prof. Vishesh Shrivastava Dr. Lily Bhushan

2|Page
INDEX

SR NO TOPIC DATE SIGN

1 Setting up the Raspberry Pi


2 Installing the operating system on
Raspberry Pi
3 Basic Python programming
exercises on Raspberry Pi
4 Controlling an LED with
Raspberry Pi
5 LED chaser using a Raspberry Pi
board
6 Setting up Wi-Fi connections on
Raspberry Pi
7 Reading and displaying sensor
data

3|Page
PRACTICAL NO: - 1

AIM: Setting up the Raspberry Pi


Objective: To successfully set up the hardware and software required to use a Raspberry Pi.

Requirements:
- Raspberry Pi 3/4
- MicroSD card (at least 16 GB)
- MicroSD card reader
- Power supply
- HDMI cable
- Monitor or TV
- USB keyboard and mouse

Steps:
1. Insert the microSD card into the card reader and connect it to your computer.
2. Download the Raspberry Pi Imager from the official Raspberry Pi website.
3. Use the Imager to write the operating system (e.g., Raspberry Pi OS) to the microSD card.
4. Insert the microSD card into the Raspberry Pi, connect peripherals (keyboard, mouse,
monitor), and power on the device.

4|Page
PRACTICAL NO: - 2

AIM: Installing the Operating System on Raspberry Pi

Objective: To install and boot the Raspberry Pi OS on the Raspberry Pi.

Requirements:
- A prepared microSD card with Raspberry Pi OS.

Steps:
1. After inserting the microSD card into the Raspberry Pi, power it on.
2. On the first boot, you'll be prompted to complete the setup wizard.
3. Configure language, time zone, and Wi-Fi settings (if applicable).
4. Update the system by opening the terminal and running:
bash
sudo apt update
sudo apt upgrade

5. After updates are complete, restart the Raspberry Pi.

5|Page
PRACTICAL NO: - 3

AIM: Basic Python Programming Exercises on Raspberry Pi


Objective: To introduce basic Python programming exercises using the Thonny IDE on
Raspberry Pi. Requirements:
- Thonny Python IDE (pre-installed on Raspberry Pi OS).

Exercises:
1. Hello World Program:
print("Hello, World!")

2. Basic Arithmetic Operations:


a = 10
b = 20
sum = a + b
print("Sum:", sum)
3. Simple Loop:
for i in range(5):
print("Iteration:", i)

6|Page
PRACTICAL NO: - 4

AIM: Controlling an LED with Raspberry Pi


Objective: To control the state of an LED using the GPIO pins of the Raspberry Pi.

Requirements:
- Breadboard
- LED
- 220Ω resistor
- Jumper wires
- GPIO pins on Raspberry Pi
Steps:
1. Connect the positive leg of the LED to GPIO pin 17 and the negative leg to a resistor
connected to the ground (GND) pin.

7|Page
2. Open Thonny and run the following code to turn the LED on and off :
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)

while True:
GPIO.output(17, GPIO.HIGH) LED on
time.sleep(1)
GPIO.output(17, GPIO.LOW) LED off
time.sleep(1)

OUTPUT:-

8|Page
PRACTICAL NO: - 5

AIM: LED Chaser Using Raspberry Pi

Objective: To create an LED chaser effect using multiple LEDs connected to the Raspberry
Pi.

Requirements:
- 5 LEDs
- 5 resistors (220Ω)
- Jumper wires
- Breadboard
Steps:
1. Connect 5 LEDs to GPIO pins (e.g., 17, 18, 27, 22, 23).
2. Write a Python script to turn each LED on and off in sequence:
import RPi.GPIO as GPIO
import time

leds = [17, 18, 27, 22, 23]

GPIO.setmode(GPIO.BCM)
for pin in leds:
GPIO.setup(pin, GPIO.OUT)

while True:
for pin in leds:
GPIO.output(pin, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(pin, GPIO.LOW)

9|Page
OUTPUT:-

10 | P a g e
PRACTICAL NO: - 6

AIM : Setting up Wi-Fi Connections on Raspberry Pi


Objective: To configure Wi-Fi on Raspberry Pi for internet access.

Steps:
1. Open the Raspberry Pi terminal.
2. Enter the command to open the Raspberry Pi configuration tool:
sudo raspi-config

3. Select "Network Options" and then "Wi-Fi."

4. Enter your Wi-Fi network's SSID and password.

5. Reboot the Raspberry Pi to apply the changes.

11 | P a g e
PRACTICAL NO: - 7
AIM: Reading and Displaying Distance Using Ultrasonic Sensor
Objective
The objective of this practical is to interface the ultrasonic sensor with Raspberry Pi and write
a Python program using Thonny to calculate and display the distance of an object based on
the time taken by sound waves to reflect back to the sensor.

Requirements
- Raspberry Pi (any model with GPIO support)
- HC-SR04 Ultrasonic Sensor
- Breadboard
- Jumper Wires
- Resistors: 330Ω, 470Ω
- Thonny IDE (pre-installed on Raspberry Pi OS)

Theory
The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object. It sends out
an ultrasonic wave, which reflects back when it hits an object. The sensor then measures the
time taken for the wave to return and calculates the distance using the formula:

Where:
- Time is the time taken by the ultrasonic wave to travel to the object and back.
- 34300 is the speed of sound in cm/s.

The distance is divided by 2 because the wave travels to the object and back.

12 | P a g e
Circuit Diagram

- Connect the VCC of the ultrasonic sensor to the 5V pin of the Raspberry Pi.
- Connect the GND of the sensor to the GND pin of the Raspberry Pi.
- Connect the Trig pin of the sensor to GPIO 23.
- Connect the Echo pin of the sensor to GPIO 24 (via a voltage divider using 330Ω and 470Ω
resistors to drop the 5V signal to 3.3V for the Pi).

Connections:

13 | P a g e
Procedure
1. Connect the Hardware
- Use jumper wires to connect the VCC, GND, TRIG, and ECHO pins of the ultrasonic
sensor to the appropriate Raspberry Pi GPIO pins as mentioned above.
- Use resistors (330Ω and 470Ω) in series between the ECHO pin and GPIO pin 24 to lower
the voltage to 3.3V, which is safe for the Raspberry Pi.

2. Write the Python Code


Open the Thonny IDE on Raspberry Pi and write the following Python code to calculate
and display the distance:
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

TRIG = 23
ECHO = 24

print("Distance Measurement In Progress")

GPIO.setup(TRIG, GPIO.OUT)
GPIO.setup(ECHO, GPIO.IN)

try:
while True:
GPIO.output(TRIG, False)
print("Waiting For Sensor To Settle")
time.sleep(2)

GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)

while GPIO.input(ECHO) == 0:
pulse_start = time.time()

while GPIO.input(ECHO) == 1:
pulse_end = time.time()

pulse_duration = pulse_end - pulse_start


distance = pulse_duration * 17150
distance = round(distance, 2)

14 | P a g e
print("Distance:", distance, "cm")
time.sleep(1) # Adding a delay between readings

except KeyboardInterrupt:
print("Measurement stopped by user")
GPIO.cleanup()

3. Run the Program


- Run the script in Thonny.
- The program will continuously calculate and print the distance of any object placed in
front of the sensor in centimeters.
4. Observe the Output
- The distance of the object from the sensor is displayed in real-time in the terminal window
of the Thonny IDE.
5. Terminate the Program
- Press Ctrl + C in the terminal to stop the program.

Observation
When an object is placed in front of the sensor, the distance is calculated and displayed as
expected. The ultrasonic sensor accurately detects the distance of objects placed within its
range.
Result
The practical was successfully completed. We interfaced the HC-SR04 ultrasonic sensor with
the Raspberry Pi, were able to measure, and display the distance of an object in real-time
using a Python script.

15 | P a g e

You might also like