0% found this document useful (0 votes)
11 views108 pages

IoT Unit - II - Dr. Anup Dey

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)
11 views108 pages

IoT Unit - II - Dr. Anup Dey

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/ 108

Unit-II

IoT Physical Devices &


Endpoints

By
Dr. Anup Dey
Assistant Professor
School of CS & AI
SR University, Warangal
Outline
•Introduction to RaspberryPi
•About the RaspberryPi Board
• Hardware Layout and Pinouts
•Operating Systems on RaspberryPi
•Configuring RaspberryPi
•Programming RaspberryPi
•Connecting Raspberry Pi via SSH, Remote access tools,
•Interfacing DHT Sensor with Pi
•Pi as Webserver
• Pi Camera
• Image & Video Processing using Pi.
Raspberry Pi
•The Raspberry Pi is a series of small single-board computers developed in the
United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic
computer science in schools and in developing countries.
• 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".
Raspberry Pi
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
Raspberry Pi …TimeLine
• The first generation (Raspberry Pi 1 Model B) was released in
February 2012.
• It was followed by a simpler and inexpensive model Model A.
• In 2014, the foundation released a board with an improved design
in Raspberry Pi 1 Model B+. These boards are approximately
credit-card sized and represent the standard mainline form-factor.
• Improved A+ and B+ models were released a year later. A
"compute module" was released in April 2014 for embedded
applications, and a Raspberry Pi Zero with smaller size and reduced
input/output (I/O) and general- purpose input/output (GPIO)
capabilities was released in November 2015 for US$5.
Raspberry Pi …TimeLine
• The Raspberry Pi 2 which added more RAM was released in
February 2015.
• Raspberry Pi 3 Model B released in February 2016, is bundled
with on-board WiFi, Bluetooth and USB boot capabilities.
• As of January 2017, Raspberry Pi 3 Model B is the newest
mainline Raspberry Pi. Raspberry Pi boards are priced between
US$5–35.
• As of 28 February 2017, the Raspberry Pi Zero W was launched,
which is identical to the Raspberry Pi Zero, but has the Wi-Fi and
Bluetooth functionality of the Raspberry Pi 3 for US$10.
Raspberry Pi …Features
• Features a Broadcom system on a chip which includes an ARM
compatible central processing unit (CPU) and an on-chip
graphics processing unit (GPU).

• CPU speed ranges from 700 MHz to 1.2 GHz for the Pi 3 and on
board memory range from 256 MB to 1 GB RAM.

• Secure Digital (SD) cards are used to store the operating


system and program memory in either the SDHC or MicroSDHC
sizes.
Raspberry Pi …Features
• Most boards have between one and four USB slots, HDMI and
composite video output, and a 3.5 mm phono jack for audio.

• Lower level output is provided by a number of GPIO pins


which support common protocols like I²C.

• The B-models have an 8P8C Ethernet port and the Pi 3 and Pi


Zero W have on board Wi-Fi 802.11n and Bluetooth.
Raspberry Pi …Operating System
• The Foundation provides Raspbian, a Debian- based Linux
distribution for download, as well as third party Ubuntu,
Windows 10 IOT Core, RISC OS, and specialised media center
distributions.

• It promotes Python and Scratch as the main programming


language, with support for many other languages.

• The default firmware is closed source, while an unofficial open


source is available.
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 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 …Operating System
Hardware
Hardware

• This block diagram depicts Models A, B, A+, and B+.


Model A, A+, and the Pi Zero lack t he Ethernet and USB
hub components.
• The Ethernet adapter is internally connected to
an addit ional USB port .
• In Model A, A+, and the Pi Zero, the USB port is
connected directly to the system on a chip (SoC). On the
Pi 1 Model B+ and later models the USB/Ethernet chip
contains a five- point USB hub, of which four ports are
available, while the Pi 1 Model B only provides two.
• On the Pi Zero, the USB port is also connected directly
to t he SoC, but it uses a micro USB (OTG) port .
Processor

• The Broadcom BCM2835 SoC used in the first generation


Raspberry Pi is somewhat equivalent to the chip used in first
modern generat ion smar tphones (it s CPU is an older ARMv6
archit ecture), which includes a 700 MHz ARM1176JZF-S processor,
VideoCore IV graphics processing unit (GPU), and RAM.
• It has a level 1 (L1) cache of 16 KB and a level 2 (L2) cache of 128
KB. The level 2 cache is used primarily by the GPU. The SoC is
stacked underneath the RAM chip, so only its edge is visible.
• The Raspberry Pi 2 uses a Broadcom BCM2836 SoC with a 900
MHz 32-bit quad-core ARM Cortex-A7 processor, with 256 KB
shared L2 cache.
• The Raspberry Pi 3 uses a Broadcom BCM2837 SoC with a 1.2 GHz
64-bit quad-core ARM Cortex-A53 processor, with 512 KB shared
L2 cache
Performance

• The Raspberry Pi 3, with a quad-core Cortex-A53


processor, is described as 10 t imes t he perf ormance of a
Raspberry Pi
1.This was suggested to be highly dependent upon task
threading and instruction set use. Benchmarks showed
the Raspberry Pi 3 to be approximately 80% faster than
the Raspberry Pi 2 in parallelized tasks.
• Raspberry Pi 2 includes a quad-core Cort ex-A7 CPU
running at 900 MHz and 1 GB RAM. It is described as 4–6
times more powerful than its predecessor. The GPU is
identical to the original. In parallelized benchmarks, the
Raspberry Pi 2 could be up to 14 times faster than a
Raspberry Pi 1 Model B+.
RAM

• The Raspberry Pi 2 and the Raspberry Pi


3 have 1 GB of RAM.
• The Raspberry Pi Zero and Zero W
have 512 MB of RAM.
Networking

• The Model A, A+ and Pi Zero have no Ethernet


circuitry and are commonly connected t o a network
using an external user-supplied USB Ethernet or Wi-
Fi adapter.
• On the Model B and B+ the Ethernet port is provided by
a built-in USB Ethernet adapter using the SMSC
LAN9514 chip.
• The Raspberry Pi 3 and Pi Zero W (wireless) are
equipped with 2.4 GHz WiFi 802.11n (150 Mbit/s) and
Bluetooth 4.1 (24 Mbit/s) based on Broadcom
BCM43438 FullMAC chip with no official support for
Monitor mode but implemented through unofficial
firmware patching and t he Pi 3 also has a 10/100
Ethernet port .
Peripherals

• The Raspberry Pi may be operated with


any generic USB computer keyboard
and mouse.
• It may also be used wit h USB storage,
USB to MIDI converters, and virtually any
other device/ component wit h USB
capabilit ies.
• Other peripherals can be attached
through the various pins and connectors
on the surface of the Raspberry Pi.
Video Capabilities

• The video controller can emit standard modern


TV resolutions, such as HD and Full HD, and
higher or lower monitor resolutions and older
standard CRT TV resolutions.
• As shipped, it can emit these: 640×350 EGA;
640×480 VGA; 800×600 SVGA; 1024×768 XGA;
1280×720 720p HDTV; 1280×768 WXGA variant;
1280×800 WXGA variant; 1280×1024 SXGA;
1366×768 WXGA variant; 1400×1050 SXGA+;
1600×1200 UXGA; 1680×1050 WXGA+;
1920×1080 1080p HDTV; 1920×1200 WUXGA.
Raspberry Pi …Hardware
Raspberry Pi GPIO (26 Pin)
Raspberry Pi GPIO (26 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)
Raspberry Pi GPIO (40 Pin)

GND-8 pins, GPIO-26 pins, VCC-4 pins & Reserved-2 pins


Raspberry Pi Example:
Interfacing LED and switch with Raspberry Pi
Raspberry Pi Vs. Arduino
Raspberry Pi Vs. Arduino
Raspberry Pi Vs. Arduino
Raspberry Pi Vs. Arduino
Raspberry Pi Vs. Arduino
Operating System
Operating System
Operating System
Operating System
Operating System
Operating System
Raspbian

• Raspbian is a Debian-based computer operating


system for Raspberry Pi. Since 2015 till now it is
officially provided by the Raspberry Pi Foundation
as the primary operating system for the family of
Raspberry Pi single-board computers.
• Raspbian was created by Mike Thompson and
Peter Green as an independent project .
• The initial build was completed in June 2012.
• The operating system is still under active
development. Raspbian is highly optimized for
the Raspberry Pi line's low-performance ARM
CPUs.
Raspbian

• Raspbian uses PIXEL, Pi Improved


Xwindows Environment, Lightweight as its
main desktop environment as of the lat est
updat e.
• It is composed of a modified LXDE desktop
environment and the Openbox stacking window
manager with a new theme and few other
changes.
• The distribution is shipped with a copy of
computer algebra program Mathematica and a
version of Minecraft called Minecraft Pi as well as
a lightweight version of Chromium as of the
latest version.
Basic features

• Developer Raspberry Pi
• OS family Foundat ion Unix-like
• Source model Open source
• Lat est Raspbian Jessie with PIXEL /
• release 16.02.2017Pi
Marketing target Raspberry
• Update method APT
• Package manager dpkg
• Platforms ARM
• Kernel Monolithic
type GNU
•• Userland
Default user int erface PIXEL, LXDE
• License Free and open-source software licenses (mainly GPL)
• Official website
https://www.raspberrypi.org/downloads/raspbian/
Downloads
GUI
How to write disk image?
Finalization

• Complete the disk image writing


process.
• Now insert t he SD card in Raspberry Pi.
• Plug-in the power supply to the kit.
• Lets see the OS….
Programming Languages

• Python [Recommended for


coding]
•C
• C++
• Java
• Scratch
Software Management on Pi

• sudo apt-get update


• sudo apt-get upgrade
• sudo apt-get install <package>
• sudo apt-get download
<package>
• sudo apt-get remove <package>
• sudo apt-get purge <package>
• sudo apt-get dist-upgrade
Accessing Pi in Linux

• The Rpi can be accessed in Linux


terminal by secure shell.

• The Pi GUI can be accessed using


VNC server.
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.
• 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).
Raspberry Pi Example:
Interfacing LED and switch with Raspberry Pi
Raspberry Pi Example:
Interfacing LED and switch with Raspberry Pi

from time import sleep


import RPi.GPIO as
GPIO
GPIO.setmode(GPIO.BC
M)

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

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

while True:
try:
if (GPIO.input(25) ==
True):
toggleLED(pin)
sleep(.01)
except
KeyboardInterrupt:
Raspberry Pi Camera Module
• The Raspberry Pi Camera Module v2 replaced
the original Camera Module in April 2016.
• The v2 Camera Module has a Sony IMX219 8-
megapixel sensor (compared to the 5-megapixel
OmniVision OV5647 sensor of the original
camera).
• The Camera Module can be used to take high-
definition video, as well as stills photographs. It’s
easy to use for beginners, but has plenty to offer
advanced users if you’re looking to expand your
knowledge.
• You can also use the libraries we bundle with
the camera to create effects.
Raspberry Pi Camera Module
• You can read all the gory details about
IMX219 and the Exmor R back-illuminated
sensor architecture on Sony’s website, but
suffice to say this is more than just a
resolution upgrade: it’s a leap forward in
image quality, colour fidelity, and low-light
performance.
• It supports 1080p30, 720p60 and VGA90
video modes, as well as st ill capture. It
at t aches via a 15cm ribbon cable t o th e CSI
port on t he Raspberry Pi.
Raspberry Pi Camera Module
• The camera works with all models
of Raspberry Pi 1, 2, and 3.
• It can be accessed through the MMAL
and V4L APIs, and t here are numerous
t hird- party libraries built for it,
including the Picamera Python library.
• The camera module is very popular in
home security applications, and in
wildlife camera traps.
Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Connecting the Pi Camera
Open Raspberry Pi Configuration
Enable the Camera interface
Enable the Camera interface
Enable the Camera interface
Camera preview
Rotating the Camera

You can rotate the image by 90, 180, or 270


degrees, or you can set it to 0 to reset.
Change transperancy
Storing the image
Taking five pictures in a row
Recording a Video
Converting and Playing Video

• The video format need to get


converted t o MP4. So install gpac.
sudo apt-get install gpac
• Now convert the video to MP4:
MP4Box -fps 30 -add video.h264 video.mp4
Effects
• The resolution of the capture is configurable.
• By default it’s set to the resolution of your
monitor, but the maximum resolution is 2592 x
1944 for still photos and 1920 x 1080 for video
recording.
• Try the following example to set the resolution
to max.
• Note that you’ll also need to set the frame rate
to 15 to enable this maximum resolution:
• The minimum resolution allowed is 64 x 64.
Try taking one at that resolution.
Effects: Frame rate and Resolution
Effects: Text Annotation
Effects: Brightness
Annotation Text Sizes

• You can set the annotation text size


with the following code:
camera.annotate_text_size = 50

• Valid sizes are 6 to 160. The default is


32.
Annotation Colors

• You can also alter the annotation


colours. First of all, ensure that Color is
imported by amending your import line
at the top:
from picamera import PiCamera, Color
• Then amend the rest of your code
as follows:
Image Effects

• You can use camera.image_effect to apply a


particular image effect.

The opti ons are: none, negative, solarize, sketch, denoise, emboss, oilpaint, hatch, gpen,
pastel, watercolor, fi lm, blur, saturation, colorswap, washedout, posterise, colorpoint,
colorbalance, cartoon, deinterlace1, and deinterlace2.
The default is none.


Image Effects
Looping various Effects
AWB mode
• You can use camera.awb_mode to set the auto
white balance t o a preset mode t o apply a
part icular ef f ect .
• The options are: off, auto, sunlight, cloudy, shade,
tungsten, fluorescent, incandescent, flash, and
horizon. The default is auto.
Exposure mode
• You can use camera.exposure_mode to set the
exposure to a preset mode to apply a particular effect.
• The options are: off, auto, night, nightpreview,
backlight, spotlight, sports, snow, beach, verylong,
fixedfps, antishake, and fireworks. The default is
auto.
Live streaming

You might also like