Internet Of Things
“ Practical File ”
Name:Suraj Malap
Roll No:8624
Std:TYIT
Div:D
Certificate This is to certify that Mr. /Miss.
Suraj Malap
Examination Seat no. 8624 has successfully completed all
the practicals of the subject
Internet Of Things
in partial fulfillment for the degree of B.Sc. (Information
Technology) SEM V, affiliated to university of Mumbai for
the academic year 2022-2023. Internal Examiner Head of
the Department External Examiner
INDEX
Sr.No Practical Date Sign
1 Familiarization of Raspberry Pi-Architecture
2 Perform LED Glow on Raspberry Pi
3 Execute linux Commands on Raspberry Pi
4 Controlling Raspberry Pi with Telegram
5 RFID Interface with Raspberry Pi
6 Show Pulse Width Modulation on Raspberry Pi
7 Show how RPi Camera capture the image
8 Convert Raspberry Pi as a Webserver
9 Show the working of Fingerprint module on Raspberry Pi
10
Practical 2
CODE :
- You are now ready to write some code to switch the LED on.
- Turn on your Pi and open the terminal window.
- Create a new text file “LED.py” by typing the following: nano LED.py
Type The following code
import RPI.GPIO as GPIO
import time
GPIO.setmode (GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
for i in range(10):
GPIO.output (7, True)
print("LED on)
time.sleep(1)
GPIO.output (7, False)
print("LED off")
time.sleep(1)
print("Done.....")
GPIO.cleanup()
Running the Code:
To run this code type: sudo python LED.py
OUTPUT
Practical 3
LINUX COMMAND IN RASPBERRY PI
1.Sudo raspi-config
2. ls
3. Pwd
4. mkdir
5. Ifconfig
6. Hostname
7. Ping
8. Sudo apt-get
9. Sudo apt-get update
10. Sudo apt-get upgrade
11. Route
Practical 4
CODE :
Configuration code for Telegram:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip install telepot
clear
mkdir TelegramLEDdemo
cd TelegramLEDdemo
Code for Telegram:
import RPi.GPIO as GPIO
import time
import sys
import telepot
import datetime
import random
from telepot.loop import MessageLoop
def on(pin):
GPIO.otput(pin,GPIO.HIGH) return
def off(pin):
GPIO.output(pin,GPIO.LOW)
return
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
def handle(msg):
chat_id=msg['chat']['id']
command=msg['text']
print('received:%s'%command)
if command == 'ON':
while 1:
GPIO.output(11,GPIO.HIGH)
time.sleep(1)
GPIO.output(11,GPIO.LOW)
time.sleep(1)
elif command =='OFF':
GPIO.output(11,GPIO.LOW)
bot=telepot.Bot('5472635263:AAGG6E8AtyKnMrvNAg289E9TjYBqG4CnRMI')
bot.message_loop(handle) print("i am listening")
while 1:
time.sleep(1)
OUTPUT
Telegram Communication:
-Output on Screen
Practical 5
STEPS
Step1
Update Raspberry Pi - sudo apt-get update
Step2
sudo apt-get upgrade
Step3
After runing the command sudo raspi-config you will get Config options
Step4
Select using Arrow Keys -> Interfacing Options -> SPI -> Enable
And click select then ok
Step5
Click yes and the ok hence finish
Reboot Raspberry Pi
Step6
Check to make sure that SPI has been enabled. -lsmod /grep spi
Step7
Install Spidev library- sudo apt-get install python-spidev python3-spidev
Step8
Type command Cd->Pwd(*if /home/pi is displayed then we are on correct
path*)
Step9
Then Download Python library SPI Which help to interact with SPI- git clone
https://github.com/lthiery/SPI-Py.git
Then Change directory to SPI-Py/
Step10
Intsall SPI Python library by running setup file and then clear it.
Step11
Then Change the directory and By “cd” command and also type command
“pwd”.
Download the library that help keep talk to the RC522 module over the SPI
interface.
Step12
Change directory to MFRC522-python
Step13
Write a python code will ask you for text to input and then write it on RFID
tag.
CODE :
Writing.py
import RPi.GPIO as GPIO
import SimpleMFRC522
reader =SimpleMFRC522.SimpleMFRC522()
try:
text=raw_input(‘enter new data on card’)
print(“now place card”)
reader.write(text)
print(“data written”)
finally:
GPIO.cleanup()
Write the python code that will read this data back off the tag.
Reading.py
import RPi.GPIO as GPIO
import SimpleMFRC522
reader=SimpleMFRC522()
try:
id,text=reader.read()
print(id)
print(text)
finally:
GPIO.cleanup()
Then run the command
- sudo nano read.py
- sudo python read.py
- then type message .
OUTPUT
Practical 6
CODE :
Import Rpi.GPIO as GPIO
Import time
GPIO.setWarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(19,GPIO.OUT)
P=GPIO.PWM(19,100)
p.start(0)
while 1:
for x in range(50):
p.ChnageDutyCycle(x)
time.sleep(0.1)
for x in range (50) :
p.ChangeDutyCycle(50-x)
time.sleep(0.1)
OUTPUT:
Practical 7
CODE :
import pi camera
from time import sleep
camera=picamera.PiCamera()
camera.start_preview()
sleep(5)
camera.capture("Image.jpg")
camera.stop_preview()
OUTPUT :
Practical 8
STEPS :
Step1
Navigate to the command prompt / terminal. You can get there by hitting
CTRL+ALT+T from the Raspbian desktop or connecting remotely via SSH if you
have that configured. Some users also configure the Raspberry Pi to boot
directly to the command prompt.
Step2
Update your packages by typing
sudo apt-get update
This will make sure that you get the latest versions of every file you
download after this.
Step3
Install apache2 with the command:
sudo apt-get install apache2 -y
Step4
Install php for your sever by typing:
sudo apt-get install php libapache2-mod-php -y
Step5
Install mariadb so you can use a mysql database with your website. You
start by typing:
- “sudo apt-get install mariadb-server”
Then, after the download is finished. You must do the formal install by typing:
- “sudo mysql_secure_installation”
You will be asked for a root password. You can leave it blank.
Step6
Install the php-mysql connector so php pages can access the DB.
: “sudo apt install php-mysql”
Step7
Restart apache2 so all of the changes are running.
: “sudo service apache2 restart”
Step6
Test your server. On the Raspberry Pi itself, you should be able to go to
http://localhost and see a test page. From another computer on the same
network, you should be able to get there by visiting http://raspberrypi.local
or http://raspberrypi, provided that your Raspberry Pi's hostname is
raspberrypi.
Practical 9
STEPS :
Step1
Run the “sudo bash” command
Step2
To install library , root privilages are required , login with root.
-type “pwd” then clear the screen,
Step3
Download packages using “wget” command. And then clear the screen .
Step4
Update Raspberry pi with “apt-get update” command
Step5
Install and Download fingerprint sensor library.
: apt-get install python-fingerprint
Step6
To return the normal shell (under the pi user ) , type “exit” command.
Step7
Type “whoami” command , then “pwd” command and last “ls” command to
see the Downloaded file.
Step8
Check the usb port on which the fingerprint sensor id connected.
Step9
Go to the Examples directory by using : cd /usr/share/doc/python-
fingerprint/examples/
Then type “pwd” , “ls” command to get the sample files.
Step10
Run the sample file to test to see , if the sensor is detected and ready to
access.
: sudo python example index.py
Step11
Similarly run all the script files , to make sure the fingerprint module is
working.
: sudo python example enroll.py
: sudo python example search.py
If the fingerprint is not detected then it show “No Match found”
: sudo python example downloadimage.py
OUTPUT :