PiIO - Remote IO

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:

  • To simplify end user configuration
  • To use more readily available hardware
  • To provide a more polished product

The entire project source is available under the GPL licence on my GitHub.


Raspberry Pi Client Features:

  • GPIO input/output
  • ADC using Microchip’s MCP3008 (SPI)
  • Equations can be used to manipulate ADC/GPIO values
  • Interface bindings are designed exclusive to the RPI client and are extensible

Web browser Client Features:

  • Websocket HTML5 Technology with Flash fallback – Works in most browsers.
  • Admin interface to configure any Raspberry Pi remotely in real-time
  • Display bindings are designed to be extensible



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.


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:

  • Numeric - Displays integer or Boolean values in plain text
  • Progress Bar - Displays integer values in a progress bar (0-100)
  • Graph - Displays integer values over time
  • Button - Toggles the state of a GPIO output port

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.

Push Configuration and Notifications

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:

  • Any Raspberry Pi comes online or goes offline
  • Configuration has been changed

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:

  • GPIO – Using Ben Croston’s Python GPIO binding
  • ADC – Using my MCP3008 SPI ADC binding

Interfaces can be added by simply extending the python classes IRead, and IWrite in the rpi_data/interface.py file.

Django Web

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.

Autobahn Websockets

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.