Skip to content
Realtime Streaming with the Raspberry Pi and Python Library
Branch: master
Clone or download
Latest commit a32280e Nov 19, 2014
Type Name Latest commit message Commit time
Failed to load latest commit information.
readme_images readme images Mar 11, 2014
.gitignore first Mar 10, 2014 first Mar 10, 2014

Raspberry Pi Realtime Streaming with


This is an example of a streaming graph:

Here is an example of how to hook up a TMP36 Temperature Sensor to your Pi!

This is a tutorial on streaming with the Raspberry Pi

First, install the required modules and dependencies:

sudo apt-get install python-dev
wget -O - | sudo python
sudo easy_install -U distribute
sudo apt-get install python-pip
sudo pip install rpi.gpio
sudo pip install plotly

Create your sensor reading script, and start importing some modules in it!

import plotly.plotly as py # plotly library
from plotly.graph_objs import Scatter, Layout, Figure # plotly graph objects
import time # timer functions
import readadc # helper functions to read ADC from the Raspberry Pi

Make sure to update the credentials in the script with your own!

username = 'your_plotly_username'
api_key = 'your_api_key'
stream_token = 'your_stream_token'

If you don't know your credentials :

Sign up to plotly here: View your API key and streaming tokens here:

Initialize a Plotly Object

py.sign_in(username, api_key)

Initialize your graph (not streaming yet)

trace1 = Scatter(

layout = Layout(
    title='Raspberry Pi Streaming Sensor Data'

fig = Figure(data=[trace1], layout=layout)

print py.plot(fig, filename='Raspberry Pi Streaming Example Values')

Specify the connected channel for your sensor

sensor_pin = 0

Initialize the GPIO


Initialize the Plotly Streaming Object

stream = py.Stream(stream_token)

Start looping and streamin'!

while True:
	sensor_data = readadc.readadc(sensor_pin, readadc.PINS.SPICLK, readadc.PINS.SPIMOSI, readadc.PINS.SPIMISO, readadc.PINS.SPICS)
	stream.write({'x':, 'y': sensor_data})
	time.sleep(0.1) # delay between stream posts

Your graph will be visible in your plotly account ( and at your_graph_url, the value assigned by the py.plot call above.


Questions? Suggestions? Something not look right? Get in touch!

You can’t perform that action at this time.