[go: up one dir, main page]

0% found this document useful (0 votes)
13 views39 pages

CSE IoT UNIT-IV

Unit 4 covers the fundamentals of IoT devices, focusing on the Raspberry Pi as an exemplary device. It discusses the basic building blocks of IoT devices, including sensing, actuation, communication, and data processing, as well as programming Raspberry Pi using Python. Additionally, it explores various interfaces like Serial, SPI, and I2C, and provides examples of interfacing components with Raspberry Pi.
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)
13 views39 pages

CSE IoT UNIT-IV

Unit 4 covers the fundamentals of IoT devices, focusing on the Raspberry Pi as an exemplary device. It discusses the basic building blocks of IoT devices, including sensing, actuation, communication, and data processing, as well as programming Raspberry Pi using Python. Additionally, it explores various interfaces like Serial, SPI, and I2C, and provides examples of interfacing components with Raspberry Pi.
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/ 39

UNIT 4

IoT Physical Devices &


Endpoints

Book website: Bahga & Madisetti, ©


Outline

• Basic building blocks of an IoT Device


• Exemplary Device: Raspberry Pi
• Introduction to Raspberry Pi
• Raspberry Pi interfaces(Serial, SPI, I2C)
• Programming Raspberry Pi with Python

Book website: Bahga & Madisetti, ©


What is an IoT Device

• 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 upon the physical
entities/environment around them remotely.

Book website: Bahga & Madisetti, ©


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 abouts its operation
and health monitoring data to a server.
• A car which sends information about its location to a cloud-based
service.
• 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.

Book website: Bahga & Madisetti, ©


Basic building blocks of an IoT Device

• Sensing
• Sensors can be either on-board the IoT device or attached to the device.
• Actuation
• IoT devices can have various types of actuators attached that allow taking
actions upon the physical entities in the vicinity of 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.
Book website: Bahga & Madisetti, ©
Block diagram of an IoT Device

Book website: Bahga & Madisetti, ©


Exemplary Device: Raspberry Pi

• Raspberry Pi is a low-cost mini-computer with the physical size of a


credit card.
• Raspberry Pi runs various flavors of Linux and can perform almost all
tasks that a normal desktop computer can do.
• Raspberry Pi also allows interfacing sensors and actuators through
the general purpose I/O pins.
• Since Raspberry Pi runs Linux operating system, it supports Python
"out of the box".

Book website: Bahga & Madisetti, ©


Overview of RPI
Raspberry Pi

Book website: Bahga & Madisetti, ©


Linux on Raspberry Pi

• Raspbian
• Raspbian Linux is a Debian Wheezy port optimized for Raspberry Pi.
• Arch
• Arch is an Arch Linux port for AMD (Advanced Micro Devices) devices.
• Pidora
• Pidora Linux is a Fedora Linux optimized for Raspberry Pi.
• RaspBMC
• RaspBMC is an XBMC (Xbox media center) 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.

Book website: Bahga & Madisetti, ©


Raspberry Pi GPIO

Book website: Bahga & Madisetti, ©


Raspberry Pi Commands
Raspberry Pi Interfaces
• 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 SPI Connection, there is one master device and one or more peripheral devices.
• There are five pins on Raspberry Pi for SPI interface
 MISO
 MOSI
 SCK
 CE0, CE1
• I2C
• The I2C interface pins on 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).
Bahga & Madisetti, ©
Bahga & Madisetti, ©
SPI and I2C are the two widely used serial communication protocols. Each communication protocol consists of its syntax
and rules for data transmission between devices.
SPI is an acronym for Serial Peripheral Interface. it is a serial communication protocol. It was developed by Motorola and
allows sending and receiving data at the same time. It requires four wires to communicate between devices. These four wires
include MOSI, MISO, SS, and SCLK. Since there is a line for the clock, SPI is a synchronous serial bus and is capable of
working in full duplex and bidirectional mode. It means that the bus is capable of transmitting data in both directions at the
same time. It supports a single-master and multi-slave system. Although it is slow, it is well-suited for onboard peripherals.

Bahga & Madisetti, ©


I2C

I2C is also known as I2C, IIC, and Inter IC. It is an acronym for Inter-Integrated circuits. Like SPI, it is also a serial
communication protocol. It is developed by Philips Semiconductors. It is a half-duplex communication protocol. It can
either receive or transmit information one at a time. It is well known for two-wire communication. The wires are labeled
SCL (Serial Clock) and SDA (Serial Data). Since there is a clock, it is also synchronous communication. It is a master-to-
slave communication protocol. It supports multi-master and multi-slave systems. All the information transfer between
devices requires only two lines. This is possible because every device (slave) has a unique address.

It allows interconnecting multiple devices over a short distance using a common bus. Although it is slow, it is well-
suited to inter-chip and intra-chip data transfer. All the devices attached to the network share the same bus for exchanging
information. The protocol is beneficial, as is evident from the fact that it requires only two wires. A single bus can support
up to 127 devices.

Bahga & Madisetti, ©


SPI vs I2C

Bahga & Madisetti, ©


Bahga & Madisetti, ©
Bahga & Madisetti, ©
Python Programming with Raspberry Pi

https://roboindia.com/tutorials/category/raspberry-pi/

Bahga & Madisetti, ©


Raspberry Pi Example:
Controlling LED with Raspberry Pi
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, True)
Time.sleep(1)

Bahga & Madisetti, ©


Raspberry Pi Example:
Interfacing LED and switch with Raspberry Pi

Bahga & Madisetti, ©


Raspberry Pi Example:
Interfacing LED and switch with Raspberry Pi

Bahga & Madisetti, ©


Raspberry Pi Example:
Interfacing LED and switch with Raspberry Pi
from time import sleep
import RPi.GPIO as GPIO Controlling an LED with a switch
GPIO.setmode(GPIO.BCM)

GPIO.setup(25, GPIO.IN)
#Switch Pin
GPIO.setup(18,
GPIO.OUT) #LED Pin
state=false

def toggleLED(pin):
state = not state
GPIO.output(pin, state)

while True:
try:
if (GPIO.input(25) == True):
toggleLED(pin)
sleep(01)
Bahga & Madisetti, ©
except KeyboardInterrupt:
Interfacing LDR with Raspberry Pi

Bahga & Madisetti, ©


Interfacing LDR with Raspberry Pi

Bahga & Madisetti, ©


Interfacing LDR with Raspberry Pi
Python Program
import RPi.GPIO as GPIO
import time Def switchOnLight(PIN):
GPIO.setmode(GPIO.BCM) GPIO.setup(PIN, GPIO.OUT)
Ldr_threshold = 1000 GPIO.output(PIN, True)
LDR_PIN=18 Def switchOfLight(PIN);
LIGHT_PIN=25 GPIO.setup(PIN, GPIO.OUT)
Def readLDR(PIN): GPIO.output(PIN, False)
reading=0 While True:
GPIO.setup(LIGHT_PIN, GPIO.OUT) Ldr_reading=readLDR(LDR_PIN)
GPIO.output(PIN, False) If ldr_reading<ldr_threshold:
Time.sleep(0.1) switchOnLight(LIGHT_PIN)
GPIO.setup(PIN, GPIO.IN) Else:
While (GPIO.input(PIN)—False): switchOfLight(LIGHT_PIN)
reading=reading+1 Time.sleep(1)
Return reading

Bahga & Madisetti, ©


Interfacing LDR with Raspberry Pi

Bahga & Madisetti, ©


Sending an email on switch press

Set the Gmail permissions


Import SMTP Library
Email Variables
Board Setup
Raspberry Pi Numbering Schemes
How to setup input pins
Connect to the Gmail Server
Login to Gmail
Send Email and Exit
Bahga & Madisetti, ©
Sending an email on switch
press

Bahga & Madisetti, ©


Sending an email on switch press

Bahga & Madisetti, ©


Sending an email on switch press

Bahga & Madisetti, ©


Sending an email on switch press

Bahga & Madisetti, ©


Sending an email on switch press

Bahga & Madisetti, ©


Sending an email on switch press

Bahga & Madisetti, ©


Other Devices
• pcDuino, BeagleBone Black, Cubieboard

pcDuino
pcDuino is an Arduino-Pin compatible single board mini-computer that come with
a 1Ghz ARM Cortex-A8 Processsor. Pc Duino is a high performance and cost
effective device that runs PC like OS such as Ubuntu and Android ICS.
Like Raspberry Pi, it has an HDMI video/audio interface.
Its supports various programming languages including C, C++, JAVA and Python.

Bahga & Madisetti, ©


Other Devices
• pcDuino, BeagleBone Black, Cubieboard

BeagleBone Black
BeagleBone Black is similar to Raspberry Pi, but a more powerful device. It
comes with a 1Ghz ARM Cortex-A8 processor and supports both Linux and
Android opeariting systems.
Like Raspberry Pi, it has HDMI video/audio interface, USB and Ethernet ports.

Bahga & Madisetti, ©


Other Devices
• Cubieboard
Its powered by a dual core ARM Cortex A7 processor and has a range of input/output
interfaces including USB, HDMI, IR, serial, Ethernet, SATA(Serial Advanced
Technology Attachment) , and a 96 pin extended interface.
It also provides SATA support.
This board can run both Linux and Android operating systems.

Bahga & Madisetti, ©


Other Devices

• pcDu
ino

• BeagleBo
ne Black

• Cubie board

Bahga & Madisetti, ©

You might also like