9561 KARISHMA P.
KOLEKAR
TYIT B INTERNET OF THINGS
Practical Details Date Sign
No
1 Introduction about the different components in IoT and the
different control boards used to implement Iot
2 Preparing Raspberry Pi: Hardware preparation and
Installation
3 Execute linux commands on Raspberry Pi
4 GPIO: Light the LED with Python
5 Show Pulse Width Modulation output on Raspberry Pi
6 Controlling Raspberry Pi with Telegram App
7 Interfacing Raspberry Pi with RFID
8 Show how PiCamera capture the image
9 Convert Raspberry Pi as a Web Server
10 Fingerprint Sensor interfacing with Raspberry Pi
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
PRACTICAL 3
Q. Execute linux commands on Raspberry Pi
1. Configuration commands :
(1) sudo raspi-config
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
(2) sudo apt-get update
(3) sudo apt-get upgrade
2. File System Commands :
(1) ls
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
(2) touch
(3) head -n file_name
(4) tail -n file_name
(5) cat* file_name
(6) mkdir and rmdir
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
(7) pwd
(8) nano file_name
(9) cd dir_name
(10) cd
(11) tree
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
(12) pipe command
(13) cp file_name dir_name
(14) mv file_name dir_name
3. Search Commands :
(1) whereis file_name
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
4. Network Commands :
(1) ifconfig
(2) ping ip_address
(3) hostname
(4) nmap raspberrypi
5. Screenshot Command :
(1) scrot
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
PRACTICAL 4
1. Raspberry Pi - GPIO : Light the LED with Python
# Blinks LED connected to pin 10
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(10,GPIO.OUT) # set GPIO Physical Pin no 10
for i in range(100): # Repeat 100 times
GPIO.output(10,True) # switch on Pin 10
print("LED on!")
time.sleep(0.1) # Wait
GPIO.output(10,False) # switch off Pin 10
print("LED off!")
time.sleep(0.1) # Wait
print("Done..")
GPIO.cleanup() # Resets GPIO port
OUTPUT -
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
2. Arduino Board - GPIO : Light the LED with Python
// C++ code
//
void setup()
{
pinMode(8, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
delay(300); // Wait for 1000 millisecond(s)
digitalWrite(8, LOW);
delay(300); // Wait for 1000 millisecond(s)
}
OUTPUT -
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
PRACTICAL 5
Q. Show Pulse Width Modulation output on Raspberry Pi.
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.ChangeDutyCycle(x)
time.sleep(0.2)
for x in range(50):
p.ChangeDutyCycle(50-x)
time.sleep(0.1)
OUTPUT -
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
PRACTICAL 6
Q. Controlling Raspberry Pi with Telegram App.
import RPi. GPIO as GPIO import time import sys import telepot import datetime import
random
from telepot. loop import MessageLoop def on (pin):
GPIO. output (pin, GPIO. HIGH)
return
def off(pin):
GPIO. output (pin, GPIO. LOW)
return
GPIO. setmode (GPIO. BOARD) GPIO. setup (18, GPIO. OUT)
def handle(msg) :
chat_id=msg[ 'chat ']['id']
command=msg[' text ']
print(' received:% '%command)
if command =='ON':
GPIO. output (18, GPIO. HIGH)
elif command =='OFF'
GPIO. output (18, GPIO. LOW)
bot=telepot . Bot('6491772830: AAH7A-bWBWB9Fq4cU-LjJsMwGOkTn8Q')
bot message_ loop(handle) print ('I am listening')
while 1:
time. sleep (1)
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
OUTPUT :
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
PRACTICAL 8
Q.Show how PiCamera captures the image.
Image :
import picamera
from time import sleep cam=picamera. PiCamera ()
can. start preview)
call-annotate_text="Clicked by Div-b"
can.hflip=True
cam.vfLip=True
sleep (5)
cam. capture ('imagel.png')
for i in range (5):
sLeep (5)
cam. capture ('/home/raspberrypi/camerademo/pic%s.jpg'%i)
cam. stop_preview()
OUTPUT :
9561 KARISHMA P. KOLEKAR
TYIT B INTERNET OF THINGS
Video :
import picamera import time
can-picamera.PiCamera()
cam. start_preview()
cam. start_recording ("vi.h264")
cam.annotate_text="hello"
time. sleep (50)
can. stop_recording()
cam. stop_preview()
OUTPUT :