Iot Practical Tyit
Iot Practical Tyit
Submitted by:
Submitted To :
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
CERTIFICATE
This is to certify that Mr./Miss Saifee Zoya Shamshad having Exam Seat No.
of B.Sc.IT (Semester V) has complete the Practical work in the subject of
“Internet of Things” during the Academic year 2022-23 under the guidance of
Mr.Rawool Vijay Anil being the Partial requirement for The fulfilment of the curriculum
of Degree of Bachelor of Science in Information Technology, University of Mumbai.
College Seal
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL NO.-0
AIM:
Starting Raspbian OS, Familiarising with Raspberry Pi Components and
interface, connecting to ethernet, Monitor, USB.
Solution:-
The Raspberry Pi Components:-
Raspberry Pi
ARM CPU/GPU
GPIO
RCA
Audio out
LEDs
USB
HDMI
Power
SD cardslot
Ethernet
Wi-Fi
Raspberry Pi:-
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer
monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that
enables people of all ages to explore computing, and to learn how to program in languages
like Scratch and Python.
The Raspberry Pi device looks like a motherboard, with the mounted chips and ports
exposed but it has all the components you need to connect input, output, and storage
devices and start computing.
The most recent model is the Raspberry Pi 3 Model B+, but other models include the
Raspberry Pi Model A, the Raspberry Pi Zero and the Raspberry Pi Zero WiFi.
Most models are capable of doing everything you would expect a desktop computer to do,
from browsing the internet and playing high-definition video, to making spreadsheets,
word-processing, and playing games.
The Raspberry Pi has sold tens of millions of units across the world and is used by everyone
from hackers, to engineers, students, hobbyists and scientists.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ARM CPU/GPU: This is a Broadcom BCM2835 System on a Chip (SoC) that's made up of
an ARM central processing unit (CPU) and a Videocore 4 graphics processing unit (GPU).
The CPU handles all the computations that make a computer work (taking input, doing
calculations and producing output), and the GPU handles graphics output.
GPIO: These are exposed general-purpose input/output connection points that will allow
the real hardware hobbyists the opportunity to tinker.
RCA: An RCA jack allows connection of analog TVs and other similar output devices.
Audio out: This is a standard 3.55-millimeter jack for connection of audio output devices
such as headphones or speakers. There is no audio in.
LEDs: Light-emitting diodes, for all of your indicator light needs.
USB: This is a common connection port for peripheral devices of all types (including your
mouse and keyboard). Model A has one, and Model B has two. You can use a USB hub to
expand the number of ports or plug your mouse into your keyboard if it has its own USB
port.
HDMI: This connector allows you to hook up a high-definition television or other
compatible device using an HDMI cable.
Power: This is a 5v Micro USB power connector into which you can plug your compatible
power supply.
SD cardslot: This is a full-sized SD card slot. An SD card with an operating system (OS)
installed is required for booting the device. They are available for purchase from the
manufacturers, but you can also download an OS and save it to the card yourself if you
have a Linux machine and the wherewithal.
Ethernet: This connector allows for wired network access and is only available on the
Model B.
Wi-Fi: WiFi, or 802.11, is a wireless protocol that was built with the intent of replacing
Ethernet using wireless communication over unlicensed bands. Its goal was to provide off-
the-shelf, easy to implement, easy to use short-range wireless connectivity with cross-
vendor interoperability.
LCD Monitor: A 16×2 display unlike a touchscreen or a regular LCD screen is best used
to display short messages or information. You will find it extremely handy when you only
need to display some essential data but don’t really need anything too large and expensive.
Starting Raspbian OS
Raspbian OS:-
Raspbian is the Raspberry Pi’s most popular operating system, a spin off of the Linux
distribution Debian that works well on the Raspberry Pi’s hardware.
Raspbian is a competent and versatile operating system that gives your Raspberry Pi all the
comforts of a PC: a command line, a browser, and tons of other programs.
You can use a Raspberry Pi running Raspbian as a cheap and effective home computer, or
you can use it as a springboard and turn your Raspberry Pi into any of countless other
functional devices, from wireless access points to retro gaming machines.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
3. SD Card Formatter.
Hardware Requirement:-
1. A Well Configured Desktop PC or Laptop
2. Memory Card Reader
3. SD Card minimum 8GB with Class C or 10.
STEP-1
Download all the required software from the following link
1. SD Card Formatter
https://www.sdcard.org/downloads/formatter_4/
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP-2
After downloading all components install SD card Formatter and Win32 Disk Imager
Double click on SD Card Formatter Setup
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Click on Yes
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP 3:
Unzip the file
The Raspbian disc image is compressed, so you’ll need to unzip it.
You can use any of the unzip tools to unzip the compressed file like WinRAR, Winzip7 and any
inbuilt windows zip file.
STEP 4
Format the SD Card with SD card Formatter tool
Attach SD Card with SD Card Reader and plug into the System
Open SD Card Formatter Tool
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP 5:
Write the disc image to your microSD card
Connect SD Card with SD Card Reader to the Desktop system
Open Win32 Disk Imager
Select ISO image file of Raspbian OS Which is extract in previous step and also select
appropriate device.
Click on Write
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
After successful write remove SD Card Reader from system and then remove SD Card from SD
Card Reader.
STEP 6:
Put the microSD card in your Pi and boot up
You’re ready to go! Put that sucker into your Rasberry Pi, plug in the peripherals and power source,
and enjoy.
The current edition to Raspbian will boot directly to the desktop. Your default credentials are
username pi and password raspberry.
STEP 7:
Startup the Raspbian OS
Insert into your Raspberry Pi and any other extra cords such as power, mouse, keyboard, Monitor,
Ethernet or Wi-Fi and the HDMI cord.
Power on the Raspberry Pi
Setting up the Pi
Please remember that after booting the Pi, there might be situations when the user credentials
like the "username" and password will be asked. Raspberry Pi comes with a default user name and
password and so always use it whenever it is being asked. The credentials are:
Login: pi
Password: raspberry
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
sudo tightvnserver
this command will ask you for a password to be set, enter tightvnc and confirm the same.
Now it will ask you for view only access say ’n’ for NO.
Now type the previous command again:
sudo tightvncserver
this will start the VNC server on your RPi machine, now note the number provided, this
number will be used to put the IP address and Port number while starting the Viewer
application.
11. Now to view the desktop of the RPi on your machine. Install the TightVNCviewer onto your
PC from this link: https://www.tightvnc.com/download.php
12. Choose the download according to your system, 32bit or 64bit processing. Also download
the DFM Mirage driver from the same page for best performance of the application.
For MAC users you can download the JAVA viewer Jar file and run the application.
13. While installing the TightVNCViewer application select typical install and click next. Enter
the first password as tightvnc and confirm the same, click on do not for the next set of
password and click install.
14. After installation run the tightvncviewer application. It will ask you for IP address and port
number. Put the IP address of your RPi and the port number as 590x. X is the number which
you noted down when you started the tightvncsever.
15. After you click on enter you’ll be prompted to enter the password, enter tightvnc as specified
while server installation. After a successful login you will be redirected to the Desktop of
RPi.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL No.-1
AIM:-
Displaying different LED patterns with Raspberry Pi.
Components Required:-
Raspberry Pi Model with its Power Supply
Jumper Wire
LED
Monitor
USB Keyboard
USB Mouse
Breadboard
Resistor
Circuit Diagram:-
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
time.sleep(4.5)
GPIO.output(led4,True)
print("Led 4 OFF")
time.sleep(5)
GPIO.output(led5,True)
print("Led 5 OFF")
time.sleep(5.5)
GPIO.cleanup()
2. Run from terminal for that we need to type the following command
sudo python BLINKLED.py
Note:-
Make sure that before running above code we should need to check current
working directory of terminal after that we navigate to the particular directory
where the BLINKLED.py file is present.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL No.-2
AIM:-
Displaying Time over 4-Digit 7-Segment Display using Raspberry Pi
Introduction:-
For displaying small amount of data we prefer to use 4-digit 7-Segment display.
7-Segment and 4-Digit 7-Segment Display Module:
7 Segment Display has seven segments in it and each segment has one LED inside it to display the
numbers by lighting up the corresponding segments. Like if you want the 7-segment to display the
number "5" then you need to glow segment a, f, g, c, and d by making their corresponding pins
high. There are two types of 7-segment displays: Common Cathode and Common Anode, here we
are using Common Cathode seven segment display.
Components Required:-
Raspberry Pi with Power Supply
TM1637 4-DIGIT Seven Segment Display
Jumper wire
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Circuit Design:-
OR
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
2. Unzip the file, copy the file on to an usb drive and copy paste the same into the
/home/pi/Documents/7segment folder of your RPi.
Step3:
Open the Source Code of clock.py and displayIP.py simultaneous by using Python
IDLE (3.5.6) and run the code and see the output.
Source Code:
#For Display the time
from time import sleep
import tm1637
try:
import thread
except ImportError:
import _thread as thread
# Initialize the clock (GND, VCC=3.3V, Example Pins are DIO-20 and CLK21)
Display = tm1637.TM1637(CLK=21, DIO=20, brightness=1.0)
try:
print ("Starting clock in the background (press CTRL + C to stop):")
Display.StartClock(military_time=False)
print ('Continue Python script and tweak Display!')
sleep(5)
Display.ShowDoublepoint(False)
sleep(5)
loops = 3
while loops > 0:
for i in range(0, 10):
Display.SetBrightness(i / 10.0)
sleep(0.5)
loops -= 1
Display.StopClock()
thread.interrupt_main()
except KeyboardInterrupt:
print ("Properly closing the clock and open GPIO pins")
Display.cleanup()
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
# Initialize the display (GND, VCC=3.3V, Example Pins are DIO-20 and
CLK21)
Display = tm1637.TM1637(CLK=21, DIO=20, brightness=0.3)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("gmail.com", 80))
IP = s.getsockname()[0]
s.close()
print ("IP of RasPi is")
print IP
# Separate on comma.
numbers = IP.split(".")
# Loop and print each city name.
loops = 3
while loops > 0:
for number in numbers:
Display.ShowInt(number)
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
time.sleep(2)
loops -= 1
Display.Clear()
time.sleep(2)
print('done.')
Display.cleanup()
On Display it will showing first 192. Then 168. Then 0. Then 122 Continuously
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL NO.-4
AIM:
Controlling Raspberry Pi with Telegram
SOLUTION:
HARDWARE REQUIREMENT:
Raspberry Pi 3 Model B
Jumper Wire
Breadboard
USB Keyboard
USB Mouse
LED
Ethernet Cable or Wi-Fi Connectivity
SOFTWARE REQUIREMENT:
Telegram App running on Mobile Phone
STEPS
Step 1: Open Telegram app in your system or mobile
1.1 Download and Open Telegram app in your system or mobile or we can use telegram web
also.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Important Note:
In above code you have to enter your access token key which is generated from step 1
Here is successful executed code now we have to connect LED with Raspberry Pi.
Step 6: Connect LED to Pi
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL No.-5
AIM:-
Setting up Wireless Access Point using Raspberry Pi
To setup the wireless access point created to provide (share) internet access to (with) connected
devices. So let’s begin creating Wi-Fi Hotspot with Raspberry Pi.
Required Components:
Hardware Requirement:
Raspberry Pi 2
8GB SD card
WiFi USB dongle
Ethernet cable
Power supply for the Pi.
Monitor (optional)
Keyboard (optional)
Mouse (optional)
Raspberry Pi the ability to serve as a wireless access point and to achieve this, we will need to
install and setup a software that equips the raspberry pi with this functionality along with a DHCP
server software to provide a network address for the devices which will be connected to the access
point.
Software Requirements:
Putty
The dnsmasq and the hostapd softwares
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Step 3:
Stop the software from Running
We don’t have the software configured yet there is no point running it, so we disable them from
running in the underground. To do this we run the following commands to stop the systemd
operation.
sudo systemctl stop dnsmasq
sudo systemctl stop hostapd
Step 4:
Configure a Static IP address for the wireless Port
Confirm the wlan port on which the wireless device being used is connected. For my Pi, the
wireless is on wlan0. Setting up the Raspberry Pi to act as a server requires us to assign a static
IP address to the wireless port. This can be done by editing the dhcpcd config file.
To edit the configuration file, run;
sudo nano /etc/dhcpcd.conf
Scroll to the bottom of the config file and add the following lines.
Interface wlan0
static ip_address=192.168.52.1/24
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Step 5:
Configure the dhcpcd server
To configure the dhcpcd server and provide it with the range of IP addresses to be assigned to
devices that connect to the wireless access point.
To do this, we need to edit the configuration file of the dnsmasq software but the config file of the
software contains way too much info and a lot could go wrong If not properly edited, so instead of
editing, we will be creating a new config file with just the amount of information that is needed to
make the wireless access point fully functional.
Before creating the new config file, we keep the old on safe by moving and renaming it.
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.old
Then launch the editor to create a new configuration file;
sudo nano /etc/dnsmasq.conf
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
with the editor launched, copy the lines below and paste in or type directly into it.
Interface = wlan0
dhcp-range = 192.168.52.2, 192.168.52.40, 255.255.255.0,24h
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
auth_algs=1
wpa=2
wpa_passphrase=nitcsc143
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
After the config file has been saved, we need to point the hostapd software to where the config file
has been saved. To do this, run;
sudo nano /etc/default/hostapd
Find the line with daemon_conf commented out.
Uncomment the DAEMON_CONF line and add the line below in between the quotes in front of
the “equal to” sign.
Step 7:
Fire it up
Since we disabled the two software initially, to allow us configure them properly, we need to restart
the system after configuration to effect the changes.
Use;
sudo systemctl start hostapd
sudo systemctl start dnsmasq
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Step 8:
Routing and masquerade for outbound traffic
We need to add routing and masquerade for outbound traffic.
To do this, we need to edit the config file of the systemctl by running:
sudo nano /etc/sysctl.conf
Uncomment this line net.ipv4.ip_forward=1
Next we move to masquerading the outbound traffic. This can be done by making some changes
to the iptable rule. To do this, run the following commands:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
then save the Iptables rule using:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Step 9:
Create Wireless Access Point on startup
To edit the rc.local file, run:
sudo nano /etc/rc.local
and add the following lines at the bottom of the system, just before the exit 0 statement
iptables-restore < /etc/iptables.ipv4.nat
Step 10:
Reboot! and Use
sudo reboot
Accessing the Internet from the Raspberry Pi’s Wi-Fi Hotspot
To implement this, we need to put a “bridge” in between the wireless device and the Ethernet
device on the Raspberry Pi (the wireless access point) to pass all traffic between the two interfaces.
To set this up, we will use the bridge-utils software. Install hostapd and bridge-utils. While we
have installed hostapd before, run the installation again to clear all doubts.
sudo apt-get install hostapd bridge-utils
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
When a bridge is created, a higher level construct is created over the two ports being bridged and
the bridge thus becomes the network device. To prevent conflicts, we need to stop the allocation
of IP addresses by the DHCP client running on the Raspberry Pi to the eth0 and wlan0 ports. This
will be done by editing the config file of the dhcpcd client to include denyinterfaces
wlan0 and denyinterfaces eth0 as shown in the image below.
The file can be edited by running the command;
sudo nano /etc/dhcpcd.conf
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Next, we edit the interfaces file using sudo nano /etc/network/interfaces so various devices can
work with the bridge. Edit the interfaces file to include the information below;
#Bridge setup
auto br0
iface br0 inet manual
bridge_ports eth0 wlan0
After that reboot the pi and scan for the wireless device
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL NO.-7
AIM: -
Raspberry Pi GPS Module Interfacing
GPS plays a prominent role in the present-day navigation systems, starting out with smartphones
and automobiles to much complex missile guidance systems. the importance of GPS and to
understand how painstaking the navigation, without GPS, will be; plotting a course, getting lost,
and finally finding the way. communication between the Pi and a GPS module and there by reading
the latitude and longitude.
Raspberry Pi, interfaced with a GPS module, can be used for developing an advanced real-time
navigation system.
Required Components: -
Hardware Requirement: -
Raspberry Pi
GPS Module (Neo 6m v2 GPS Module)
Jumper Wires
Power supply (5v 100mA)
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Circuit Diagram: -
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP 2:
Setting up the UART in Raspberry Pi
The first thing we will do under this is to edit the /boot/config.txt file. To do this, run the
commands below:
force_turbo enables UART to use the maximum core frequency which we are setting in this case
to be 250. The reason for this is to ensure consistency and integrity of the serial data been received.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
The dtoverlay=pi3-disable-bt disconnects the bluetooth from the ttyAMA0, this is to allow us
access to use the full UART power available via ttyAMAO instead of the mini UART ttyS0.
STEP2:
UART setup section is to edit the boot/cmdline.txt
I will suggest you make a copy of the cmdline.txt and save first before editing so you can revert to
it later if needed. This can be done using;
sudo cp boot/cmdline.txt boot/cmdline_backup.txt
sudo nano /boot.cmdline.txt
Replace the content with;
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4
elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
STEP3:
Disabling the Raspberry Pi Serial Getty Service
sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
STEP 4:
Activating ttyAMAO
We have disabled the ttyS0, next thing is for us to enable the ttyAMAO.
sudo systemctl enable [email protected]
STEP5:
Install Minicom and pynmea2
We will be minicom to connect to the GPS module and make sense of the data. It is also one of
the tools that we will use to test is our GPS module is working fine. An alternative to minicom is
the daemon software GPSD.
sudo apt-get install minicom
To easily parse the received data, we will make use of the pynmea2 library. It can be installed
using;
sudo pip install pynmea2
STEP 6:
Installing the LCD Library
git clone https://github.com/adafruit/Adafruit_Python_CharLCD.git
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP7:-
Testing before Python Script
Run the command:
sudo minicom -D/dev/ttyAMA0 -b9600
where 9600 represents the baud rate at which the GPS module communicates. This may be used
for once we are sure of data communication between the GPS and the RPI, it’s time to write our
python script.
The test can also be done using cat
sudo cat /dev/ttyAMA0
STEP8:-
Writing the python source code:
MYGPS.py
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
import time
import serial
import string
import pynmea2
import RPi GPIO as gpio
#to add the LCD library
import Adafruit_CharLCD as LCD
gpio.setmode(gpio.BCM)
#declaring LCD pins
lcd_rs = 17
lcd_en = 18
lcd_d4 = 27
lcd_d5 = 22
lcd_d6 = 23
lcd_d7 = 10
lcd_backlight = 2
lcd_columns = 16 #Lcd column
lcd_rows = 2 #number of LCD rows
lcd = LCD.Adafruit_CharLCD(lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4,
lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
port = "/dev/ttyAMA0" # the serial port to which the pi is connected.
#create a serial object
ser = serial.Serial(port, baudrate = 9600, timeout = 0.5)
while 1:
try:
data = ser.readline()
except:
print("loading")
#wait for the serial port to churn out data
if data[0:6] == '$GPGGA': # the long and lat data are always contained in the GPGGA
string of the NMEA data
msg = pynmea2.parse(data)
#parse the latitude and print
latval = msg.lat
concatlat = "lat:" + str(latval)
print concatlat
lcd.set_cursor(0,0)
lcd.message(concatlat)
#parse the longitude and print
longval = msg.lon
concatlong = "long:"+ str(longval)
print concatlong
lcd.set_cursor(0,1)
lcd.message(concatlong)
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL NO.-9
AIM:-
Visitor Monitoring with Raspberry Pi and Pi Camera
Project which is Visitors Monitoring System with Image capture functionality. Here we are
interfacing Pi camera with Raspberry Pi to capture the image of every visitor which has entered
through the Gate or door. In this project, whenever any person is arrived at the Gate, he has to
press a button to open the Gate, and as soon as he/she press the button, his/her picture will be
captured and saved in the system with the Date and time of the entry. This can be very useful for
security and surveillance purpose.
This system is very useful in offices or factories where visitor entry record is maintained for
visitors and attendance record is maintained for employees. This Monitoring system will digitize
and automate the whole visitor entries and attendances.
Component Requirements:-
Hardware Requirement:-
Camera Module
L293D Motor Driver Module
DC Motor
LED
Push Button
Resistors
External 5V Power Supply
Raspberry Pi and connection wires
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Circuit Design:-
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
The DC motor is a machine that transforms electric energy into mechanical energy in form of
rotation. DC Motor is controlled by L293D driver IC Circuit. I make following connections to
connect DC motor to IC circuit, and then IC to Raspberry Pi’s GPIO Pins. I also provide external
power supply to IC.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Buzzer
System Functionality:-
Pi camera is used to capture the images of visitors, when a push button is pressed or triggered.
A DC motor is used as a gate. Whenever anyone wants to enter in the place then he/she needs to
push the button.
After pushing the button, Raspberry Pi sends command to Pi Camera to click the picture and
save it.
After it, the gate is opened for a while and then gets closed again.
The buzzer is used to generate sound when button pressed.
LED is used for indicating that Raspberry Pi is ready to accept Push Button press, means when
LED is ON, and system is ready for operation.
STEP2:
Install Pi Camera Library
sudo apt-get install python-picamera
sudo apt-get install python3-picamera
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP3:
Enable Raspberry Pi Camera by using Raspberry Pi Software Configuration Tool
(raspi-config):
sudo raspi-config
Then select Enable camera and Enable it.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP4:-
Then user needs to reboot Raspberry Pi, by issuing sudo reboot, so that new setting
can take. Now your Pi camera is ready to use.
sudo reboot
STEP5:-
After Reboot, Create a folder which is used to store pictures captured by Pi Camera.
(E.g. /home/pi/Desktop/Visitors)
STEP6:-
Write the Python Code and run the python code
sudo nano pivisit.py
sudo python pivisit.py
pivisit.py
import RPi.GPIO as GPIO
import picamera
import time
m11=17
m12=27
led=22
button=23
buz=24
buttonstatus = False
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(led, GPIO.OUT)
GPIO.setup(buz,GPIO.OUT)
GPIO.setup(m11,GPIO.OUT)
GPIO.setup(m12,GPIO.OUT)
GPIO.setup(button,GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.output(led, False)
GPIO.output(buzzer,False)
GPIO.output(m11,False)
GPIO.output(m12,False)
camera = PiCamera()
def capture_image():
print(" Taking Pic")
camera.start_preview()
time.sleep(3)
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
camera.capture("/home/pi/Desktop/Visitors/img.jpg")
camera.stop_preview()
def open_gate():
print("Welcome")
GPIO.output(m11,True)
GPIO.output(m12,False)
time.sleep(1.5)
GPIO.output(m11,False)
GPIO.output(m12,False)
time.sleep(3)
GPIO.output(m11,False)
GPIO.output(m12,True)
time.sleep(1.5)
GPIO.output(m11,False)
GPIO.output(m12,False)
print("Thank you")
time.sleep(4)
def beep():
GPIO.output(buz, True)
time.sleep(0.2)
GPIO.output(buz,Flase)
time.sleep(0.2)
GPIO.output(buz, True)
time.sleep(0.2)
GPIO.output(buz,Flase)
time.sleep(0.2)
try:
While True:
Print(" please Press Button to Open the gate")
buttonstatus = GPIO.input(button)
time.sleep(0.3)
if (buttonstatus == 0):
GPIO.output(LED, True)
beep()
capture_image()
open_gate()
time.sleep(3)
finally:
GPIO.cleanup()
OUTPUT:
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL No.-10
AIM:-
Interfacing Raspberry Pi with RFID.
RFID or Radio Frequency Identification is a way of communication over electromagnetic wave
(Radio Frequency Waves, to be specific). RFID Tags and RFID Cards are often used for
authentication and access control.
You might have seen people swiping their identity cards at the entrance of their offices. The
identity card is in fact an RFID Card that has the personal information of the employee. The
moment he/she swipes the card, his check in time will be captured by a computer.
RFID Communication System comprises of three parts: an RFID Card or Tag (which contains the
user or product information embedded on a chip), an RFID Reader (a device which triggers the
RFID card and extracts the information from the Card) and a Host System (like a Computer or a
Microcontroller which then processes the data).
EM-18 RFID reader module is one of the commonly used reader and can read any 125KHz tags.
It features low cost, low power consumption, small form factor and easy to use. It provides both
UART and Wiegand26 output formats. It can be directly interfaced with microcontrollers using
UART and with PC using an RS232 converter.
Components Requirement:
Raspberry Pi With Power Supply
EM-18 RFID reader
Connecting wires(Jumper Wire)
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Circuit Design:-
Demo:
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Now, it asks whether you would like to access the login shell over serial communication. Select
“No” option. Then, it asks do you want to enable the Serial Port Hardware. Select “Yes” option.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
Finish the process and Reboot the Raspberry Pi. After the Raspberry Pi is powered up, once again
login using Putty and in order to check whether the Serial Port is enabled or not, enter the following
command.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
At the bottom, you can see, “ttyS0” is configured as Serial. Now, you can proceed with
Interfacing RFID Reader Module with Raspberry Pi to communicate over Serial.
STEP2:
Write the python code and run it.
sudo nano rfid.py
sudo python rfid.py
rfid.py
import serial
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(8,GPIO.OUT)
GPIO.output(8,True)
import time
ser=serial.Serial(port='/dev/ttyS0',baudrate=9600)
str=""
while True:
print "Place your Card"
for i in range(0,12,1):
c=ser.read()
str+=c
time.sleep(0.001)
print str
if(str=="4E002FBC7BA6"):
GPIO.output(8, False)
else:
GPIO.output(8, True)
print "THANK YOU"
str=""
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
OR
import serial #import serial module
def read_rfid ():
ser = serial.Serial ("/dev/ttyS0") #Open named port
ser.baudrate = 9600 #Set baud rate to 9600
data = ser.read(12) #Read 12 characters from
serial port to data
ser.close () #Close port
return data #Return data
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
PRACTICAL NO.-12
AIM: -
Installing Windows 10 IoT Core on Raspberry Pi
Windows 10 IoT Core is a version of Windows 10 that is optimized for smaller devices with or
without a display, and that runs on the Raspberry Pi 2 and 3, Arrow DragonBoard 410c &
MinnowBoard MAX. Windows 10 IoT Core utilizes the rich, extensible Universal Windows
Platform (UWP) API for building great solutions.
Components Required: -
Hardware Requirements:
RASPBERRY PI with Power Supply
Card Reader
Keyboard (USB)
Mouse (USB)
8 GB SD CARD
Ethernet Cable
HDMI cable
Access to a PC.
Software Requirement: -
Get Windows 10 IoT Core Dashboard
STEP2: -
Click on Setup Install the application and open it.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP3:
Plug your memory card with your desktop pc or laptop
STEP4:
Select set up a new device from the sidebar.
STEP5:-
Select the options as shown in the image below.
Make sure you select the correct drive for your microSD card and give your device a name and
admin password.
Select the Wi-Fi network connection.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP6:
Click download and install.
ROLL NO.14
CHANDRABHAN SHARMA COLLEGE INTERNET OF THINGS
STEP7: -
Once the image has been installed on the microSD card, it's time to eject it from your PC and go
over to the Raspberry Pi. First connect the micro USB cable and power supply, HDMI cable and
USB Wi-Fi adapter or Ethernet cable. Connect the HDMI cable to your chosen display, insert the
microSD card into the Raspberry Pi and power it up.
Unlike "proper" Windows 10, there's not much of a setup process here. You'll be asked to choose
a language and enter your Wi-Fi password to connect to the web. That's about it. It'll take a
couple of minutes, but when booted up you'll see the Windows 10 IoT Core splash screen.
When booted, you can go back to the dashboard application on your PC, and you'll see your
Raspberry Pi listed as one of your devices.
ROLL NO.14