Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

INTERNET OF THINGS PRACTICAL, Lecture notes of Embedded Systems

INTERNET OF THINGS PRACTICAL 1,2,3,4,5,6

Typology: Lecture notes

2017/2018

Uploaded on 09/26/2018

devansh-shetty
devansh-shetty 🇮🇳

4.5

(6)

5 documents

1 / 43

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practical No.0
AIM: Starting Raspbian OS, Familiarising with Raspberry Pi Components
and interface, connecting to Ethernet, Monitor, and USB.
3 Steps For Installation Raspbian OS:
1. Format the SD card ( with the help of SD card formatter )
2. Unzip the OS – Disk image le
3. Write the OS image le to SD card ( win32 Disk image Writer )
Hardware requirement:
1. Raspberry Pi 3.
2. Monitor or TV: A monitor or TV is connected with HDMI cable with
Raspberry Pi.
3. HDMI cable ( High Denition Multimedia Interface )
4. Ethernet Cable: Ethernet cable will allow Pi to connect with the
Internet.
5. USB keyboard: Any standard USB keyboard and mouse can be
attached to Raspberry Pi.
6. USB Mouse: This is used to connect mouse with Raspberry Pi kit.
7. Micro USB Power Supply: We can use 5v, 2A power supply for all
models of Raspberry Pi.
8. 8GB or larger microSD card: SD card is used to store the default OS,
Raspbian.
9. SD card Reader: This is used to read the SD card.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b

Partial preview of the text

Download INTERNET OF THINGS PRACTICAL and more Lecture notes Embedded Systems in PDF only on Docsity!

Practical No.

AIM: Starting Raspbian OS, Familiarising with Raspberry Pi Components and interface, connecting to Ethernet, Monitor, and USB.

3 Steps For Installation Raspbian OS:

  1. Format the SD card ( with the help of SD card formatter )
  2. Unzip the OS – Disk image file
  3. Write the OS image file to SD card ( win32 Disk image Writer )

Hardware requirement:

  1. Raspberry Pi 3.
  2. Monitor or TV: A monitor or TV is connected with HDMI cable with Raspberry Pi.
  3. HDMI cable ( High Definition Multimedia Interface )
  4. Ethernet Cable: Ethernet cable will allow Pi to connect with the Internet.
  5. USB keyboard: Any standard USB keyboard and mouse can be attached to Raspberry Pi.
  6. USB Mouse: This is used to connect mouse with Raspberry Pi kit.
  7. Micro USB Power Supply: We can use 5v, 2A power supply for all models of Raspberry Pi.
  8. 8GB or larger microSD card: SD card is used to store the default OS, Raspbian.
  9. SD card Reader: This is used to read the SD card.

Practical No. 1

Aim : Displaying different LED patterns with Raspberry Pi.

Hardware Requirement:

  1. Raspberry Pi.
  2. 5 LEDs.
  3. Male to Male and Male to Female Jumper wire.
  4. Breadboard.
  5. Monitor.
  6. Keyboard.
  7. Mouse.
  8. HDMI Cable.
  9. Power supply for Raspberry Pi.

Coding:

Q.Display the dancing pattern (using 1 LEDs).

#Blink LED Program

#Connect the LED to GPIO 22 Pin

#Connect the LED to GPIO 22 (i.e. Physical Pin15)

#import GPIO and time library

importRPi.GPIO as GPIO

from time import sleep

GPIO.setmode(GPIO.BOARD) #set the Pin mode you will be working with

ledPin = 15 #this is GPIO 22 pin i.e Physical Pin

#setup the ledPin(i.e GPIO 22)as output

GPIO.setup(ledPin, GPIO.OUT)

GPIO.output(ledPin, False)

try:

while True: GPIO.output(ledPIn, True) #Set the LED Pin to HIGH print(“LED ON”) sleep(1) #Wait for 1 sec GPIO.output(ledPin, False) #Set the LED Pin to LOW print(“LED OFF”) sleep(1) #wait for 1 sec

finally:

#reset the GPIO Pins GPIO.output(ledPin, False) GPIO.cleanup()

OUTPUT:

sleep(1) GPIO.output(ledPin, True) print(“LED ON”) sleep(1)

finally:

GPIO.output(ledPin1,False) GPIO.output(ledPin, False) GPIO.cleanup()

OUTPUT:

Q. Display the dancing pattern (using 3 LEDs).

Import RPi.GPIO as GPIO

from time import sleep

GPIO.setmode(GPIO.BCM)

ledpin=

ledpin1=

ledpin2=

GPIO.setup(ledpin,GPIO.OUT)

GPIO.output(ledpin,False)

GPIO.setup(ledpin1,GPIO.OUT)

GPIO.output(ledpin1,False)

GPIO.setup(ledpin2,GPIO.OUT)

GPIO.output(ledpin,False)

try:

while True:

GPIO.output(ledPin, True)

OUTPUT:

Q. Display the dancing pattern (using 3 LEDs Reverse pattern ).

import RPi.GPIO as GPIO

from time import sleep

GPIO.setmode(GPIO.BOARD)

ledPin=

ledPin1=

ledPin2=

GPIO.setup(ledPin,GPIO.OUT)

GPIO.output(ledPin,False)

GPIO.setup(ledPin1,GPIO.OUT)

GPIO.output(ledPin1,True)

GPIO.setup(ledPin2,GPIO.OUT)

GPIO.output(ledPin2,False)

try:

while True: GPIO.output(ledPin,True) print("Led On") sleep(1)

OUTPUT:

LED PATTERN (WITHOUT USING BREADBOARD)

PATTERN 1:

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BOARD) led1 = 29 led2 = 31 led3 = 33 led4 = 35 led5 = 36 led6 = 37 led7 = 38 led8 = 40

#setup the ledPin(i.e. GPIO22) as output GPIO.setup(led1, GPIO.OUT) GPIO.setup(led2, GPIO.OUT) GPIO.setup(led3, GPIO.OUT) GPIO.setup(led4, GPIO.OUT) GPIO.setup(led5, GPIO.OUT) GPIO.setup(led6, GPIO.OUT) GPIO.setup(led7, GPIO.OUT) GPIO.setup(led8, GPIO.OUT)

GPIO.output(led1, False) GPIO.output(led2, False) GPIO.output(led3, False) GPIO.output(led4, False) GPIO.output(led5, False) GPIO.output(led6, False) GPIO.output(led7, False) GPIO.output(led8, False)

PATTERN 2:

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BOARD) led1 = 29 led2 = 31 led3 = 33 led4 = 35 led5 = 36 led6 = 37 led7 = 38 led8 = 40

#setup the ledPin(i.e. GPIO22) as output GPIO.setup(led1, GPIO.OUT)

GPIO.setup(led2, GPIO.OUT) GPIO.setup(led3, GPIO.OUT) GPIO.setup(led4, GPIO.OUT) GPIO.setup(led5, GPIO.OUT) GPIO.setup(led6, GPIO.OUT) GPIO.setup(led7, GPIO.OUT) GPIO.setup(led8, GPIO.OUT)

GPIO.output(led1, False) GPIO.output(led2, False) GPIO.output(led3, False) GPIO.output(led4, False) GPIO.output(led5, False) GPIO.output(led6, False) GPIO.output(led7, False) GPIO.output(led8, False)

def ledpattern (ledVal1,ledVal2,ledVal3,ledVal4,ledVal5,ledVal6,ledVal7,ledVal8): GPIO.output(led1, ledVal1) GPIO.output(led2, ledVal2) GPIO.output(led3, ledVal3) GPIO.output(led4, ledVal4) GPIO.output(led5, ledVal5) GPIO.output(led6, ledVal6) GPIO.output(led7, ledVal7) GPIO.output(led8, ledVal8)

def patterOne(): for i in range (0,3): ledpattern(1,1,0,0,1,1,0,0) time.sleep(1) ledpattern(0,0,1,1,0,0,1,1) time.sleep(1)

try: while True:

led6 = 37 led7 = 38 led8 = 40

#setup the ledPin(i.e. GPIO22) as output GPIO.setup(led1, GPIO.OUT) GPIO.setup(led2, GPIO.OUT) GPIO.setup(led3, GPIO.OUT) GPIO.setup(led4, GPIO.OUT) GPIO.setup(led5, GPIO.OUT) GPIO.setup(led6, GPIO.OUT) GPIO.setup(led7, GPIO.OUT) GPIO.setup(led8, GPIO.OUT)

GPIO.output(led1, False) GPIO.output(led2, False) GPIO.output(led3, False) GPIO.output(led4, False) GPIO.output(led5, False) GPIO.output(led6, False) GPIO.output(led7, False) GPIO.output(led8, False)

def ledpattern (ledVal1,ledVal2,ledVal3,ledVal4,ledVal5,ledVal6,ledVal7,ledVal8): GPIO.output(led1, ledVal1) GPIO.output(led2, ledVal2) GPIO.output(led3, ledVal3) GPIO.output(led4, ledVal4) GPIO.output(led5, ledVal5) GPIO.output(led6, ledVal6) GPIO.output(led7, ledVal7) GPIO.output(led8, ledVal8)

def patterOne(): for i in range (0,3): ledpattern(1,1,1,1,0,0,0,0)

time.sleep(1) ledpattern(0,0,0,0,1,1,1,1) time.sleep(1)

try: while True: patterOne()

finally: #reset the GPIO Pins

OUTPUT:

PRACTICAL NO.