0% found this document useful (0 votes)
25 views27 pages

Iot Practical PDF

iot_practical engineering

Uploaded by

arpawade
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)
25 views27 pages

Iot Practical PDF

iot_practical engineering

Uploaded by

arpawade
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/ 27

Practical No :01

Raspberry Pi 3 Model B
Bluetooth / Wifi model USB chip to connect processor

Broadcom Processor

Ethernet LAN port

4 USB port

GPIO 40 Pin

HDMI port Backside:

1. Micro SD card slot


2. RAM (min of 4 GB)

Audio/Video jack

Micro USB power Connector


T.Y.B.Sc.I.T Internet of Things

Practical: 1

Used to connect hardware module

1. Power (3.3V,5V)

2. Ground

3. 12C (SDA,SCL)

4. UART – Universal asynchronus transmitter


(Txd,RxD)

5. GPIO – Used to turn devices


ON or OFF
EG. – LED

6. SPI – used to connect device


using some protocol

7. DNC – Do not connect

Reference pins DNC

Roll No.: 91 Created By: Sudhanshu Maurya


Practical No :02
Aim: Displaying different LED patterns with Raspberry Pi.
Components:
1. LED
2. 330Ω Register
3. 6 m-m jumper Wires
Connection diagram:

Code:
Centerdash-pattern.py

import RPi.GPIO as GPIO


import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(5,GPIO.OUT)
GPIO.setup(6,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(19,GPIO.OUT)
GPIO.setup(26,GPIO.OUT)
list=[5,6,13,19,26]
for num in range((len(list) / 2)+1):
GPIO.output(list[num],GPIO.HIGH)
GPIO.output(list[len(list)-num-1],GPIO.HIGH)
time.sleep(0.05)
GPIO.output(list[num],GPIO.LOW)
GPIO.output(list[len(list)-num-1],GPIO.LOW)
time.sleep(0.05)
GPIO.cleanup()
OUTPUT

Running-pattern.py

import RPi.GPIO as GPIO


import time
import keyboard

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(5,GPIO.OUT)
GPIO.setup(6,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(19,GPIO.OUT)
GPIO.setup(26,GPIO.OUT)
list=[5,6,13,19,26]
print "Press q to Exit"
try:
while True:
if keyboard.is_pressed('q'):
break;
for num in range(len(list)):
GPIO.output(list[num],GPIO.HIGH)
time.sleep(0.05)
GPIO.output(list[num],GPIO.LOW)
time.sleep(0.05)
except KeyboardInterrupt:
pass
GPIO.output(5,GPIO.LOW)
GPIO.output(6,GPIO.LOW)
GPIO.output(13,GPIO.LOW)
GPIO.output(19,GPIO.LOW)
GPIO.output(26,GPIO.LOW)
GPIO.cleanup()
OUTPUT:
Practical No :03
Aim: Displaying Time over 4-Digit 7-Segment Display using Raspberry Pi.
Components:
1. 16Bit ADS1115
2. 12 M-M Jumper Wires
Display Description:

Above picture is pretty much self explanatory. Display model included in the kit
has 12 pins so as simple as it can be. 8 pins are attached to 7 segments of all digits
and single decimal point, other 4 are used as HIGH for every digit. If you connect
pin 12 to HIGH, the first digit will activate (9 = second, 8 = third, 6 =fourth). So if
we had 12, 9, 8 & 6 all connected to HIGH, and 7 & 4 LOW, all four digits would
display the number 1. This HIGH LOW scheme will be exactly opposite of this for
Common Cathode displays.
Connection Diagram:

Code:
Seg.py
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

#GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)


segments = (17,27,22,23,24,25,5,6)
for segment in segments:
GPIO.setup(segment, GPIO.OUT)
GPIO.output(segment, 1)
digits = (16,20,21,12)

for digit in digits:


GPIO.setup(digit, GPIO.OUT)
GPIO.output(digit, 1)

num = {' ':(0,0,0,0,0,0,0),


'0':(1,1,1,1,1,1,0),
'1':(0,1,1,0,0,0,0),
'2':(1,1,0,1,1,0,1),
'3':(1,1,1,1,0,0,1),
'4':(0,1,1,0,0,1,1),
'5':(1,0,1,1,0,1,1),
'6':(1,0,1,1,1,1,1),
'7':(1,1,1,0,0,0,0),
'8':(1,1,1,1,1,1,1),
'9':(1,1,1,1,0,1,1)}

try:
while True:
n = time.ctime()[11:13]+time.ctime()[14:16]
s = str(n).rjust(4)
for digit in range(4):
for loop in range(0,7):
if num[s[digit]][loop] == 0:
GPIO.output(segments[loop], 1)
else:
GPIO.output(segments[loop], 0)
if (int(time.ctime()[18:19])%2 == 0)
and (digit == 1):
GPIO.output(6, 0)
else:
GPIO.output(6, 1)

GPIO.output(digits[digit], 1)
time.sleep(0.001)
GPIO.output(digits[digit], 0)

except KeyboardInterrupt:
GPIO.cleanup()
OUTPUT:
Practical No 4
AIM: Raspberry Pi Based Oscilloscope.
Component List:
1. 10K Potentiometer
2. 16Bit ADS1115
3. Jumper Wire
Connection diagram (BCM Pins):

Install dependencies:
1. sudo apt-get update
2. sudo apt-get upgrade
3. sudo apt-get install build-essential python-dev python-smbus git
4. sudo apt-get install i2c-tools
Check i2c Address
Install Adafruit Library:
• cd TYIT/3-oscilloscope/
• Next, clone the Adafruit git folder for the library by running.
• Git clone https://github.com/adafruit/Adafruit_Python_ADS1x15
• Cd Adafruit_Python_ADS1x15
• Sudo python setup.py install
Install graph plotting and drawing libraries
• sudo apt-get install python-matplotlib
• sudo apt-get install python-pip
• sudo pip install drawnow
• sudo python scope.py

Code:
import time
import matplotlib.pyplot as plt
from drawnow import*
import Adafruit_ADS1x15

adc=Adafruit_ADS1x15.ADS1115()
GAIN=1
val=[]
cnt=0
plt.ion()

adc.start_adc(0, gain=GAIN)
print('Reading ADS1x15 Channel 0')

def makeFig():
plt.ylim(-5000,5000)
plt.title('Oscilloscope')
plt.grid(True)
plt.ylabel('ADC Ost_resultutputs')
plt.plot(val, 'ro-', label='Channel 0')
plt.legend(loc='lower right')

while (True):
value=adc.get_last_result()
print('channel 0: {0}'.format(value))

time.sleep(0.5)
val.append(int(value))
drawnow(makeFig)
plt.pause(0.000001)
cnt=cnt+1
if(cnt>50):
val.pop(0)

OUTPUT:
Practical No 5

AIM: Interfacing Raspberry Pi with RFID.


Component List:

Connection Diagram:
OUTPUT
PRACTICAL NO.6
AIM: Camera Connection and capturing Images
APPARATUS: Camera Module
THEORY: The Raspberry Pi Camera Board plugs directly into the CSI connector
on the Raspberry Pi. The camera is supported in the latest version of Raspbian,
the Raspberry Pi’s preferred operating system.
The Raspberry Pi Camera Board Features:
1. Fully Compatible with Both the Model A and Model B Raspberry Pi
2. 5MP Omnivision 5647 Camera Module
3. Still Picture Resolution: 2592 x 1944
4. Video: Supports 1080p @ 30fps, 720p @ 60fps and 640x480p 60/90
Recording
5. 15-pin MIPI Camera Serial Interface – Plugs Directly into the Raspberry Pi
Board
6. Size: 20 x 25 x 9mm
7. Weight 3g
8. Fully Compatible with many Raspberry Pi cases

PROCEDURE:
1. Locate the camera port and connect the camera:
2. Start up the Pi.
3. Open the Raspberry Pi Configuration Tool from the main menu.
4. Ensure the camera software is enabled. If it's not enabled, enable it and reboot
your Pi to begin.

CODE:
from time import sleep
from picamera import PiCamera
camera = PiCamera()
camera.resolution = (1280, 720) camera.start_preview()
sleep(2)
camera.capture('/home/pi/Pictures/newImage.jpg')
camera.stop_preview()

OUTPUT:
Practical No: 07
Aim: Controlling Raspberry Pi with Telegram Meesanger.
Telegram code:
import sys

import time
import telepot

import RPi.GPIO as GPIO

#LED

def on(pin):

GPIO.output(pin, GPIO.HIGH)

return 'LED is On Now on BCM pin 5'

def off(pin):

GPIO.output(pin, GPIO.LOW)

return 'LED is Off Now on BCM pin 5'

GPIO.setmode(GPIO.BCM)

GPIO.setup(5, GPIO.OUT)

def handle(msg):

chat_id = msg['chat']['id']

command = msg['text']

print('Got Command '+command)

if command == 'on':

bot.sendMessage(chat_id, on(5))

elif command == 'off':

bot.sendMessage(chat_id, off(5))

else :

bot.sendMessage(chat_id, 'Echo:'+command)

bot = telepot.Bot('970040458:AAErVBNY3qrEoOhqqg4IxpKKqpZuQFvq5kY')

bot.message_loop(handle)

print('I am listening...')

while 1:

try:

time.sleep(10)

except KeyboardInterrupt:

print('')

print('Program Interrupted')

GPIO.cleanup()
exit()

except:

print('other error of exception occured')

GPIO.cleanup()

OUTPUT:

Creating New Bot


Commands given to bot:

Practical No:08

Aim: Installing Windows 10 IoT Core on Raspberry Pi.

You might also like