Date: 06/02/2013
This project enables you to remotely control your Raspberry Pi’s GPIO interface from a web browser using html5 websocket technology.
I set out to build this project with several goals after the feedback I’ve received from my embedded websockets project.
These goals included:
The entire project source is available under the GPL licence on my GitHub.
Raspberry Pi Client Features:
Web browser Client Features:
A server is required for PiIO. The server software wasn’t designed to run on the RPI. A centralised server provides control over multiple Raspberry Pis at once.
I'm not the best at these but I put something together anyways.
Skip to these notable points in the video:
A display is a user interface display which can be bound to a RPI interface. These displays can be named.
PiIO comes with the following displays:
You can see one of each of these in the following screenshot:
The admin interface allows the user to remotely configure which displays they would like to use and which hardware interfaces they are bound to. The hardware interface configuration is pushed to the remote RPI where the RPI is configured to stream or receive data for the selected interfaces.
The available interfaces are gathered from the remote RPI. If you were to add another interface to the RPI client code (example could be an I2C ADC) it would get pushed to the server where you could bind the interface to a display.
The user can enter equations to alter the value of any interface. These equations are evaluated Python code that runs server side.
In the above screenshot I’ve got the ProgressBar display bound to ADC CH0 with the equation “(float(x) / 1023) * 100)”. This equation converts the 10bit ADC value into a value from 0-100.
A similar equation is there for the Graph display to convert the values from 0-5 to represent voltage.
If a user changes a RPIs configuration in the Admin interface all users viewing that Raspberry Pi will get their views updated to reflect the new configurations without the need for a refresh.
The user gets notified when:
The RPI communicates to the same websocket server as the end-user using a Python AutoBahn Client.
When a new RPI is connected using the client software it registers itself and will appear in the Django Admin along with any interfaces it supports.
If a RPI has been configured on the Admin interface it will stream and accept data to/from the server when a user is present.
The RPI currently supports the following interfaces:
Interfaces can be added by simply extending the python classes IRead, and IWrite in the rpi_data/interface.py file.
The Websites built using the Django framework in python with the Twitter Bootstrap CSS framework. The website communicates to and from the websocket server using HTTP requests.
If you wish to add custom displays you would have to modify the webserver, instructions may be provided at a later date. (I tried to design it to be easy.)
You can deploy the site by following standard django tutorials.
The websocket server handles all the data streaming. The server is written in Python using Autobahn which is an extension for Twisted.
Deployment instructions may be provided at a later date.
The code is available on my GitHub under the GPL licence.