Contenu connexe Similaire à Raspberry Pi 3 Tutorial | Raspberry Pi 3 Projects | IoT Projects | IoT Tutorial | Edureka (20) Raspberry Pi 3 Tutorial | Raspberry Pi 3 Projects | IoT Projects | IoT Tutorial | Edureka3. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Need of Raspberry Pi
4. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Need of Raspberry Pi
Taking IT back to basics and making it accessible to every school
Making it accessible to every
school
Taking IT back to basics
• Developed by the Raspberry Pi Foundation
• First generation was released in February 2012
“We want to see the Raspberry Pi being used by kids all over the world to learn to program and understand how computers work”
5. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What is Raspberry Pi?
6. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What is Raspberry Pi?
Ras p b err y P i = +
• Low cost, credit-card sized computer
• Plugs into a monitor & uses a keyboard & mouse
• Capable of exploring computing & learn how to program
• Raspberry Pi 3 released in February 2016
Series of small single-board computers bundled with on-board WiFi, Bluetooth and USB boot capabilities, GPIOs etc.
7. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Why Raspberry Pi?
8. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Browsing the internet & playing HD video
Capabilities of Raspberry Pi
Making spreadsheets & word-processing
Playing Games
Infra-red cameras & security systems
Music machines & detectors for weather stations
9. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
10. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
E T H E R N E T P O R T
U S B P O R T
H D M I P O R T
C H A R G E R
A U D I O P O R T
G P I O P I N S
S D C A R D
S L O T
11. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
• Raspberry Pi 1st generation uses Broadcom BCM2835 SoC
• ≅ the chip in 1st generation smartphones
• CPU -> ARMv6 architecture
• VideoCore IV graphics processing unit (GPU) and RAM
• L1 cache of 16 KB and L2 cache of 128 KB
• L2 cache is used primarily by the GPU
• Raspberry Pi 3 uses a Broadcom BCM2837 SoC
• 1.2 GHz 64-bit quad-core ARM Cortex-A53 processor
• 512 KB shared L2 cache & 1 GB RAM
The Raspberry Pi 3, with a quad-core Cortex-A53 processor, is described as 10 times the
performance of a Raspberry Pi 1
12. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
Model A Model B
Generations 1 1+ 1 1+ 2 2 ver 1.2 3
Architecture ARMv6Z (32-bit) ARMv7-A(32-bit) ARMv8-A (64/32-bit)
SoC Broadcom BCM2835
BroadcomBCM2
836
Broadcom BCM2837
CPU 700 MHz single-core ARM1176JZF-S
900 MHz 32-
bit quad-
coreARM
Cortex-A7
900 MHz
64-bit
quad-
core ARM
Cortex-A53
1.2 GHz 64-
bit quad-
core ARM
Cortex-A53
GPU
Broadcom VideoCore IV @ 250 MHz (BCM2837: 3D part of GPU @ 300 MHz, video part of GPU @ 400
MHz)
1080p30 H.264/MPEG-4 AVC high-profile decoder and encoder
13. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Model A Model B
Generations 1 1+ 1 1+ 2 2 ver 1.2 3
Memory
(SDRAM)
256 MB
(shared with
GPU)
512 MB (shared with GPU) as of 4 May
2016. Older boards had 256 MB (shared
with GPU)
1 GB (shared with GPU)
• Initially Model B -> 128 MB was allocated by default to the GPU,
leaving 128 MB for the CPU
• Default split was 192 MB (RAM for CPU), sufficient for 1080p video
decoding or for simple 3D, but not for both together
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
14. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
• Model A, A+ and Pi Zero have no Ethernet circuitry, commonly connected to a network using an
external USB Ethernet or Wi-Fi adapter
• On Model B and B+ the Ethernet port is provided by a built-in USB Ethernet adapter using the
SMSC LAN9514 chip
• Raspberry Pi 3 & Pi Zero W (wireless) are equipped with 2.4 GHz WiFi 802.11n (150 Mbit/s) &
Bluetooth 4.1 (24 Mbit/s) based on Broadcom BCM43438
Model A Model B
Generations 1 1+ 1 1+ 2 2 ver 1.2 3
On-board
network
None
10/100 Mbit/s Ethernet (8P8C) USB adapter on the USB
hub
10/100 Mbit/s
Ethernet,
802.11n
wireless,
Bluetooth 4.1
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
15. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Model A Model B
Generations 1 1+ 1 1+ 2 2 ver 1.2 3
USB 2.0 ports
1 (direct from BCM2835
chip)
2 (via the
on-board
3-port
USB hub)
4 (via the on-board 5-port USB hub)
Audio inputs As of revision 2 boards via I²S
Audio outputs Analog via 3.5 mm phone jack; digital via HDMI and, as of revision 2 boards, I²S
On-board
storage
SD, MMC,
SDIO card
slot
(3.3 Vwith
card power
only)
MicroSDHC
slot
SD, MMC,
SDIO card
slot
MicroSDHC slot
MicroSDHCslot
, USB Boot
Mode
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
16. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
• Video controller can emit standard TV resolutions, such as HD and Full HD, and higher or lower
monitor resolutions
• Raspberry Pi 3 does not have H.265 decoding hardware, but CPU is more powerful enough to
allow the decoding of H.265-encoded videos in software.
• GPU in the Raspberry Pi 3 runs at a higher clock frequencies of 300 MHz or 400 MHz, compared
to previous versions which ran at 250 MHz.
17. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Model A Model B
Generations 1 1+ 1 1+ 2 2 ver 1.2 3
Video input
15-pin MIPI camera interface (CSI) connector, used with the Raspberry Pi camera or Raspberry Pi NoIR
camera
Video outputs
HDMI (rev
1.3) compo
site
video (RCA
jack), MIPI
display
interface
(DSI) for
raw LCD pa
nels
HDMI (rev
1.3),
composite
video
(3.5 mm TR
RS jack),
MIPI
display
interface
(DSI) for
raw LCDpa
nels
HDMI
(rev 1.3),
composit
e video
(RCA
jack),
MIPI
display
interface
(DSI) for
raw LCD p
anels
HDMI (rev 1.3), composite video (3.5 mm TRRS jack), MIPI
display interface (DSI) for raw LCDpanels
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
18. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
Model A Model B
Generations 1 1+ 1 1+ 2 2 ver 1.2 3
Low-level
peripherals
8× GPIO
plus the
following,
which can
also be
used as
GPIO: UAR
T, I²Cbus, S
PI bus with
two chip
selects, I²S
audio+3.3
V, +5 V,
ground
17× GPIO
plus the
same
specific
functions,
and HAT ID
bus
8× GPIO plus the
following, which can
also be used as
GPIO: UART, I²Cbus,
SPI bus with
two chip
selects, I²S audio
+3.3 V, +5 V, ground.
An additional
4× GPIO are
available on the P5
pad if the user is
willing to make
solder connections
17× GPIO plus the same specific functions, and
HAT ID bus
19. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Processor
RAM
Networking
Peripherals
Video
Connectors
GPIO# 2nd func. Pin# Pin# 2nd func. GPIO#
+3.3 V 1 2 +5 V
2 SDA1 (I²C) 3 4 +5 V
3 SCL1 (I²C) 5 6 GND
4 GCLK 7 8 TXD0 (UART) 14
GND 9 10 RXD0 (UART) 15
17 GEN0 11 12 GEN1 18
27 GEN2 13 14 GND
22 GEN3 15 16 GEN4 23
+3.3 V 17 18 GEN5 24
10 MOSI (SPI) 19 20 GND
9 MISO (SPI) 21 22 GEN6 25
11 SCLK (SPI) 23 24 CE0_N (SPI) 8
GND 25 26 CE1_N (SPI) 7
(Pi 1 Models A and B stop here)
EEPROM ID_SD 27 28 ID_SC EEPROM
5 N/A 29 30 GND
6 N/A 31 32 12
13 N/A 33 34 GND
19 N/A 35 36 N/A 16
26 N/A 37 38 Digital IN 20
GND 39 40 Digital OUT 21
20. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
21. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
The Raspberry Pi Foundation recommends the use of Raspbian, a Debian-based Linux operating system
RISC OS
FreeBSD
NetBSD
Plan 9 from Bell Labs
Windows 10 IoT
1
2
3
4
5
22. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
1 Download NOOBS from www.raspberrypi.org
D o w n l o a d
N O O B S . z i p
23. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
1 Download NOOBS from www.raspberrypi.org
E x t r a c t t h e
z i p f i l e &
G o t o
R a s p b i a n
2 Extract the zip File
24. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
1 Download NOOBS from www.raspberrypi.org
C o p y t h e s e f i l e s t o S D C a r d
2 Extract the zip File
3 Copy these file to a formatted SD card
25. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
1 Download NOOBS from www.raspberrypi.org
2 Extract the zip File
3 Copy these file to a formatted SD card
4 Put in Raspberry Pi SD Card slot
26. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi OS Installation
1 Download NOOBS from www.raspberrypi.org
2 Extract the zip File
3 Copy these file to a formatted SD card
4 Put in Raspberry Pi SD Card slot
5 Follow the installation instructions
27. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Accessories
28. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Accessories
HAT (Hardware Attached on Top) expansion boards –
▪ Together with the Model B+, inspired by the Arduino shield boards, the interface for HAT boards was devised by
the Raspberry Pi Foundation.
▪ Each HAT board carries a small EEPROM containing the relevant details of the board
▪ Raspberry Pi's OS is informed of the HAT, and the technical details of it.
▪ Mechanical details of a HAT board are available online.
8X8 LED
Matrix
Temperature
Humidity
Pressure
Joystick
Gyroscope
29. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Camera
• On 14 May 2013, the launched the Raspberry Pi camera board alongside a firmware
update
• 8 megapixel camera
• Camera board has flexible flat cable that plugs into the CSI connector
• Located between the Ethernet and HDMI ports
• User must enable the use of the camera board by running Raspi-config
• Produce 1080p, 720p and 640x480p video
Raspberry Pi Accessories
30. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Accessories
Infrared Camera
• In October 2013, the foundation started producing camera
module without an infrared filter, called the Pi NoIR
Gertboard
• Device designed for educational purposes
• Expands the Raspberry Pi's GPIO pins to allow interface with &
control of LEDs, switches, analog signals, sensors and other
devices
• Includes an optional Arduino compatible controller to interface
with the Pi
31. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Sense Hat Tutorial
32. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Displaying text
Displaying images
Setting orientation
PeripheralsSensing the environment
Detecting movement
from sense_hat import SenseHat
from time import sleep
from random import randint
sense = SenseHat()
r = randint(0,255)
sense.show_letter(“e", (r, 0, 0))
sleep(1)
r = randint(0,255)
sense.show_letter(“d", (0, 0, r))
sleep(1)
sense.clear()
Importing Sense
Hat
Initializing Sense
Hat
Displaying letter e
on LED matrix
Clearing Sense
Hat LED Matrix
33. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Displaying text
Displaying images
Setting orientation
PeripheralsSensing the environment
Detecting movement
from sense_hat import SenseHat
sense = SenseHat()
r = (255, 0, 0)
o = (255, 127, 0)
y = (255, 255, 0)
g = (0, 255, 0)
b = (0, 0, 255)
i = (75, 0, 130)
v = (159, 0, 255)
e = (0, 0, 0)
image =
[e,e,e,e,e,e,e,e,e,e,e,r,r,e,e,e,e,r
,r,o,o,r,r,e,r,o,o,y,y,o,o,r,o,y,y,g
,g,y,y,o,y,g,g,b,b,g,g,y,b,b,b,i,i,b
,b,b,b,i,i,v,v,i,i,b]
sense.set_pixels(image)
RGB code for
different colours
Displaying image
on LED matrix
34. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Displaying text
Displaying images
Setting orientation
PeripheralsSensing the environment
Detecting movement
from sense_hat import SenseHat
import time
sense = SenseHat()
sense.show_letter("J")
angles = [0, 90, 180, 270, 0, 90, 180, 270]
for r in angles:
sense.set_rotation(r)
time.sleep(0.5)
Setting angles for
rotation
Rotating the letter
35. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Displaying text
Displaying images
Setting orientation
PeripheralsSensing the environment
Detecting movement
from sense_hat import SenseHat
sense = SenseHat()
while True:
t = sense.get_temperature()
p = sense.get_pressure()
h = sense.get_humidity()
t = round(t, 1)
p = round(p, 1)
h = round(h, 1)
if t > 18.3 and t < 26.7:
bg = [0, 100, 0] #
green
else:
bg = [100, 0, 0] # red
msg = "Temperature = {0}, Pressure
= {1}, Humidity = {2}".format(t, p, h)
sense.show_message(msg,
scroll_speed=0.05, back_colour=bg)
Getting temperature,
humidity & Pressure
Rounding to 1
decimal point
36. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Displaying text
Displaying images
Setting orientation
PeripheralsSensing the environment
Detecting movement
from sense_hat import SenseHat
sense = SenseHat()
while True:
orientation = sense.get_orientation()
pitch = orientation['pitch']
roll = orientation['roll']
yaw = orientation['yaw’]
print("pitch={0}, roll={1},
yaw={2}".format(pitch,yaw,roll))
Getting orientation
using gyroscope
Getting pitch, roll,
yaw
37. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Hardware
Displaying text
Displaying images
Setting orientation
PeripheralsSensing the environment
Detecting movement
from sense_hat import SenseHat
sense = SenseHat()
while True:
acceleration = sense.get_accelerometer_raw()
x = acceleration['x’]
y = acceleration['y’]
z = acceleration['z’]
x=round(x, 0)
y=round(y, 0)
z=round(z, 0)
print("x={0}, y={1}, z={2}".format(x, y, z))
Gets the amount
of g-force acting
on each axis
39. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Raspberry Pi Demo
40. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Problem Statement
You’re trying to build a security camera for your house. You have to detect the motion or any movement in front of it, and
as it detects any motion it will capture and save the image.
41. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Solution Logic
Start
Save the initial
Image in a frame
Convert this image to a
gaussian blur image
Take the frames with
the object and covert it
into gaussian blur image
Calculate the
difference
If
difference
is
detected?
Initial frame
Yes
Save the
image
No