Control Your Pi with Webiopi

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.

Installation
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.

gertboard com legenda de conponentesBlue and white diagram

 

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
1. Temperature
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.

RPi Temperature_bb

 

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

to

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.

5 thoughts on “Control Your Pi with Webiopi

  1. HI,

    I get an error, No such file or directory: ‘/sys/bus/w1/devices/w1_bus_master1/w1_master_slaves’

    Could you maybe shed some light on why this might be?

    Raspian Wheezy, if you need any more details let me know

    Thanks 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s