SlideShare a Scribd company logo
[Feb 2016] A Special Webinar for Forward4
Internet of Things 101:
Building IoT Prototypes w/ Raspberry Pi
Tomomi Imura (@girlie_mac)
Tomomi
(@girlie_mac)
● Lead Dev Evangelist at PubNub
● Front-End Dev
● ❤ Hardware hacking
● Cat Lady of the InterWeb
What You Will Learn Today
1. Internet of Things and Data Stream
2. How to send & receive data with PubNub using Python
3. How to wire a LED & resistor to Pi using breadboard
4. How to program Pi to blink the LED
5. Making it IoT : Remote-controlled LED from web interface
Era of Internet of Things
Source: PLATFORM, data based on Cisco IBSG
Estimate 50B by 2020
non-human/human = 6.58
2003:
non-human/human = 0.08
2015:
non-human/human = 3.47
2008:
non-human/human >= 1
Withings: Smart Body Analyzer
GE Link
Cinder
Sensing Cooker
Nest: Learning
Thermostat
Whistle: Connected pet collar
Amazon
Dash Button
Smart Devices
Smart-Ass Devices :-D
Internet of Things
………
Bluetooth
Internet of Things with
Data Stream
Send & Receive Data to/from Data
Center via Internet
PubNub Data Stream
Two-way communication to/from every device in the world.
https://pubnub.com
Realtime Reliable Secure
PubNub is globally distributed realtime data stream
network (DNS)
PubNub Use-Cases
◼ Chat (Periscope)
◼ Multi-player games (DeNA games)
◼ Vehicle Location Tracking (Lyft, GetTaxi)
◼ Financial data (TD Ameritrade)
◼ Collaborative teaching tools (ClassDojo, CodePen)
◼ IoT, Smart Home (Insteon, Logitech)
Prototyping Internet of
Things
Send & Receive Data to/from Data
Center via Internet
LED
6. USB TO POWER SOURCE 5. TO MONITOR
4. TO MOUSE
3. TO KEYBOARD
2. WI-FI ADAPTER
1. SD CARD
Getting Started with
Raspberry Pi
https://github.com/pubnub/
workshop-raspberrypi
Raspbian OS
SSH into your Rasp Pi
1. Get your Raspberry Pi’s IP address
pi@raspberrypi ~$ hostname -I
2. SSH to Pi from your laptop
(Terminal on Mac/Linux, PuTTY on Windows):
me@MyMac ~$ ssh pi@10.96.70.1
SSH into your Rasp Pi
Use your Pi’s IP!
Your Pi’s username
If SSH-ing fails, try:
$ sudo raspi-config
on your Pi
Programming Rasp Pi
Pre-installed on Raspberry Pi:
C / C++
Get Started w/ Python
Update your system first
~$ sudo apt-get update
~$ sudo apt-get upgrade
Install python and pip
~$ sudo apt-get install python-dev
~$ sudo apt-get install python-pip
Wut, you want Node.js?
~$ wget
http://node-arm.herokuapp.com/node_latest_
armhf.deb
...but we’re using python today!
Don’t worry, I’m a JS dev too :-)
Installing PubNub
~$ sudo pip install pubnub
https://github.com/pubnub/
workshop-raspberrypi/tree/master/
projects-python/helloworld
Hello World w/ PubNub
Hello World w/ PubNub
Import & init (hello.py)
import sys
from pubnub import Pubnub
pubnub = Pubnub(publish_key='demo',
subscribe_key='demo')
Use your own publish
& subscribe keys!
Hello World w/ PubNub
Publish (Sending data)
channel = 'hello-pi'
data = { 'username': 'Grumpy Cat',
'message': 'Hello world from Pi!'}
def callback(m):
print(m)
pubnub.publish(channel, data, callback=callback,
error=callback)
Hello World w/ PubNub
Run your program
~$ sudo python hello.py
Debug Console
http://pubnub.com
/console/
1. channel: hello-pi
2. pub key: demo
3. sub key: demo
https://github.com/pubnub/
workshop-raspberrypi/tree/master/
projects-python/led
Hello World of Hardware:
Blinking LED
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
1. Raspberry Pi 2 (w/ a WiFi Adapter for later exercise)
2. 1 Breadboard
3. 2 Male/Female jumper wires, 2 colors
4. 1 Resistor (200Ω)
5. 1 LED (1.9 - 3.2V)
What you need
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
OMG Physics!
Cathode (-) Anode (+)
- +
1.9V 3.2V
- +
OMG Physics!
R =
V - Vs f
I
source voltage (V) forward voltage (V)
(LED voltage drop)
current thru
the LED (A)
resistance (Ω)
OMG Physics!
R =
3.3v - 1.9v
0.02 A
source voltage (V)
forward voltage (V)
(Red LED voltage drop)
current thru
the LED (A)
resistance (Ω)
= 70 Ω
4-band Resistor Color Code
47 x 100 =
4.7 k Ohms
4 7 102 +/- 5%
multiplier
tolerance
Learn more at: https://learn.adafruit.com/multimeters/resistance
5-band Resistor Color Code
200 x 1 =
200 Ohms
2 0 100 +/- 1%
multiplier
tolerance
Learn more at: https://learn.adafruit.com/multimeters/resistance
0
Breadboard
400-pinMini
We are using this kind today!
You may find this
type of breadboard
when googling
circuits. They have
power rails that
goes vertical!
not connected !
An electronics breadboard is a fundamental tool to build circuits. It is solderless, and great tool for
prototyping.
conductive metal
strips goes
horizontally
Connected!
Turning LED on
3.3V
(Raspberry Pi)
LED
Turning LED on
3.3V (Pin 1)
GND
Anode (longer
leg)
Cathode
Raspberry Pi 2 Pins
3.3V
Ground
GPIO (general purpose input output)
Programming LED
GPIO-4 (Pin 7)
Programming LED
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
LED = 4
GPIO.setup(LED,GPIO.OUT)
for i in range(6):
GPIO.output(LED,True)
time.sleep(0.5)
GPIO.output(LED,False)
time.sleep(0.5)
import RPi.GPIO libs
set pin type. use BCM, not pin number
GPIO 4 pin (Pin 7)
set LED pin as output
toggle light pin signal to low/high to
make it blink.
7 times.
https://github.com/pubnub/
workshop-raspberrypi/tree/master/
projects-python/remote-led
Making it IoT:
Remote-Controlled LED
Making it IoT:
Remote-Controlled LED
publish data subscribe data
Publishing data from a web client
var pubnub = PUBNUB.init({
subscribe_key: 'demo',
publish_key: 'demo'
});
button.addEventListener('click',
function(){
pubnub.publish(
{channel: 'disco',
message: {led: 1}}
);
});
Making it IoT:
Remote-Controlled LED
When the button is
clicked on browser, it
publishes data, {‘led’: 1}
Subscribing data to Raspberry Pi
pubnub = Pubnub(publish_key='demo', subscribe_key='demo')
channel = 'disco'
def _callback(m, channel):
if m['led'] == 1:
for i in range(6):
GPIO.output(LED_PIN,True)
time.sleep(0.5)
GPIO.output(LED_PIN,False)
time.sleep(0.5)
pubnub.subscribe(channels=channel, callback=_callback, error=_error)
Making it IoT:
Remote-Controlled LED
button.addEventListener
('click', publish);
As soon as a message is
published from a browser,
the message is subscribed
to Pi
Disco!
http://pubnub.github.io/
workshop-raspberrypi/web/disco.html
Making it IoT:
Remote-Controlled LED
IoT & PubNub
Case Study: Insteon
http://www.insteon.com
Data Visualization with
Temperature Sensor
It uses a capacitive humidity sensor and a thermistor to
measure the surrounding air, and spits out a digital signal on
the data pin.
https://github.com/pubnub/workshop
-raspberrypi/tree/master/projects-pyt
hon/dht22
http://pubnub.github.io/workshop
-raspberrypi/web/temperature.ht
ml
Realtime Data Graphs & Charts
https://github.com/pubnub/eon-chart
Resources
◼ Raspberry Pi - https://www.raspberrypi.org/
◼ PubNub - https://pubnub.com
◼ Step-by-step instructions & Code sample on GitHub -
https://github.com/pubnub/workshop-raspberrypi
◼ This slide deck: https://goo.gl/NHIkJe
Thank you :-)
Tomomi Imura (@girlie_mac)
https://www.pubnub.com/blog/author/tomomi/
http://girliemac.com
Tuts+ Node.js & Arduino tutorial: http://goo.gl/LTtPn4
Creative Commons Attributions
◼ LED circuit: Wikimedia
◼ GPIO Pins: RaspberryPi-Spy.co.uk
Also, great public domain images from Pixabay, and an
open-source software, Fritzing for circuit diagrams!

More Related Content

PPTX
Python in raspberry pi
PDF
Physical computing with Python and Raspberry Pi
PDF
Picamera, Flask and the Twitter API Raspberry Pi workshop
PDF
Python on Pi - Keynote at PySS14
PDF
Python for PHP developers
PPTX
Raspberry Pi Using Python
PDF
Introduction to IPython & Notebook
PDF
A quick overview of why to use and how to set up iPython notebooks for research
Python in raspberry pi
Physical computing with Python and Raspberry Pi
Picamera, Flask and the Twitter API Raspberry Pi workshop
Python on Pi - Keynote at PySS14
Python for PHP developers
Raspberry Pi Using Python
Introduction to IPython & Notebook
A quick overview of why to use and how to set up iPython notebooks for research

What's hot (20)

PPTX
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
PDF
Raspberry Pi and Amateur Radio - 2020 update
ODP
Introduction to Raspberry Pi and GPIO
PDF
The magic of IPython Notebook
PDF
Intro to Jupyter Notebooks
PPTX
How to deliver a Python project
ODP
Raspberry Pi and Amateur Radio
PDF
Getting Started with Embedded Python: MicroPython and CircuitPython
PDF
Introduction to IPython & Jupyter Notebooks
PPTX
Pi Is For Python
PDF
Advanced view of projects raspberry pi list raspberry pi projects
PDF
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
PDF
Jupyter, A Platform for Data Science at Scale
PDF
Will iPython replace Bash?
PDF
Getting started with AGL using a Raspberry Pi
PPTX
LED Blinking Using Raspberry Pi
PPTX
Introduction to Raspberry Pi
PDF
Introduction to the rapid prototyping with python and linux for embedded systems
PDF
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
PDF
ROOT 2018: iminuit and MINUIT2 Standalone
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
Raspberry Pi and Amateur Radio - 2020 update
Introduction to Raspberry Pi and GPIO
The magic of IPython Notebook
Intro to Jupyter Notebooks
How to deliver a Python project
Raspberry Pi and Amateur Radio
Getting Started with Embedded Python: MicroPython and CircuitPython
Introduction to IPython & Jupyter Notebooks
Pi Is For Python
Advanced view of projects raspberry pi list raspberry pi projects
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
Jupyter, A Platform for Data Science at Scale
Will iPython replace Bash?
Getting started with AGL using a Raspberry Pi
LED Blinking Using Raspberry Pi
Introduction to Raspberry Pi
Introduction to the rapid prototyping with python and linux for embedded systems
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
ROOT 2018: iminuit and MINUIT2 Standalone
Ad

Similar to [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi (20)

PPTX
Raspberry Pi Introductory Lecture
PPTX
Introduction To Raspberry Pi with Simple GPIO pin Control
PPTX
Raspberry Pi - Unlocking New Ideas for Your Library
PPTX
Raspberry Pi Session - 22_11_2014
PPTX
Raspberry Pi Free Session - 20_09_2014
PPTX
Raspberry pi
PPTX
Building the Internet of Things with Raspberry Pi
PDF
Intro to the raspberry pi board
PPTX
Python-in-Embedded-systems.pptx
PDF
My presentation raspberry pi
PDF
Internet of things aktu lab file
PDF
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
PPTX
IOT notes ....,.........
PDF
RaspberryPi_Workshop and Programming with python.
PPTX
First python project
PPTX
Using arduino and raspberry pi for internet of things
PDF
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
PPTX
Building your own RC Car with Raspberry Pi
PDF
[HTML5DevConf SF] Hardware Hacking for Javascript Developers
PPTX
Build your first android things application
Raspberry Pi Introductory Lecture
Introduction To Raspberry Pi with Simple GPIO pin Control
Raspberry Pi - Unlocking New Ideas for Your Library
Raspberry Pi Session - 22_11_2014
Raspberry Pi Free Session - 20_09_2014
Raspberry pi
Building the Internet of Things with Raspberry Pi
Intro to the raspberry pi board
Python-in-Embedded-systems.pptx
My presentation raspberry pi
Internet of things aktu lab file
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
IOT notes ....,.........
RaspberryPi_Workshop and Programming with python.
First python project
Using arduino and raspberry pi for internet of things
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
Building your own RC Car with Raspberry Pi
[HTML5DevConf SF] Hardware Hacking for Javascript Developers
Build your first android things application
Ad

More from Tomomi Imura (20)

PDF
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
PDF
[POST.Dev Japan] VS Code で試みる開発体験の向上
PDF
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
PDF
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
PDF
Engineering career is not a single ladder! - Alternative pathway to develope...
PDF
Being a Tech Speaker with Global Mindset
PDF
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
PDF
Slack × Twilio - Uniquely Powering Communication
PDF
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
PDF
[2019 south bay meetup] Building more contextual message with Block Kit
PDF
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
PDF
Building a Bot with Slack Platform and IBM Watson
PDF
[日本語] Slack Bot Workshop + Intro Block Kit
PDF
[DevRelCon Tokyo 2019] Developer Experience Matters
PDF
[DevRel Summit 2018] Because we all learn things differently
PDF
[DevRelCon July 2018] Because we all learn things differently
PDF
[Japanese] Developing a bot for your workspace 翻訳ボットを作る!
PDF
Future of the Web with Conversational Interface
PDF
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
PDF
[日本語・Japanese] Creative Technical Content for Better Developer Experience
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
[POST.Dev Japan] VS Code で試みる開発体験の向上
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
Engineering career is not a single ladder! - Alternative pathway to develope...
Being a Tech Speaker with Global Mindset
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
Slack × Twilio - Uniquely Powering Communication
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
[2019 south bay meetup] Building more contextual message with Block Kit
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
Building a Bot with Slack Platform and IBM Watson
[日本語] Slack Bot Workshop + Intro Block Kit
[DevRelCon Tokyo 2019] Developer Experience Matters
[DevRel Summit 2018] Because we all learn things differently
[DevRelCon July 2018] Because we all learn things differently
[Japanese] Developing a bot for your workspace 翻訳ボットを作る!
Future of the Web with Conversational Interface
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
[日本語・Japanese] Creative Technical Content for Better Developer Experience

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
The AUB Centre for AI in Media Proposal.docx
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
Dropbox Q2 2025 Financial Results & Investor Presentation

[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi