trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

WebIOPi : control your Pi’s GPIO with a browser

Tue Aug 21, 2012 7:35 pm

It's time to share my first Pi project using GPIOs :

WebIOPi is a web application which allows you to control your Raspberry Pi’s GPIO. Just install it on your Pi, and use any browser from your network.
It’s useful to start enjoying GPIOs and also to debug some circuits without writing any line of code.
It also allows to control your Pi’s GPIOs over Internet, so it’s a good starting point for home remote control.
You can even fully customize the included UI with few CSS modifications or use the REST API to build your own WebApp?.

Under Apache License, full doc, code, packages and examples are available on the Google Code project page.
Blog entry : http://trouch.com/2012/08/21/webiopi-co ... a-browser/

Image

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

waltermixxx
Posts: 34
Joined: Wed May 09, 2012 7:21 pm
Location: Woodbridge, Ontario

Re: WebIOPi : control your Pi’s GPIO with a browser

Wed Aug 22, 2012 3:25 am

Wow this is great... :)
This should be on front page of www.raspberrypi.org very very cool :)

Just waiting on my ribbon cable and other goodies from Adafruit.com and will try it out.

thanks for posting. :)
Electronics for fun...
Raspberry Pi-1 Occidentalist, Tenda 311m x 2
Raspberry Pi-2 Raspbian Wheezy 07-15-12, Netgear N150 x1
Genius 8000 slimline wireless keyboard and mouse both work great with the usb wifi dongle right in the raspberry pi.

NewPi
Posts: 66
Joined: Sat Aug 18, 2012 2:52 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Thu Aug 23, 2012 8:47 am

Definitely a worth "frontpage promotional" utility.
Raspberry Pi Howto, Tips, Tricks and Tools -> http://bit.ly/RPiTricks

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Thu Aug 23, 2012 9:45 am

Hope Liz will see that ;)

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

GarethD
Posts: 21
Joined: Wed Aug 15, 2012 8:58 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Aug 24, 2012 1:30 am

Hi, This looks brilliant, so I am having a go. I have followed the instructions for the
Python install and everything seemed to install ok.
But when I fired up the browser I get 404 page not found.
Tried from a computer on the lan and a localhost and both come up with the same result.

I suspect it is something I have done or not done but some help would be very useful.
I am a noob to all this so be gentle....

Below is the error I get:-

[email protected] ~/webiopi $ sudo python webiopi.py 8080
Fri Aug 24 02:13:33 2012 WebIOPi Started at 0.0.0.0:8080
192.168.0.3 - - [24/Aug/2012 02:15:49] "GET / HTTP/1.1" 404 -
localhost - - [24/Aug/2012 02:17:59] "GET / HTTP/1.1" 404 -

Regards
Gareth

NewPi
Posts: 66
Joined: Sat Aug 18, 2012 2:52 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Aug 24, 2012 2:49 am

Raspberry Pi Howto, Tips, Tricks and Tools -> http://bit.ly/RPiTricks

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Aug 24, 2012 6:40 am

GarethD wrote:Hi, This looks brilliant, so I am having a go. I have followed the instructions for the
Python install and everything seemed to install ok.
But when I fired up the browser I get 404 page not found.
Tried from a computer on the lan and a localhost and both come up with the same result.
append /webiopi/ to the URL !
http://localhost:8080/webiopi/

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

GarethD
Posts: 21
Joined: Wed Aug 15, 2012 8:58 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Aug 24, 2012 10:27 am

trouch wrote:
GarethD wrote:Hi, This looks brilliant, so I am having a go. I have followed the instructions for the
Python install and everything seemed to install ok.
But when I fired up the browser I get 404 page not found.
Tried from a computer on the lan and a localhost and both come up with the same result.
append /webiopi/ to the URL !
http://localhost:8080/webiopi/
Thanks for the info, I got it working great. :)

If I use Internet Explorer I get the the web page but if I change a port from in to out it goes straight
back to an input...

All works fine in Chrome & Firefox browsers though.

This makes testing the gpio ports very easy. So I will be using this a lot.

Excellent project, many thanks

Gareth

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Aug 24, 2012 11:35 am

Didn't check with IE, thanks for the repport !

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Mon Aug 27, 2012 7:32 pm

WebIOPi 0.3 has been released with many internal improvements.
http://trouch.com/2012/08/27/webiopi-0-3-release/

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

ingramator
Posts: 4
Joined: Sat May 19, 2012 1:31 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Thu Aug 30, 2012 9:05 am

trouch wrote:WebIOPi 0.3 has been released with many internal improvements.
http://trouch.com/2012/08/27/webiopi-0-3-release/
Awesome job with the update mate!

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Thu Aug 30, 2012 11:55 am

Nice work!
note: I may or may not know what I'm talking about...

Ant232
Posts: 115
Joined: Thu Jul 12, 2012 9:34 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Mon Sep 03, 2012 10:20 pm

This is exactly what I have been looking for. Thank you.

Can I ask a quick question?
I am trying to get web control for my heating system. So far all is going well thanks to webiopi. I've built a little optocoupler board and hacked into the heating timer. Can turn the heating and water heat on using the web interface. Hopefully tomorrow I will get tallies coming back from the timer to show if the heating is currently on or not. The one small problem I can't figure out is...
The heating timer buttons need a momentary switch to turn on and off again. So at the moment I have to replicate that by pressing the GPIO button twice for on and twice for off. Is there any way to make the buttons momentary?
I'm not a programmer and am really over my head here. I would imagine that it would be difficult to set some gpios to momentary so could all of them be changed? I had a good nose around the files and thought that maybe a time to sleep function could be added to the python script. I tried a couple of times in different places but I really am shooting I the dark. Even a hint would help and I could do a bit more digging myself.

Thanks again
Ant

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Tue Sep 04, 2012 12:17 pm

Ant232 wrote:Is there any way to make the buttons momentary?
I've spotted this issue but didn't care about it.
As you request it, I will add this feature quickly in the core.
Server side (python script) don't need any change. Just change the client side to handle both mouse button down and up with Javascript.

Copy app/skeleton directory to app/heater then edit app/heater/index.html and add the following lines where you find some comments ("place your code here") :

Code: Select all

// create RPiHeader Table and append it to content div
webiopi().RPiHeader().createTable("content");

webiopi().setDirection(7, "out"); // set GPIO 7 as output

$("#gpio7").unbind("click"); // unbind existing click handler

// mousse down (button press) send "1"
$("#gpio7").bind("mousedown", function(event) {
	webiopi().setValue(7, 1);
});

// mouse up (button release) send "0"
$("#gpio7").bind("mouseup", function(event) {
	webiopi().setValue(7, 0);
});
I can't test it until next week as I'm not at home and my Pi is unplugged, but it should work. You will have a raising edge when pressing GPIO 7 (RPi pin 26), and a falling edge when releasing it. Invert 0 and 1 in the two webiopi().setValue(7, x) calls to invert the behavior.

Take a look at http://code.google.com/p/webiopi/wiki/CUSTOMIZE and in the app folder to find more customization examples.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

Ant232
Posts: 115
Joined: Thu Jul 12, 2012 9:34 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Wed Sep 05, 2012 11:21 pm

Thanks for the reply Trouch. And thanks so much for your modification of the code. I will be back at my pi tomorrow so will give it a go. It will be a great way to learn how all the code fits together. Thanks again.

Ant

kenco coffee bean
Posts: 20
Joined: Tue Sep 04, 2012 2:53 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Thu Sep 06, 2012 8:17 am

wow amazing, cant wait to get my r-pi now - being delivered by 1 pm today - special delivery! definitely going to get this installed!!! thanks for the hard work!!!

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Sep 07, 2012 9:56 am

I have a problem.

I used http://code.google.com/p/webiopi/wiki/I ... PHP/Apache as the install guide
The "out" does not stay, it reverts back to "in" when pressed. Also the colour/mode does not change when switching below high and low.

I noticed one thing in the installation though: (see below)... There was some conflicts in the software. I accepted the solution (Just for your information) How can this be resolved?

On the second image, This is what happens when:

Code: Select all

apt-get apache2-mpm-worker
... is typed.

A quick responce would be nice thank you.

Sounds like a nice peice of software.
Attachments
Capture_apache2(2).PNG
Picture 2
Capture_apache2(2).PNG (12.93 KiB) Viewed 74338 times
Capture_apache2.PNG
Picture 1
Capture_apache2.PNG (21.3 KiB) Viewed 74338 times

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Sep 07, 2012 10:30 am

It's sound like a package conflit with your existing install.
Try the standalone python server, as it don't need anything else exept a lib.

Give more details on your setup, so I'll do some test next week.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: WebIOPi : control your Pi’s GPIO with a browser

Fri Sep 07, 2012 12:35 pm

Set-up is standard Raspbian image (latest) with ethernet and the GPIO-RPi.0.3.1a Library. I have delete some stuff that would not effect the install of this software.

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Sun Sep 09, 2012 1:17 pm

Ant232 wrote:Thanks for the reply Trouch. And thanks so much for your modification of the code. I will be back at my pi tomorrow so will give it a go. It will be a great way to learn how all the code fits together. Thanks again.

Ant
I've just tested the code I gave you.
You also have to update the style.css in your app/heater sub folder to display the button.
It then work but it's not great. You have to hold the mouse button until it changes color before release it.
I have roadmaped the feature in the core. So just wait for next version.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Sun Sep 09, 2012 1:20 pm

wallarug wrote:Set-up is standard Raspbian image (latest) with ethernet and the GPIO-RPi.0.3.1a Library. I have delete some stuff that would not effect the install of this software.
So forgive PHP and Apache, and just use the standalone python script.
http://code.google.com/p/webiopi/wiki/INSTALL#PYTHON

Code: Select all

$ sudo python webiopi.py [port]
or
$ sudo ./webiopi.py [port]
then open your browser to http://raspIP:port/webiopi/

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

Re: WebIOPi : control your Pi’s GPIO with a browser

Sun Sep 09, 2012 9:52 pm

I'm getting an errror when I try to start Apache:

"Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(98) Address already in use: make_sock:could not bind to address 0.0.0.0:80 no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.


I previously installed lighttpd and PHP. Do I have to uninstall those before I perform this install?

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Sun Sep 09, 2012 10:11 pm

charleslinquist wrote:I'm getting an errror when I try to start Apache
[...]
I previously installed lighttpd and PHP. Do I have to uninstall those before I perform this install?
If you already have ligttpd, you don't need Apache !
If you still want to use Apache with lighttpd installed, you need to change ones port or stop lighttpd before starting Apache because they both use the port 80 by default.
See http://code.google.com/p/webiopi/wiki/I ... P/lighttpd if you want to use lighttpd.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: WebIOPi : control your Pi’s GPIO with a browser

Mon Sep 10, 2012 11:34 am

trouch wrote:
wallarug wrote:Set-up is standard Raspbian image (latest) with ethernet and the GPIO-RPi.0.3.1a Library. I have delete some stuff that would not effect the install of this software.
So forgive PHP and Apache, and just use the standalone python script.
http://code.google.com/p/webiopi/wiki/INSTALL#PYTHON

Code: Select all

$ sudo python webiopi.py [port]
or
$ sudo ./webiopi.py [port]
then open your browser to http://raspIP:port/webiopi/
What if I don't want to run the script every time and just want to run the webserver automatically at start-up?

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi : control your Pi’s GPIO with a browser

Mon Sep 10, 2012 2:25 pm

wallarug wrote:What if I don't want to run the script every time and just want to run the webserver automatically at start-up?
Continue reading the INSTALL instructions....
http://code.google.com/p/webiopi/wiki/INSTALL#PYTHON
You can also run it or install it as a daemon, using the provided webiopi.init.sample file :

Code: Select all

$ sudo cp webiopi.py.init /etc/init.d/webiopi
Then change WEBIOPI_HOME and WEBIOPI_PORT variables according to the path you installed it, and to the port you want to use :

Code: Select all

$ sudo nano /etc/init.d/webiopi
And changes variables next to the Author line.

WEBIOPI_HOME=/var/www/webiopi
WEBIOPI_PORT=80
You can now start/stop the Python version of WebIOPi as a service :

Code: Select all

$ sudo /etc/init.d/webiopi start
and
$ sudo /etc/init.d/webiopi stop
You can even start WebIOPi at boot :

$ sudo update-rc.d webiopi defaults

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

Return to “Interfacing (DSI, CSI, I2C, etc.)”