Raspberry Pi RESTful tutorial

Overview

In order to have dizmo communicate with the physical outside world, you will need to learn how to install WebIOPi on the Raspberry Pi and use it with the RESTful dizmo.

What you need

  • Raspberry Pi with NOOBS installed http://www.raspberrypi.org/wp-content/uploads/2012/04/quick-start-guide-v2_1.pdf
  • SSH needs to be enabled on the Raspberry Pi

Hardware

  • Led (any color), 270 Ohm Resistor
  • Breadboard, Jumper Cables

Installation

Connect your Raspberry to your network (ideally via the onboard network socket, optionally via a wifi usb dongle) and take note of its ip-adress.

Connect to your Raspberry via ssh, then issue the following commands to download and install webiopi:

$ wget http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz -O WebIOPi-0.7.1.tar.gz
$ tar xvzf WebIOPi-0.7.1.tar.gz
$ rm WebIOPi-0.7.1.tar.gz
$ cd WebIOPi-0.7.1
$ sudo ./setup.sh

Run

Possible Commands

sudo /etc/init.d/webiopi start (to start webiopi)
sudo /etc/init.d/webiopi stop (to stop webiopi)
sudo /etc/init.d/webiopi status (to check the status of webiopi) 

Make sure that you have started webiopi using the above commands

open Tiny Browser and enter the ip-adress of the raspberry pi open port 8000.
Default user is “webiopi” and password is “raspberry”
WebIOPi firstStart in Tiny Browser
You can click on GPIO Header to get a overview over all your GPIO Pins and the state.

WebIOPi firstStart Tiny Browser GPIO Pins

Auto Run (at boot)

$ sudo update-rc.d webiopi defaults (to run webiopi at boot)
$ sudo update-rc.d webiopi remove (to no longer run webiopi at boot) 

RESTful interface

Start RESTful dizmo go to settings insert

http://192.168.1.44:8000/GPIO/17/value/1

into URL (change ip for).
WebIOPi RESTful POST

Press [SET URL] and [DONE]

WebIOPi RESTful POST sent
On the content side you can use [POST] to execute your POST code.

Reference WebIOPi RESTAPI https://code.google.com/p/webiopi/wiki/RESTAPI

To turn the LED off you can change the POST URL to

http://192.168.1.44:8000/GPIO/17/value/0

or open a second RESTful dizmo to use it as turn off interface.