Webiopi is a fantastic framework for controlling your RPi over the web. I found it a steep learning curve, but once you’ve got head around a few ideas it provides a very powerful way of bringing your RPi to life.
I am primarily using it to gather data from sensors on my RPi and graph the output on a web page. I thought I’d publish what I’d done so that others can use the things I’ve found out.
Follow the guide on the Webiopi website to setup your RPi. If all goes well you should be able to start up the server and access your RPi on your local network via a browser. More importantly, you can now control the GPIO interface from a browser. I have my RPi connected to a Gertboard so that I can safely access all the GPIO header pins plus all of the other stuff that comes with the Gertboard. For those unfamiliar with this extension board here’s a couple of pictures showing all of the functionality that it offers.
The left-hand diagram shows the main functionality of the board while the right-hand schematic is more useful in showing how to wire it up.
Connecting up Sensors
I bought a couple of DS18B20 temperature sensors from ebay to monitor the temperature in my house (why? – just because I can!!!). Setting up the sensor is very straightforward, it uses a one-wire interface so only requires three connections: VCC, GND, and DATA (in fact it can be used with only two connections but there may be stability issues on the RPi). The one-wire interface on the RPi is accessed through GPIO 4 so this must be connected to Pin 2 of the DS18B20 as shown below. Note a VAL pull-up resistor is also required between the Data line and 3V3.
On the RPi side a couple of things need to be done to configure the sensor.
sudo modprobe w1-gpio sudo modprobe w1-therm
That’s it for the initial configuration, the sensor should now be pushing data to the RPi. Now it’s time to configure webiopi to communicate with the sensor.
You need to add the sensor to webiopi’s config file. Open up an editor,
sudo nano /etc/webiopi/config
Change the line
#temp2 = DS18B20
temp2 = DS18B20
Restart webiopi with the command
sudo /etc/init.d/webiopi restart
This configures the sensor in the REST API and it should be accessible from the webiopi page being hosted by your pi. Head over to the /app/devices-monitor page and you should see the temperature being displayed.