In the evening, with the day’s work over, your office is locked and you are about to leave for home. Suddenly, you notice that some of the lights in your office are still on, which you can see from the factory gate. You open the browser in your laptop, do authentication, give a command, and all the lights in your office are switched off. You return home peacefully.

Fig. 1: Extracting the tarball file
Fig. 1: Extracting the tarball file
Fig. 2: Installation of WebIOPi
Fig. 2: Installation of WebIOPi
Fig. 3: Startig WebIOPi
Fig. 3: Startig WebIOPi
Fig. 4: Starting WebIOPi at reboot
Fig. 4: Starting WebIOPi at reboot
Fig. 5: Login to WebIOPi
Fig. 5: Login to WebIOPi
Fig. 6: WebIOPi main menu
Fig. 6: WebIOPi main menu

Take another case. You have gone somewhere and realise that you will not be returning to your office for quite some time. So you go to a nearby computer, open the browser, check the temperature in your office, press some keys on the computer and the AC in your office gets switched off. You can do all this with the help of Raspberry Pi, using WebIOPi software.

WebIOPi
WebIOPi is browser-based software through which the above-mentioned tasks can be done easily yet economically. The latest WebIOPi version 0.0.6 is available at:

//code.google.com/p/webiopi/downloads/detail?name=WebIOPi-0.6.0.tar.gz&can=2&q=
Download it with ‘wget’ command or directly from the browser. Extract the tarball file in a directory using the command (also refer Fig. 1):

 

$ tar zxvf WebIOPi-0.6.0.tar.gz

Now use ‘cd’ command to go to the extracted directory and run the following command (also refer Fig. 2):

 

$ sudo ./setup.sh

WebIOPi will be installed in your Raspberry Pi. To start WebIOPi, run the following command (also refer Fig. 3):

 

$ sudo /etc/init.d/webiopi start

This will not make WebIOPi start automatically at every boot. To start it automatically at the boot itself, give the command (also refer Fig. 4):

 

$ sudo update-rc.d webiopi defaults

Accessing Raspberry Pi’s GPIOs
The WebIOPi is essentially an Apache webserver framework with facilities of Raspberry Pi GPIOs. If you already have Apache installed in your Raspberry Pi, just go ahead and WebIOPi will manage itself accordingly. If you do not have Apache, you can install it with the command:

 

$ sudo apt-get install apache2

Once WebIOPi is installed, go to the browser window of your computer and open the link:

 

http://your-raspi-
ip-address:8000/
webiopi

It will ask for a login and password, which you can change later. But for the time being type webiopi and raspberry as login and password, respectively, as shown in Fig. 5.

You will see the WebIOPi main menu, as shown in Fig. 6.

Fig. 7:­ GPIO header pins
Fig. 7:­ GPIO header pins

Click on the GPIO Header link and you will see the GPIO header pins along with the pin functions, as shown in Fig. 7. The ‘IN’ means the corresponding pin can be used as input. Double click on ‘IN’ box; the caption will change to ‘OUT.’ Now, the pin can be used as output pin.

Controlling devices
Make all the eight pins as OUT, then connect a few LEDs on the corresponding pins on the Raspberry Pi board. Click on each pin, say pin 13 (GPIO 27) to begin with, on the browser screen; it will change from black to orange and the corresponding LED will glow.

Connect all the GPIO pins to the inputs of a Darlington IC ULN2003 and you will be able to control relays connected to the outputs of the IC. The relays, in turn, will be able to switch ACs, fans, lights, curtains, etc on and off. As long as you can access this page with LAN or any other wireless network, you will be able to control the GPIO pins and the devices attached to them.

Similarly, click on ‘OUT’ and it will change to ‘IN’ button, indicating that the port has changed from an output port to an input port.

Interface temperature sensor
DS18B20 digital temperature sensor can sense temperature from -10 to 85 degree celsious. The sensor looks like a small transistor with its three legs, as shown in Fig. 8.

Fig. 8: Pin diagram of DS18B20
Fig. 8: Pin diagram of DS18B20
Fig. 9: Loading the DS18B20 module
Fig. 9: Loading the DS18B20 module
Fig. 10: Finding the ID of temperature sensor
Fig. 10: Finding the ID of temperature sensor
Fig. 11: WebIOPi config file
Fig. 11: WebIOPi config file
Fig. 12: Temperature display
Fig. 12: Temperature display

Fig. 8 also shows how to connect the GPIO of Raspberry Pi to temperature sensor DS18B20. Pin 1 (ground) of DS18B20 is connected to pin 6 (ground) of Raspberry Pi. Pin 2 (data) of DS18B20 is connected to pin 7 (GPIO4) of Raspberry Pi. GPIO4 is the only pin of Raspberry Pi which is used as general-purpose clock; any other GPIO pin will not work here. Pin 3 of DS18B20, which is for 3.3-volt supply, will go to pin 1 of Raspberry Pi, which has on-board 3.3-volt supply.

Ensure that a small resistor (4.7k to 10k) is connected between data pin and power pin, as shown in Fig. 8, to pull up data out signal for better correction. Switch on your Raspberry Pi and touch the sensor with a finger to see that it is not getting heated up excessively due to some wrong connection.

After login, load the DS18B20 module, and the temperature data can be viewed by using command (also refer Fig. 9):

 

$ sudo modprobe w1-gpio
$ sudo modprobe w1-therm

Write the command given below (also refer Fig. 10); you will find the ID number of the DS18B20 sensor as 28-000004ee2c8a:

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here