0% found this document useful (0 votes)
611 views

IoT Physical Devices and End Points

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
611 views

IoT Physical Devices and End Points

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Unit-IV

IoT Physical Devices and End points


• A “Thing” in internet of Things (IoT ) can be any object that has a unique identifier
and which can send / receive data (including user data ) over a network ( e.g smart
phone, smart TV , computer, refrigerator, Car , etc )

• IoT devices are connected to the internet and send information about themselves or
about their surroundings( e.g information sensed by the connected sensors ) over a
network ( to other devices or servers/storage ) or allow actuation up on the physical
entities/environment around them remotely.
IoT device Examples :

• A home automation device that allows remotely monitoring the status of


appliances and controlling the appliances.

• An Industrial machine which sends information about its operation and


health monitoring data to a server.

• A car which sends information about its location to a cloud-based sevice.

• A wireless –enabled wearable device that measures data about a person


such as the number of steps walked and sends the data to a cloud-based
service.
Basic building blocks of an IoT device:
Sensing:
Sensors can be either on-board the IoT device or attached to the device . IoT device can collect
various types of information from the on-board or attached sensors such as temperature,
humidity, light intensity etc . The sensed information can be communicated either to other
devices or cloud based servers/ storage.

Actuation : IoT device can have various types of actuators attached that allow taking actions
upon the physical entities in the vicinity of the device. For example, a relay switch connected
to an IoT device can turn an appliance on/off based on the commands sent to the device.
Communication:

Communication modules are responsible for sending collected data to


other devices or cloud-based servers/ storage and receiving data from
other devices and commands from remote applications.

Analysis & Processing:

Analysis and processing modules are responsible for making sense of


the collected data.
Exemplary Device: Raspberry Pi :
Raspberry Pi is a low-cost mini computer with the physical size of a credit card.

It runs various flavors of Linux and can perform almost all tasks that a normal
desktop computer can do.

It is also allows interfacing sensors and actuators through the general purpose I/o
(GPIO) pins.

Since Raspberry pi runs Linux operating system, it supports Python


About the Board
Raspberry Pi board with the various components /peripherals labelled.

Processor & RAM : Raspberry Pi is based on ARM processor. The latest version of
Raspberry pi comes with 700 MHz Low power ARM1176JZ-F processor and 512 MB
SDRAM.

USB Ports :Raspberry Pi comes with two USB 2.0 Ports. The USB ports on Raspberry Pi
can provide a current up to 100mA.For connecting devices that draw current more than
100mA, an external USB powered hub is required.

Ethernet Ports: Raspberry Pi comes with a standard RJ45 Ethernet port. You can connect
an Ethernet cable or a USB Wifi adapter to provide internet connectivity.
HDMI output : The HDMI port on Raspberry Pi provides both video and audio output.
You can connect the raspberry Pi to a monitor using HDMI cable.For monitors that have a
DVI port but no HDMI port, you can use an HDMI to DVI adapter/cable.

Audio output :Raspberry Pi has a 3.5mm audio output jack . This audio jack is used for
providing audio output to old televisions along with the RCA jack for video.

GPIO pins: Raspberry Pi comes with a number of general purpose input/output pins.
There are four types of pins on Raspberry Pi- true GPIO pins,12C Interface pins, SPI
interface pins and serial Rx and Tx pins.

Display Serial Interface(DSI) : The DSI interface can be used to connect an LCD panel to
Raspberry Pi.
Camera Serial Interface: The CSI interface can be used to connect a camera
module to Raspberry Pi.

Status LEDs: Raspberry Pi has Five status LEDs.

SD card slot: Raspberry Pi does not have a built in operating system and
storage . You can Plug-in an SD card loaded with a Linux image to the SD
card slot.

Power Input : Raspberry Pi has a micro-USB connector for power input.


Linux on Raspberry Pi:
Raspberry Pi supports various flavors of Linux including:

Raspbian Raspbian Linux is a Debian wheezy port optimized for Raspberry Pi. This
is the Recommended Linux for Raspberry pi.

Arch: Arch is an Arch Linux port for AMD devices.

Pidora : Pidora Linux is a Fedora Linux optimized for Raspberry Pi.

RaspBMC :RaspBMC is an XBMC media-center distribution for Raspberry Pi.

OpenELEC : OpenELEC is a fast and user friendly XBMC media-center distribution.

RISC OS: RISC OS is a very fast and compact operating system.


Raspberry Pi interfaces
Raspberry Pi has serial, SPI and I2C interfaces for data transfer as shown in figure.
Serial :

The serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins for
communication with serial peripherals.
SPI :

Serial Peripheral Interface(SPI) is a synchronous serial data protocol used for


communicating with one or more peripheral devices . In an SPI connection, there
is one master device and one or more peripherals devices. There are five pins on
Raspberry Pi for SPI interface.
• MISO (Master In Slave Out): Master line for sending data to the
peripherals.

• MOSI(Master out Slave In ) :Slave line for sending data to the master.

• SCK (Serial clock) : Clock generated by master to synchronize data


transmission.

• CEO(Chip Enable 0) : To enable or disable devices.

• CEO (Chip Enable 1) : To enable or disable devices.


I2C:

The I2C interface pins or Raspberry Pi allow you to connect hardware


modules.I2C interface allows synchronous data transfer with just two
pins-SDA( data line ) and SCL (Clock line).
Programming Raspberry Pi with Python :

Controlling LED with Raspberry Pi:

$echo 18 > /sys/class/gpio/export

$cd/sys/class/gpio.gpio18

#Set pin 18 direction to out

$echo out> direction

# Turn LED on

$echo 1 > value

#Turn LED off

$echo 0 > value


Controlling LED with Raspberry Pi
# Python Program for blinking LED

Import Rpi.GPIO as GPIO

Import time

GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.OUT)

While True :

GPIO.output( 18, True)

time.sleep( 1 )

GPIO.output( 18, False)

time.sleep(1)
Interfacing an LED and Switch with Raspberry PI
Python Program for controlling an LED with a switch
Python program to sending an email on switch press :
Import smtplib
from time import sleep
Import RPI . GPIO as GPIO
from sys import exit

From_email = ‘ <my-email>’
receipients_list=[‘<receipint-email>’]
cc_list = [ ]
subject = ‘ Hello ‘
message = ‘ Switch pressed on Raspberry pi’
username = ‘ <Gmail-username>’
password = ‘ <password>’
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN)

Def sendmail (from_addr, to_addr_list, cc_addr_list, subject, message,


login, password, smtpserver ):

header = ‘ From: % s \n’ % from_addr


header + = ‘ To: % s \n’ % ‘ , ‘ . Join( to_addr_list )
header + = ‘ Cc: % s \n’ % ‘ , ‘. Join (cc_addr_list)
header + = ‘subject: % s \n \ n ’ % subject
message = header + message
server = smtplib.SMTP(smtpserver)
server.starttls ( )
Server.login(login,password)
Problems = server.sendmail(from_addr, to_addr_list, message)
Server.quit( )
While True :
try :
if ( GPIO.input ( 25 ) == True ) :
sendmail(from_email, receipients_list, cc_list, subject, message,
username, password, server)
Sleep(.01)
Except keyboardInterrrupt:
Exit ( )
Interfacing a Light Sensor(LDR) with Raspberry Pi

• The figure shows the schematic diagram of connecting an LDR to Rspberry


Pi.

• Connect one side of LDR to 3.3V and other side to a 1uF capacitor and
also to a GPIO pin ( pin 18 in this example).

• An LED is connected to pin 18 which is controlled based on the light-level


sensed.
Interfacing LDR with Raspberry Pi
Python program for switching LED/Light based on reading LDR reading
import Rpi.GPIO as GPIO
Import time

GPIO.setmode ( GPIO.BCM)
Ldr_threshold = 1000
LDR_PIN = 18
LIGHT_PIN = 25
Def readLDR ( PIN ) :
reading = 0
GPIO.setup ( LIGHT_PIN, GPIO.OUT)
GPIO.output(PIN,False)
time.sleep ( 0. 1 )
GPIO.setup ( PIN, GPIO . IN )
while( GPIO.input ( PIN ) = = False) :
reading=reading+1
return reading
def switchingOnLight ( PIN) :
GPIO.setup ( PIN, GPIO.OUT)
GPIO.output ( PIN, True)
def switchoffLight( PIN ) :
GPIO.setup ( PIN , GPIO.OUT )
GPIO.output( PIN, False )

while True :
ldr_reading = readLDR ( LDR_ PIN )
if ldr_reading< ldr_threshold :
switchOnlight ( LIGHT_PIN)
else :
switchoffLight ( LIGHT_PIN )
time.sleep( 1 )

You might also like