SlideShare une entreprise Scribd logo
1  sur  41
Building the Internet of Things 
with Raspberry Pi
Who am I? 
I am a Software Developer and Architect at 
Energy Partners 
Caution – I am not an Electronic Engineer! 
Building the Internet of Things 
with Raspberry Pi
Building the Internet of Things 
with Raspberry Pi
Building the Internet of Things 
with Raspberry Pi
Model A Model B Model B+ 
$25 $35 $35 
1 USB port 2 USB ports 4 USB ports 
No Ethernet 10/100 Ethernet 10/100 Ethernet 
SD card slot SD card slot Micro SD card slot 
Building the Internet of Things 
with Raspberry Pi
General-purpose 
input/output pins (GPIO) 
• GPIO pins can be configured 
to be input or output 
• Input values are readable - 
HIGH or LOW (3v3 or 0v) 
• Output values are 
writable/readable 
Building the Internet of Things 
with Raspberry Pi
The Hardware 
Building the Internet of Things 
with Raspberry Pi
Building an Input Circuit 
Opto-coupler / Opto-isolator 
Transfers electrical signals between 
two isolated circuits by using light 
Building the Internet of Things 
with Raspberry Pi
Building an Input Circuit 
Resistor 
Implements electrical resistance 
Reduce current flow 
Building the Internet of Things 
with Raspberry Pi
Pull-up / pull-down resistors 
• Pull-up resistors are connected 
to the high voltage (3.3V) 
• Pull-down resistors are 
connected to ground 
• Initialize an input pin to a 
known state when nothing is 
connected to it 
Building the Internet of Things 
with Raspberry Pi 
Pull-up resistor
Building an Input Circuit - The diagram 
Building the Internet of Things 
with Raspberry Pi
Building an Output Circuit - The 
components 
Transistor 
• Used to amplify and switch electronic 
signals and electrical power 
• A voltage or current applied to one pair of 
the transistor's terminals changes the 
current through another pair of terminals. 
Building the Internet of Things 
with Raspberry Pi
Building an Output Circuit - The 
components 
Relay 
• Electrically operated switch 
• Many relays use an electromagnet to 
mechanically operate a switch 
• To control a circuit by a low-power 
signal 
Building the Internet of Things 
with Raspberry Pi
Building an Output Circuit 
Building the Internet of Things 
with Raspberry Pi
Veroboard / Stripboard 
Building the Internet of Things 
with Raspberry Pi
26pin IDC ribbon cable + crimp 
connector 
Building the Internet of Things 
with Raspberry Pi
Shortcuts! 
Building the Internet of Things 
with Raspberry Pi
Accessories
The Software 
Building the Internet of Things 
with Raspberry Pi
Building the Internet of Things 
with Raspberry Pi
Finding your Pi's hardware revision 
cat /proc/cpuinfo 
Code(s) Model and revision 
2 Model B Revision 1.0 
3 Model B Revision 1.0 + ECN0001 
4, 5, 6 Model B Revision 2.0 
Building the Internet of Things 
with Raspberry Pi
Software considerations 
• The software is the easy 
part! 
• Possible to damage the Pi 
• Triple check your pin 
configuration 
Building the Internet of Things 
with Raspberry Pi
Introducing RPi.GPIO 
• Depending on your distro, probably already 
installed 
• If not, use pip: sudo pip install rpi.gpio 
Building the Internet of Things 
with Raspberry Pi
Basic usage 
#To import the RPi.GPIO module: 
import RPi.GPIO as GPIO 
#Select the pin numbering scheme: 
GPIO.setmode(GPIO.BOARD) 
# or 
GPIO.setmode(GPIO.BCM) 
Building the Internet of Things 
with Raspberry Pi
Exit Cleanly 
• Inputs are safer than outputs 
• Shorting outputs to ground can damage the PI 
• Any ports not reset before script exit will 
remain as is 
• Always perform cleanup before script exits 
Building the Internet of Things 
with Raspberry Pi
Exit Cleanly 
import RPi.GPIO as GPIO 
# the rest of your code goes here 
GPIO.cleanup() 
# remember, a program doesn't necessarily 
# exit at the last line! 
Building the Internet of Things 
with Raspberry Pi
Inputs - Setup 
import RPi.GPIO as GPIO 
#GPIO numbering 
GPIO.setmode(GPIO.BCM) 
channel = 7 
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP) 
# or 
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) 
Building the Internet of Things 
with Raspberry Pi
Inputs - Polling 
if GPIO.input(channel): 
print('Input was HIGH') 
else: 
print('Input was LOW') 
# Or, in a loop 
while GPIO.input(channel) == GPIO.LOW: 
# wait 10 ms 
time.sleep(0.01) 
Building the Internet of Things 
with Raspberry Pi
Inputs - wait_for_edge() 
• blocks execution until an edge is detected 
• GPIO.RISING, GPIO.FALLING or GPIO.BOTH 
GPIO.wait_for_edge(channel, GPIO.RISING) 
Building the Internet of Things 
with Raspberry Pi
Inputs - event_detected() 
• Designed to be used in a loop with other 
things 
# add rising edge detection on a channel 
GPIO.add_event_detect(channel, GPIO.RISING) 
do_something() 
if GPIO.event_detected(channel): 
print('Button pressed') 
Building the Internet of Things 
with Raspberry Pi
Inputs - Threaded callbacks 
• RPi.GPIO runs a second thread for callback 
functions 
GPIO.add_event_detect(channel, GPIO.RISING, 
callback=my_callback) 
Building the Internet of Things 
with Raspberry Pi
Outputs - Setup 
import RPi.GPIO as GPIO 
GPIO.setmode(GPIO.BOARD) 
GPIO.setup(12, GPIO.OUT) 
Building the Internet of Things 
with Raspberry Pi
Outputs 
#Set output to HIGH 
GPIO.output(12, GPIO.HIGH) 
#Set output to LOW 
GPIO.output(12, GPIO.LOW) 
#Read the state of the output 
GPIO.input(12) 
Building the Internet of Things 
with Raspberry Pi
Example - Bell 
Building the Internet of Things 
with Raspberry Pi
The Raspberry Pi Alarm 
Building the Internet of Things 
with Raspberry Pi
On Github 
github.com/nbroers/hal 
Building the Internet of Things 
with Raspberry Pi
What’s next? 
Building the Internet of Things 
with Raspberry Pi
Questions? 
Building the Internet of Things 
with Raspberry Pi
Parts list 
12V input circuit: 
• Optocoupler: LTV-847 - http://www.mantech.co.za/ProductInfo.aspx?Item=340M0324 
• Resistor: 1K Ohm - http://www.mantech.co.za/ProductInfo.aspx?Item=64M0009 
Output circuit: 
• Resistor: 100k ohm 
• Resistor: 10k ohm 
• Transistor (NPN Transistor): P2N2222AG - http://www.mantech.co.za/ProductInfo.aspx?Item=72M3626 
• Relay: EDR101A1200Z - http://www.mantech.co.za/ProductInfo.aspx?Item=35M1045 
• Diode: 1N4007: http://www.mantech.co.za/ProductInfo.aspx?Item=64M0027 
Extras: 
• 26pin IDC ribbon cable crimp connector - http://www.mantech.co.za/ProductInfo.aspx?Item=14M8762 
• Ribbon cable - http://www.mantech.co.za/ProductInfo.aspx?Item=45M0001 
• Single core cable 
• Veroboard - http://www.mantech.co.za/ProductInfo.aspx?Item=64M0010 
Building the Internet of Things 
with Raspberry Pi
References 
Input Circuit design: 
http://raspberrypihobbyist.blogspot.com/2012/09/gpio-input-circuit_19.html 
Output Circuit design: 
http://raspberrypihobbyist.blogspot.com/2012/10/revision-to-relay-circuit.html 
RPi.GPIO wiki 
http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/ 
Raspberry Pi Technical Info 
http://elinux.org/RPi_Low-level_peripherals 
GPIO quick reference 
http://raspi.tv/2014/rpi-gpio-quick-reference-updated-for-raspberry-pi-b 
Exit Cleanly 
http://raspi.tv/2013/rpi-gpio-basics-3-how-to-exit-gpio-programs-cleanly-avoid-warnings-and-protect-your-pi 
Building the Internet of Things 
with Raspberry Pi
Neil Broers 
@nbroers 
neil@foo.co.za 
github.com/nbroers 
Building the Internet of Things 
with Raspberry Pi

Contenu connexe

Tendances

Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Mandeesh Singh
 
Introduction to Raspberrypi
Introduction to  RaspberrypiIntroduction to  Raspberrypi
Introduction to RaspberrypiIheb Ben Salem
 
Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Mandeesh Singh
 
Raspberry Pi - Lecture 6 Working on Raspberry Pi
Raspberry Pi - Lecture 6 Working on Raspberry PiRaspberry Pi - Lecture 6 Working on Raspberry Pi
Raspberry Pi - Lecture 6 Working on Raspberry PiMohamed Abdallah
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioKevin Hooke
 
Single Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsSingle Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsEueung Mulyana
 
Low Cost HD Surveillance Camera using Raspberry PI
Low Cost HD Surveillance Camera using Raspberry PILow Cost HD Surveillance Camera using Raspberry PI
Low Cost HD Surveillance Camera using Raspberry PIVarun A M
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using PythonSeggy Segaran
 
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick NeshRaspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick NeshTE4P
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pipraveen_23
 

Tendances (20)

Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014
 
Raspberry-Pi
Raspberry-PiRaspberry-Pi
Raspberry-Pi
 
Introduction to Raspberrypi
Introduction to  RaspberrypiIntroduction to  Raspberrypi
Introduction to Raspberrypi
 
Raspberry pi ppt
Raspberry pi pptRaspberry pi ppt
Raspberry pi ppt
 
Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Raspberry Pi (Introduction)
Raspberry Pi (Introduction)
 
Raspberry PI
Raspberry PIRaspberry PI
Raspberry PI
 
Raspberry Pi - Lecture 6 Working on Raspberry Pi
Raspberry Pi - Lecture 6 Working on Raspberry PiRaspberry Pi - Lecture 6 Working on Raspberry Pi
Raspberry Pi - Lecture 6 Working on Raspberry Pi
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur Radio
 
RASPBERRY PI
RASPBERRY PIRASPBERRY PI
RASPBERRY PI
 
IPv6: A Digital Game Changer
IPv6: A Digital Game ChangerIPv6: A Digital Game Changer
IPv6: A Digital Game Changer
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Single Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsSingle Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi Basics
 
Low Cost HD Surveillance Camera using Raspberry PI
Low Cost HD Surveillance Camera using Raspberry PILow Cost HD Surveillance Camera using Raspberry PI
Low Cost HD Surveillance Camera using Raspberry PI
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using Python
 
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick NeshRaspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
 
Raspberry pi complete setup
Raspberry pi complete setupRaspberry pi complete setup
Raspberry pi complete setup
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pi
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 

En vedette

[16.01.05] node.js & mqtt
[16.01.05] node.js & mqtt[16.01.05] node.js & mqtt
[16.01.05] node.js & mqttNa-yeon Park
 
Leveraging Android for the Internet of Things with Eclipse M2M
Leveraging Android for the Internet of Things with Eclipse M2MLeveraging Android for the Internet of Things with Eclipse M2M
Leveraging Android for the Internet of Things with Eclipse M2MBenjamin Cabé
 
Raspberry pi : an introduction
Raspberry pi : an introductionRaspberry pi : an introduction
Raspberry pi : an introductionLTG Oxford
 
Alvin Edwald Chan - Why internet of things
Alvin Edwald Chan - Why internet of thingsAlvin Edwald Chan - Why internet of things
Alvin Edwald Chan - Why internet of thingsReginald Agsalon
 
Un Raspberry Pi pour bidouiller
Un Raspberry Pi pour bidouillerUn Raspberry Pi pour bidouiller
Un Raspberry Pi pour bidouillerLook a box
 
Rasberry nodejs install_final
Rasberry nodejs install_finalRasberry nodejs install_final
Rasberry nodejs install_finalKwan Yeong Kim
 
RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)
RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)
RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)savageautomate
 
MQTT on Raspberry Pi with node.js
MQTT on Raspberry Pi with node.jsMQTT on Raspberry Pi with node.js
MQTT on Raspberry Pi with node.jsPaul Tanner
 
Raspberry Pi - Einführung und Beispielprojekte
Raspberry Pi - Einführung und BeispielprojekteRaspberry Pi - Einführung und Beispielprojekte
Raspberry Pi - Einführung und BeispielprojektePeter Eulberg
 
Beacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.jsBeacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.jsJeff Prestes
 
Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.
Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.
Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.Nat Weerawan
 
Internet das coisas (IoT) com Raspberry, Python e Node.js
Internet das coisas (IoT) com Raspberry, Python e Node.jsInternet das coisas (IoT) com Raspberry, Python e Node.js
Internet das coisas (IoT) com Raspberry, Python e Node.jsOtávio Calaça Xavier
 
An introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-REDAn introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-REDBoris Adryan
 
Physical computing with Python and Raspberry Pi
Physical computing with Python and Raspberry PiPhysical computing with Python and Raspberry Pi
Physical computing with Python and Raspberry Pibennuttall
 
[IoT] MAKE with Open H/W + Node.JS - 1st
[IoT] MAKE with Open H/W + Node.JS - 1st[IoT] MAKE with Open H/W + Node.JS - 1st
[IoT] MAKE with Open H/W + Node.JS - 1stPark Jonggun
 
Hy Wire Car Technology
Hy Wire Car TechnologyHy Wire Car Technology
Hy Wire Car TechnologyVishal Singh
 

En vedette (20)

[16.01.05] node.js & mqtt
[16.01.05] node.js & mqtt[16.01.05] node.js & mqtt
[16.01.05] node.js & mqtt
 
Leveraging Android for the Internet of Things with Eclipse M2M
Leveraging Android for the Internet of Things with Eclipse M2MLeveraging Android for the Internet of Things with Eclipse M2M
Leveraging Android for the Internet of Things with Eclipse M2M
 
Raspberry Pi + Python
Raspberry Pi + PythonRaspberry Pi + Python
Raspberry Pi + Python
 
Raspberry pi : an introduction
Raspberry pi : an introductionRaspberry pi : an introduction
Raspberry pi : an introduction
 
Raspberry pi a la cfml
Raspberry pi a la cfmlRaspberry pi a la cfml
Raspberry pi a la cfml
 
Alvin Edwald Chan - Why internet of things
Alvin Edwald Chan - Why internet of thingsAlvin Edwald Chan - Why internet of things
Alvin Edwald Chan - Why internet of things
 
Un Raspberry Pi pour bidouiller
Un Raspberry Pi pour bidouillerUn Raspberry Pi pour bidouiller
Un Raspberry Pi pour bidouiller
 
Rasberry nodejs install_final
Rasberry nodejs install_finalRasberry nodejs install_final
Rasberry nodejs install_final
 
RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)
RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)
RASPBERRY PI WITH JAVA 8 + Pi4J (Devoxx 2014)
 
MQTT on Raspberry Pi with node.js
MQTT on Raspberry Pi with node.jsMQTT on Raspberry Pi with node.js
MQTT on Raspberry Pi with node.js
 
Raspberry Pi - Einführung und Beispielprojekte
Raspberry Pi - Einführung und BeispielprojekteRaspberry Pi - Einführung und Beispielprojekte
Raspberry Pi - Einführung und Beispielprojekte
 
Beacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.jsBeacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.js
 
Home Automation
Home AutomationHome Automation
Home Automation
 
Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.
Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.
Create connected home devices using a Raspberry Pi, Siri and ESPNow for makers.
 
Raspbeery PI IoT
Raspbeery PI IoTRaspbeery PI IoT
Raspbeery PI IoT
 
Internet das coisas (IoT) com Raspberry, Python e Node.js
Internet das coisas (IoT) com Raspberry, Python e Node.jsInternet das coisas (IoT) com Raspberry, Python e Node.js
Internet das coisas (IoT) com Raspberry, Python e Node.js
 
An introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-REDAn introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-RED
 
Physical computing with Python and Raspberry Pi
Physical computing with Python and Raspberry PiPhysical computing with Python and Raspberry Pi
Physical computing with Python and Raspberry Pi
 
[IoT] MAKE with Open H/W + Node.JS - 1st
[IoT] MAKE with Open H/W + Node.JS - 1st[IoT] MAKE with Open H/W + Node.JS - 1st
[IoT] MAKE with Open H/W + Node.JS - 1st
 
Hy Wire Car Technology
Hy Wire Car TechnologyHy Wire Car Technology
Hy Wire Car Technology
 

Similaire à Building the Internet of Things with Raspberry Pi

[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi Tomomi Imura
 
IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfGVNSK Sravya
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRICELEEIO
 
IoT for data science Module 5 - Raspberry Pi.pptx
IoT for data science Module 5 - Raspberry Pi.pptxIoT for data science Module 5 - Raspberry Pi.pptx
IoT for data science Module 5 - Raspberry Pi.pptxMadhurimaDas52
 
Bulb Control using Web App with Raspberry Pi
Bulb Control using Web App with Raspberry Pi Bulb Control using Web App with Raspberry Pi
Bulb Control using Web App with Raspberry Pi Sanjay Kumar
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218CAVEDU Education
 
Linux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayLinux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayHeart Disk
 
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)Mr.Nukoon Phimsen
 
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”GlobalLogic Ukraine
 
Got Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOGot Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOAdam Englander
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxTuynLCh
 
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016Sebin Benjamin
 

Similaire à Building the Internet of Things with Raspberry Pi (20)

[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
 
Unit 3 Complete.pptx
Unit 3 Complete.pptxUnit 3 Complete.pptx
Unit 3 Complete.pptx
 
IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdf
 
Capstone_Project.ppt
Capstone_Project.pptCapstone_Project.ppt
Capstone_Project.ppt
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
 
IoT for data science Module 5 - Raspberry Pi.pptx
IoT for data science Module 5 - Raspberry Pi.pptxIoT for data science Module 5 - Raspberry Pi.pptx
IoT for data science Module 5 - Raspberry Pi.pptx
 
Bulb Control using Web App with Raspberry Pi
Bulb Control using Web App with Raspberry Pi Bulb Control using Web App with Raspberry Pi
Bulb Control using Web App with Raspberry Pi
 
Amity Raspberry Jam
Amity Raspberry JamAmity Raspberry Jam
Amity Raspberry Jam
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Linux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayLinux Format - Get Into Linux Today
Linux Format - Get Into Linux Today
 
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
 
Raspberry Pi
Raspberry Pi Raspberry Pi
Raspberry Pi
 
IoT Aquarium 2
IoT Aquarium 2IoT Aquarium 2
IoT Aquarium 2
 
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
 
Raspberry pi led blink
Raspberry pi led blinkRaspberry pi led blink
Raspberry pi led blink
 
Got Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOGot Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIO
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
 
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 

Dernier

Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 

Dernier (20)

Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 

Building the Internet of Things with Raspberry Pi

  • 1. Building the Internet of Things with Raspberry Pi
  • 2. Who am I? I am a Software Developer and Architect at Energy Partners Caution – I am not an Electronic Engineer! Building the Internet of Things with Raspberry Pi
  • 3. Building the Internet of Things with Raspberry Pi
  • 4. Building the Internet of Things with Raspberry Pi
  • 5. Model A Model B Model B+ $25 $35 $35 1 USB port 2 USB ports 4 USB ports No Ethernet 10/100 Ethernet 10/100 Ethernet SD card slot SD card slot Micro SD card slot Building the Internet of Things with Raspberry Pi
  • 6. General-purpose input/output pins (GPIO) • GPIO pins can be configured to be input or output • Input values are readable - HIGH or LOW (3v3 or 0v) • Output values are writable/readable Building the Internet of Things with Raspberry Pi
  • 7. The Hardware Building the Internet of Things with Raspberry Pi
  • 8. Building an Input Circuit Opto-coupler / Opto-isolator Transfers electrical signals between two isolated circuits by using light Building the Internet of Things with Raspberry Pi
  • 9. Building an Input Circuit Resistor Implements electrical resistance Reduce current flow Building the Internet of Things with Raspberry Pi
  • 10. Pull-up / pull-down resistors • Pull-up resistors are connected to the high voltage (3.3V) • Pull-down resistors are connected to ground • Initialize an input pin to a known state when nothing is connected to it Building the Internet of Things with Raspberry Pi Pull-up resistor
  • 11. Building an Input Circuit - The diagram Building the Internet of Things with Raspberry Pi
  • 12. Building an Output Circuit - The components Transistor • Used to amplify and switch electronic signals and electrical power • A voltage or current applied to one pair of the transistor's terminals changes the current through another pair of terminals. Building the Internet of Things with Raspberry Pi
  • 13. Building an Output Circuit - The components Relay • Electrically operated switch • Many relays use an electromagnet to mechanically operate a switch • To control a circuit by a low-power signal Building the Internet of Things with Raspberry Pi
  • 14. Building an Output Circuit Building the Internet of Things with Raspberry Pi
  • 15. Veroboard / Stripboard Building the Internet of Things with Raspberry Pi
  • 16. 26pin IDC ribbon cable + crimp connector Building the Internet of Things with Raspberry Pi
  • 17. Shortcuts! Building the Internet of Things with Raspberry Pi
  • 19. The Software Building the Internet of Things with Raspberry Pi
  • 20. Building the Internet of Things with Raspberry Pi
  • 21. Finding your Pi's hardware revision cat /proc/cpuinfo Code(s) Model and revision 2 Model B Revision 1.0 3 Model B Revision 1.0 + ECN0001 4, 5, 6 Model B Revision 2.0 Building the Internet of Things with Raspberry Pi
  • 22. Software considerations • The software is the easy part! • Possible to damage the Pi • Triple check your pin configuration Building the Internet of Things with Raspberry Pi
  • 23. Introducing RPi.GPIO • Depending on your distro, probably already installed • If not, use pip: sudo pip install rpi.gpio Building the Internet of Things with Raspberry Pi
  • 24. Basic usage #To import the RPi.GPIO module: import RPi.GPIO as GPIO #Select the pin numbering scheme: GPIO.setmode(GPIO.BOARD) # or GPIO.setmode(GPIO.BCM) Building the Internet of Things with Raspberry Pi
  • 25. Exit Cleanly • Inputs are safer than outputs • Shorting outputs to ground can damage the PI • Any ports not reset before script exit will remain as is • Always perform cleanup before script exits Building the Internet of Things with Raspberry Pi
  • 26. Exit Cleanly import RPi.GPIO as GPIO # the rest of your code goes here GPIO.cleanup() # remember, a program doesn't necessarily # exit at the last line! Building the Internet of Things with Raspberry Pi
  • 27. Inputs - Setup import RPi.GPIO as GPIO #GPIO numbering GPIO.setmode(GPIO.BCM) channel = 7 GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP) # or GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) Building the Internet of Things with Raspberry Pi
  • 28. Inputs - Polling if GPIO.input(channel): print('Input was HIGH') else: print('Input was LOW') # Or, in a loop while GPIO.input(channel) == GPIO.LOW: # wait 10 ms time.sleep(0.01) Building the Internet of Things with Raspberry Pi
  • 29. Inputs - wait_for_edge() • blocks execution until an edge is detected • GPIO.RISING, GPIO.FALLING or GPIO.BOTH GPIO.wait_for_edge(channel, GPIO.RISING) Building the Internet of Things with Raspberry Pi
  • 30. Inputs - event_detected() • Designed to be used in a loop with other things # add rising edge detection on a channel GPIO.add_event_detect(channel, GPIO.RISING) do_something() if GPIO.event_detected(channel): print('Button pressed') Building the Internet of Things with Raspberry Pi
  • 31. Inputs - Threaded callbacks • RPi.GPIO runs a second thread for callback functions GPIO.add_event_detect(channel, GPIO.RISING, callback=my_callback) Building the Internet of Things with Raspberry Pi
  • 32. Outputs - Setup import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) Building the Internet of Things with Raspberry Pi
  • 33. Outputs #Set output to HIGH GPIO.output(12, GPIO.HIGH) #Set output to LOW GPIO.output(12, GPIO.LOW) #Read the state of the output GPIO.input(12) Building the Internet of Things with Raspberry Pi
  • 34. Example - Bell Building the Internet of Things with Raspberry Pi
  • 35. The Raspberry Pi Alarm Building the Internet of Things with Raspberry Pi
  • 36. On Github github.com/nbroers/hal Building the Internet of Things with Raspberry Pi
  • 37. What’s next? Building the Internet of Things with Raspberry Pi
  • 38. Questions? Building the Internet of Things with Raspberry Pi
  • 39. Parts list 12V input circuit: • Optocoupler: LTV-847 - http://www.mantech.co.za/ProductInfo.aspx?Item=340M0324 • Resistor: 1K Ohm - http://www.mantech.co.za/ProductInfo.aspx?Item=64M0009 Output circuit: • Resistor: 100k ohm • Resistor: 10k ohm • Transistor (NPN Transistor): P2N2222AG - http://www.mantech.co.za/ProductInfo.aspx?Item=72M3626 • Relay: EDR101A1200Z - http://www.mantech.co.za/ProductInfo.aspx?Item=35M1045 • Diode: 1N4007: http://www.mantech.co.za/ProductInfo.aspx?Item=64M0027 Extras: • 26pin IDC ribbon cable crimp connector - http://www.mantech.co.za/ProductInfo.aspx?Item=14M8762 • Ribbon cable - http://www.mantech.co.za/ProductInfo.aspx?Item=45M0001 • Single core cable • Veroboard - http://www.mantech.co.za/ProductInfo.aspx?Item=64M0010 Building the Internet of Things with Raspberry Pi
  • 40. References Input Circuit design: http://raspberrypihobbyist.blogspot.com/2012/09/gpio-input-circuit_19.html Output Circuit design: http://raspberrypihobbyist.blogspot.com/2012/10/revision-to-relay-circuit.html RPi.GPIO wiki http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/ Raspberry Pi Technical Info http://elinux.org/RPi_Low-level_peripherals GPIO quick reference http://raspi.tv/2014/rpi-gpio-quick-reference-updated-for-raspberry-pi-b Exit Cleanly http://raspi.tv/2013/rpi-gpio-basics-3-how-to-exit-gpio-programs-cleanly-avoid-warnings-and-protect-your-pi Building the Internet of Things with Raspberry Pi
  • 41. Neil Broers @nbroers neil@foo.co.za github.com/nbroers Building the Internet of Things with Raspberry Pi