IoT Unit - II - Dr. Anup Dey
IoT Unit - II - Dr. Anup Dey
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.
• 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
• 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
#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
•
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