0% found this document useful (0 votes)
21 views22 pages

IoT 7004

The document outlines a practical course on IoT and applications, focusing on Arduino and Raspberry Pi. It includes installation instructions, interfacing various components, and programming examples for projects such as controlling LEDs and creating a smart parking system. The content is structured with aims, procedures, and code snippets for hands-on learning experiences.
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)
21 views22 pages

IoT 7004

The document outlines a practical course on IoT and applications, focusing on Arduino and Raspberry Pi. It includes installation instructions, interfacing various components, and programming examples for projects such as controlling LEDs and creating a smart parking system. The content is structured with aims, procedures, and code snippets for hands-on learning experiences.
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/ 22

PACIFIC SCHOOL OF ENGINEERING

DEPARTMENT OF COMPUTER ENGINEERING

INDEX

Student Name:
Enrollment Number:
Subject Name (Code): IOT and Applications (3160716)

Sr. Page Date Sign


AIM No.
N.
1. Familiarization with Arduino/Raspberry Pi. 1-2

2. Introduction about the Arduino. 3-5

3. Installation of Raspberry Pi. 6-13


To Interface LED with Arduino and write a
4. program to blink 14
the LED/Bulb.
To Interface potentiometer with Arduino and
5. write a program to use of potentiometer to 15-16
control brightness of the LED/Bulb.
To Interface buzzer sensor with Arduino and
6. write a program to use of buzzer sensor to bip a 17
sound.
To Interface ultrasonic sensor with Arduino and
7. write a program to use of ultrasonic sensor to 18
measure a distance.

To Interface LCD with Arduino and write a


8. program to use of LCD to display a text. 19

To implement a smart parking system using


Raspberry Pi and Grove Pi kit that manages
9. vehicle entry and exit through UV sensors and a 20-21
servo-controlled barrier, while dynamically
updating slot availability.
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 1
AIM: Familiarization with Arduino/Raspberry Pi.

 Arduino IDE:

Step 1: Download File Arduino IDE Click the link below to download the Software: Arduino
IDE Software
o On that page, there are 3 download options for Windows.
o Windows Installer: The software will be installed in Windows operating system and
required admin access.
o Windows Zip file: To make a portable installation.
o Windows App: for Windows 8.1 or 10. I suggest the first option. because it directly installs
all your needs to use the Arduino IDE Software, and include drivers for the Arduino board.
If you choose the Zip file you need to install the driver manually.
o Click Windows Installer, then click "just download" or "Contribute & Download". After
the download is complete, open the installer file and start installing.

Step 2: License Agreement


o After the file is run, the "License Agreement" page will appear. You can read it, then click
"IAgree" to continue.
Step 3: Installation Option
o Check the component that you want to install and uncheck the components that you don't
want to install. Click "next" to continue.
Step 4: Installation Folder
o Arduino will automatically be installed in "C:\Program Files (x86) \Arduino". If you want
to change the folder, click "Browse" and select the desired folder. Click install to start the
installation.
Step 5: Installing Process
o The installation process is ongoing.
Step 6: Installation
o Complete If there is written "complete", it means that the installation process is complete.
o click "Close".
Step 7: Open Arduino IDE

1|Page
Internet of Things (3160716) Enrollment No: 221120107004

 Introduction

o Arduino is an open-source platform used for building electronics projects. Arduino consists
of both a physical programmable circuit board (often referred to as a microcontroller) and
a piece of software, or IDE (Integrated Development Environment) that runs on your
computer, used to write and upload computer code to the physical board.

o The Arduino platform has become quite popular with people just starting out with
electronics, and for good reason. Unlike most previous programmable circuit boards, the
Arduino does not need a separate piece of hardware (called a programmer) in order to load
new code onto the board -- you can simply use a USB cable. Additionally, the Arduino IDE
uses a simplified version of C++, making it easier to learn to program. Finally, Arduino
provides a standard form factor that breaks out the functions of the micro-controller into a
more accessible package.

Arduino Uno

2|Page
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 2

Aim : Introduction about the RaspberryPi.

 Introduction:

Raspberry Pi 3 Board

o Raspberry Pi is a small single board computer. By connecting peripherals like Keyboard,


mouse, display to the Raspberry Pi, it will act as a mini personal computer.

o Raspberry Pi is popularly used for real time Image/Video Processing, IoT based applications
and Robotics applications.

o Raspberry Pi is slower than laptop or desktop but is still a computer which can provide all
theexpected features or abilities, at a low power consumption.

o Raspberry Pi Foundation officially provides Debian based Raspbian OS. Also, they provide
NOOBS OS for Raspberry Pi. We can install several Third-Party versions of OS like
Ubuntu,Archlinux, RISC OS, Windows 10 IOT Core, etc.

3|Page
Internet of Things (3160716) Enrollment No: 221120107004

o Raspbian OS is official Operating System available for free to use. This OS is


efficiently optimized to use with Raspberry Pi. Raspbian have GUI which includes tools for
Browsing, Python programming , office, games etc.
o We should use SD card (minimum 8 GB recommended) to store the OS (operating System).

o Raspberry Pi is more than computer as it provides access to the on-chip hardware i.e. GPIOs
for developing an application. By accessing GPIO, we can connect devices like LED,
motors,sensors, etc and can control them too.

o It has ARM based Broadcom Processor SoC along with on-chip GPU (Graphics Processing
Unit).

o The CPU speed of Raspberry Pi varies from 700 to 1.2 GHz. Also, it has on- board SDRAM
that ranges from 256 MB to 1 GB.

o Raspberry Pi also provides on-chip SPI, I2C, I2S and UART modules. There are different
versions of raspberry pi available as listed below:

1. Raspberry Pi 1 Model A
2. Raspberry Pi 1 Model A+
3. Raspberry Pi 1 Model B
4. Raspberry Pi 1 Model B+
5. Raspberry Pi 2 Model B
6. Raspberry Pi 3 Model B
7. Raspberry Pi Zero

ELEMENTS OF RASPBERRY PI BOARDS :

a. Two USB 2.0 ports allows connecting peripherals and storage devices while
onemicro USB serve for powering device.

b. The 3.5mm analog audio jack allows connecting headphones and speakers to
theRaspberry Pi what is especially useful for audio and media player based projects.

c. Composite RCA port for attaching the yellow video cable from TV allows usingTV
as a monitor.

d. The High Definition Multi-media Interface (HDMI) port allows the Raspberry Pi to be
hooked up to high-definition televisions and monitors that support thetechnology. The
HDMI port provides digital video and audio output. 14 different video resolutions are
supported, and the HDMI signal can be converted to DVI, composite or SCART.

e. Support for DSI (Display Serial Interface) - Raspberry Pi can be expanded with display.
4|Page
Internet of Things (3160716) Enrollment No: 221120107004

f. Support for CSI (Camera Serial Interface) - Raspberry Pi can be expanded using camera.

o The GPIO (general purpose input and output) - The Raspberry Pi has 26-pin GPIO port
arranged in two rows containing 13 pins each, located on the top-left of the Pi’s printed circuit
board. The one row contains the even-numbered pins, and the other row contains the odd-
numbered pins.

 Raspberry Pi zero and Raspberry Pi are shown below:

Raspberry Pi Zero

Raspberry Pi Board

5|Page
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 3
AIM: INSTALLATION OF RASPBERRY PI

 Prerequisites for Installing Raspberry Pi OS on A Raspberry Pi 4

o Before you install Raspberry Pi OS on your Raspberry Pi 4, you need to make sure that you have
all of the necessary components. First and foremost, you will need a Raspberry Pi 4, which is
available in 1GB, 2GB, 4GB, and 8GB RAM variants. You will also need a power supply and a
microSD card with at least 8GB of storage capacity or USB storage with the same storage
requirements. Additionally, you will need a micro HDMI cable, a USB keyboard and mouse, and
a compatible monitor.

 Hardware :

a. Raspberry Pi Board: Well, you can use any Raspberry Pi module 4, or 400.
Preferably, Raspberry Pi 3 and 4 with 4 GB RAM.
b. Micro SD Card with Card Reader: This is to write the Raspberry Pi OS image.
c. USB Drive (Optional): This is to install Ubuntu. It is optional. This is required only if
you boot your Pi from USB storage.
d. IO Peripheral Devices: Keyboard, Mouse, HDMI Cable, Ethernet Cable, and USB
Cable, depending on your requirements.
e. PC or Mac with an Internet connection: This is required to download the Raspberry Pi
Imager application and write the Raspberry Pi OS image to the SD Card or USB Storage
Drive using the Imager application.

 Software :

a. Raspberry imager: A free utility released by Raspberry Pi Imager application for


flashing content to SD cards or USB drives.
b. Internet: An Internet connection is a must to have to download the Raspberry Pi
Imager and write the Raspberry Pi OS to the SD Card or USB Storage Drive.

6|Page
Internet of Things (3160716) Enrollment No: 221120107004

 Install Raspberry Pi OS on A Raspberry Pi 4


1. Download and Install the Raspberry Pi Imager application

o Raspberry Pi Imager is a quick and easy way to install Raspberry Pi OS and other operating
systems to a microSD card or USB drive. Watch this 45-second video to learn how to
install an operating system using Raspberry Pi Imager. the Raspberry Pi Imager application
to a computer with an SD card reader. run the installer app and follow a few instructions to
Install Raspberry Pi Imager. Put the SD card or USB drive you’ll use to install Raspberry
Pi OS.

2. Run the Raspberry Pi Imager application

o Upon installation, when you run the Imager application, you will be greeted
with this window.

7|Page
Internet of Things (3160716) Enrollment No: 221120107004

3. Choose Raspberry Pi OS Image on the Raspberry Pi

o Click on the Choose OS button on the Imager application, select the Raspberry Pi OS
(Other) option then click on Raspberry Pi OS variant you want. You will see a list of
Raspberry Pi OS versions. Choose the one you want to go with.

o Raspberry Pi Lite: Raspberry Pi Lite is a version of the Raspberry Pi OS that only


includes the essential components and features. It is designed to offer users support for
their projects while reducing system resource usage, making it ideal for those who
prioritize performance over features.
o Raspberry Pi OS Full: This version of the operating system includes all the features
available with Raspberry Pi OS Lite along with the full range of applications and
functionalities. It is especially suitable for those who want access to a wide variety of
software packages, as it comes with an extensive library of open-source applications.
o Raspberry Pi OS (Legacy): This version was released alongside the original Raspberry
Pi and is an outdated version of the operating system. As such, it is no longer supported
by the Raspberry Pi Foundation and should only be used if absolutely necessary.

8|Page
Internet of Things (3160716) Enrollment No: 221120107004

4. Choose the Storage

o Click on the Choose Storage button on the Imager application. That will show up on the
list of connected micros SD cards or USB storage devices. Select the one you want to
install Raspberry Pi OS.

5. Write the Raspberry Pi OS image to the storage


o Click on the Write button to start the writing process.

9|Page
Internet of Things (3160716) Enrollment No: 221120107004

6. Raspberry Pi OS image is being written to the USB storage

7. Raspberry Pi OS image is being verified

10 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

8. Raspberry Pi OS image is written to the USB storage drive

9. Boot the Raspberry Pi inserting the USB drive

11 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

10. Raspberry Pi OS is in the boot process

11. System Configuration Wizard


o Upon the completion of the boot process. Raspberry Pi OS will throw a system
configuration wizard. Raspberry Pi OS will ask for several configurations to be set up.
You should need to Select the preferred settings to configure.

o The configuration wizard starts from the Language selection all the way it goes to the
keyboard, network, time zone, and login user account settings.

12 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

12. Reboot the Raspberry Pi


Upon the completion of the set up process, system will ask to reboot to complete the process.
Click on the Reboot button to continue Reboot.

13. Raspberry Pi OS is running on the Raspberry Pi


That’s it. Immaterially, upon login, you will be greeted with this desktop screen.

13 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 4
Aim: To Interface LED with Arduino and write a program to blink the
LED/Bulb.

 Program:

import time
from grovepi import *

led = 7 # Digital port D7

pinMode(led, "OUTPUT") # Set the LED pin mode

while True:
digitalWrite(led, 1) # Turn LED ON
time.sleep(0.5) # Wait for 0.5 seconds
print("LED is ON")

digitalWrite(led, 0) # Turn LED OFF


time.sleep(0.5) # Wait for 0.5 seconds
print("LED is OFF")

 Output:

Connection of LED
14 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 5
Aim: To Interface potentiometer with Arduino and write a program to
use of potentiometer to control brightness of the LED/Bulb.

 Program:
import time
import grovepi

# Define ports
potentiometer = 0 # A0 port
led = 5 # D5 port

# Set pin modes


grovepi.pinMode(potentiometer, "INPUT")
grovepi.pinMode(led, "OUTPUT")
time.sleep(1)

# Constants
adc_ref = 5 # Reference voltage of ADC
grove_vcc = 5 # VCC of Grove interface
full_angle = 300 # Full value of the rotary angle (300 degrees)

while True:
try:
# Read analog value from potentiometer
sensor_value = grovepi.analogRead(potentiometer)

# Calculate voltage
voltage = round(float(sensor_value) * adc_ref / 1023, 2)

# Calculate angle in degrees


degrees = round((voltage / grove_vcc) * full_angle, 2)

# Map degrees to 0–255 for LED brightness


brightness = int(degrees / full_angle * 255)

# Write PWM value to LED


grovepi.analogWrite(led, brightness)

15 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

# Print sensor details


print("sensor_value = %d voltage = %.2f degrees = %.1f brightness = %d" %
(sensor_value, voltage, degrees, brightness))

except KeyboardInterrupt:
grovepi.analogWrite(led, 0)
break

except IOError:
print("Error")

 Output:

Connection of potentiometer

16 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 6
Aim: To Interface buzzer sensor with Arduino and write a program
to use of buzzer sensor to bip a sound.

 Program:

import time
from grovepi import *

buzzer = 4 # Digital port D4


pinMode(buzzer, "OUTPUT") # Set pin mode to output
time.sleep(1)

while True:
try:
digitalWrite(buzzer, 1) # Turn buzzer ON
time.sleep(0.5)

digitalWrite(buzzer, 0) # Turn buzzer OFF


time.sleep(1)

except Exception as e:
print("Error:", e)

 Output:

Connection of buzzer

17 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 7
Aim: To Interface ultrasonic sensor with Arduino and write a
program to use of ultrasonic sensor to measure a distance.

 Program:
import grovepi
import time

grovepi.set_bus("RPI_1") # Optional: Only needed if you're using a specific I2C bus

ultrasonic_ranger = 4 # Digital port D4

while True:
try:
distance = grovepi.ultrasonicRead(ultrasonic_ranger)
print("Distance: {} cm".format(distance))

except Exception as e:
print("Error: {}".format(e))

time.sleep(0.1)

 Output:

Connection of ultrasonic sensor


18 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 8
Aim: To Interface LCD with Arduino and write a program to use of
LCD to display a text.

 Program:

from grove_rgb_lcd import *


import time

x = "Hello"
setRGB(137, 207, 240) # Light blue background

for i in x:
setText(str(i)) # Display one letter at a time
time.sleep(1.0)

 Output:

Connection of LCD

19 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

PRACTICAL 9

Aim: To implement a smart parking system using Raspberry Pi and Grove Pi


kit that manages vehicle entry and exit through UV sensors and a servo-
controlled barrier, while dynamically updating slot availability.

 Theory:
o Smart parking systems optimize urban mobility by automating parking space management.
Two UV sensors at the entry and exit of a parking lot control movement of vehicles. When
a vehicle is approaching the entry sensor, the system opens the gate and decreases available
slots. On exit, the sensor increases the number of slots. Sensor inputs, servo control, and
logic are handled by a Raspberry Pi (with Grove Pi kit). Available slots are displayed on a
screen. This approach does not use individual sensors, making it economical parking
technology.

 Components Required:

a. Raspberry Pi with Grove Pi Kit


b. 2 × UV Sensors (for vehicle detection at entry and exit)
c. 1 × Servo Motor (for barrier control)
d. 1 × LED (status or gate indicator)
e. Jumper wires
f. Python (programming language)

 Implementation:

Smart Parking System

20 | P a g e
Internet of Things (3160716) Enrollment No: 221120107004

 Flow Chart:

 Procedure:
1. Set up the Raspberry Pi and install the required libraries.
2. Connect the UV sensors to the Grove Pi input ports — one for entry and one for exit.
3. Connect the servo motor to a PWM-compatible output port for gate movement.
4. Attach an LED (optional) to indicate gate operation.
5. Write Python code to:
o Monitor UV sensor triggers
o Control the servo motor
o Update and display the slot count
o Prevent entry if slots = 0
6. Upload the code and run the system.
7. Test the system by simulating multiple vehicle entries and exits.

 Observations:

Event Entry Sensor Exit Sensor Available Slot Gate Status

System Start - - 2 Close


1 Car Enters Triggered - 1 Opens
1 More Car Enters Triggered - 0 Opens
1 Car Exits - Triggered 1 Opens
1 Car Enters Triggered - 0 Opens
Max Cars Enter - - 0 Blocked

 Conclusion:
SmartPark demonstrates a scalable and budget-friendly parking solution by leveraging basic
sensors and microcontroller logic. It is ideal for small-scale parking lots with limited hardware
needs.

21 | P a g e

You might also like