HeavensBlade
Posts: 26
Joined: Fri Aug 03, 2012 10:45 am

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

Sun Nov 18, 2012 4:05 pm

I just tried to open the WebIOPi page on my iPad, but after i get prompted to login the page doesnt load and the browser says the server has timed out. The server is running stable, because i get access from my android phone and pc.
Does anyone know where the Problem is?
It worked, in v. 0.3, it was a bit laggy but it worked.

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 Nov 18, 2012 5:07 pm

I tried with an iPhone but not an iPad...
Can you turn on Javascript console in developer settings ?

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

HeavensBlade
Posts: 26
Joined: Fri Aug 03, 2012 10:45 am

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

Sun Nov 18, 2012 5:53 pm

Hmm, I don't know where the problem was, but without changing or even restarting anything now it works. Maybe I typed the wrong URL or something, I'm sorry my bad.

There is another point. I have two Pi's running. One rev1 and the other is rev2. On the rev1 everything is fine, and the pin layout is as it was in webiopi 0.3. But on the rev2 there is no GPIO 21 instead there is GPIO 27. Is this a software issue or a change on the PCB? If it is the way it should be can you tell me how to change the software for the rev1 to make it 27 or the other way to make the rev2 pin GPIO 21? Because this is really confusing when trying the same script and html on both systems.

Last but not least:
I made a button that changes the state of 2 pins:

Code: Select all

				
			// you can also create a button which calls a different function for mouse down and up events
			button = webiopi().createButton("hold", "Audio: iPad", mousedown_ipad);
			content.append(button);
		});
	function mousedown_ipad() {
		webiopi().setValue(17, 0); webiopi().setValue(4, 0);
	}
Is it possible to make the button light up if the pins are in this specific state?

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 Nov 18, 2012 6:41 pm

HeavensBlade wrote:There is another point. I have two Pi's running. One rev1 and the other is rev2. On the rev1 everything is fine, and the pin layout is as it was in webiopi 0.3. But on the rev2 there is no GPIO 21 instead there is GPIO 27. Is this a software issue or a change on the PCB? If it is the way it should be can you tell me how to change the software for the rev1 to make it 27 or the other way to make the rev2 pin GPIO 21? Because this is really confusing when trying the same script and html on both systems.

Last but not least:
I made a button that changes the state of 2 pins:

Code: Select all

				
			// you can also create a button which calls a different function for mouse down and up events
			button = webiopi().createButton("hold", "Audio: iPad", mousedown_ipad);
			content.append(button);
		});
	function mousedown_ipad() {
		webiopi().setValue(17, 0); webiopi().setValue(4, 0);
	}
Is it possible to make the button light up if the pins are in this specific state?
Yes, pin mapping has changed with the REV2 boards.
That's it, GPIO 0/1/21 has been replaced by 2/3/27 on the header.

To light up buttons, you can use some CSS styling and set class from the javaxcript :

CSS:

Code: Select all

#gpio17.OFF {
	background-color: White;
}
		
#gpio17.ON {
	background-color: Red;
}
JS :

Code: Select all

$("#gpio17").attr("class", "OFF");
or 
$("#gpio17").attr("class", "ON");
you can use a callback in setValue function

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

Andy60
Posts: 4
Joined: Tue Oct 09, 2012 10:44 am
Location: Stuttgart, DE

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

Wed Nov 21, 2012 9:10 am

Again thanx for the great job on 0.5.1. I have developed an Android native app using your REST API and its working quite well. Still working on it to integrate the changes from 0.3 to 0.5 .....

Some small findings and questions:

When handling HTTP POST in webiopi.py there are checks for being an GPIO output when setting values (e.g. on line 275 and 276) or driving sequences. This check is missing when handling POST for pulse, pulseangle and pulseratio. Should this be added for costistency?

On the wiki page explaining the python server library usage is a small typo:

# Example loop which toggle GPIO 9 each 5 seconds
try:
while True:
GPIO.output(7, not GPIO.input(7))
time.sleep(5)

It should say that GPIO 7 is toggled instead of GPIO 9.

Its a very good idea to have some increased security and adding a base authentication for HTTP. However, using base64 encoding together with plain HTTP is not really helpful in the world wide "wild" as the authentication header will be transfered unencrypted over the socket. A better solution would be doing HTTPS via SSL (openssl), maybe this is a future enhancement requirement.

Sometimes it may be required to control some of the GPIO pins for simple purposes (like driving status LEDs) from within a unix shell script and some other ones using your server library and controlling them via HTTP. Do you think this will interfere in some way or not (assuming that the shell-controlled GPIOs are never touched via webiopi)?

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

Wed Nov 21, 2012 10:30 am

Andy60 wrote: When handling HTTP POST in webiopi.py there are checks for being an GPIO output when setting values (e.g. on line 275 and 276) or driving sequences. This check is missing when handling POST for pulse, pulseangle and pulseratio. Should this be added for costistency?
Actually, the check done in webiopi.py for POST */value/* is useless and has to be removed as there is already some check in the native C code which is under webiopi.GPIO
The check is also present in the native code for pulse*, sequence. Check native/bridge.c if you want ;)

Andy60 wrote: On the wiki page explaining the python server library usage is a small typo:
# Example loop which toggle GPIO 9 each 5 seconds
It should say that GPIO 7 is toggled instead of GPIO 9.
Yes, i noticed that and it's already corrected in demo.py on my side, but I have to correct the wiki too.
Andy60 wrote: Its a very good idea to have some increased security and adding a base authentication for HTTP. However, using base64 encoding together with plain HTTP is not really helpful in the world wide "wild" as the authentication header will be transfered unencrypted over the socket. A better solution would be doing HTTPS via SSL (openssl), maybe this is a future enhancement requirement.
I know :(
But using SSL add other issues (with the certificate for instance) I don't want to care now.

Andy60 wrote: Sometimes it may be required to control some of the GPIO pins for simple purposes (like driving status LEDs) from within a unix shell script and some other ones using your server library and controlling them via HTTP. Do you think this will interfere in some way or not (assuming that the shell-controlled GPIOs are never touched via webiopi)?
WebIOPi uses SOC registers through /dev/mem, so changes made with the shell will be seen by WebIOPi. The opposite no.
Andy60 wrote: I have developed an Android native app using your REST API and its working quite well.
I have something better for my iPhone and working for the same app on Android.
I guess your app requires you install webiopi on the Pi ? Mine's not ;)
I also guess your app requires you add the IP or DNS of your Pi ? Mine's not ;)

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

Andy60
Posts: 4
Joined: Tue Oct 09, 2012 10:44 am
Location: Stuttgart, DE

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

Wed Nov 21, 2012 4:20 pm

trouch wrote:Actually, the check done in webiopi.py for POST */value/* is useless and has to be removed as there is already some check in the native C code which is under webiopi.GPIO
The check is also present in the native code for pulse*, sequence. Check native/bridge.c if you want ;)
I have seen the checks in bridge.c, you are right, they are somewhat redundant to the ones in the python module. On the other hand, POST /value/ will feed back some HTTP 40* error messages in those cases. Whereas the checks in bridge.c may end up in some log or console message but will not show up as HTTP error messages to the "end" user on HTTP level which may be of help in some way. Maybe there is a way to have the checks only in the native C code part but propagate the error cases up to the python module to provide the 40* responses still there.
trouch wrote: I know :(
But using SSL add other issues (with the certificate for instance) I don't want to care now.
OK, self signed certs are not really fun for everyone ;)
trouch wrote: WebIOPi uses SOC registers through /dev/mem, so changes made with the shell will be seen by WebIOPi. The opposite no.
Perfect for me 8-)
trouch wrote: I have something better for my iPhone and working for the same app on Android.
I guess your app requires you install webiopi on the Pi ? Mine's not ;)
I also guess your app requires you add the IP or DNS of your Pi ? Mine's not ;)
Absolutely right, of course I need Webiopi installed on the Pi (which is ok if I intend to use it anyway on my Pi) and have to configure ip and port to make the HTTP Rest API calls from Android/Java. Well if you have something better ... I'm quite curious what that would be .... 8-)

I assume you need at least some small piece of code on the Pi that lets you control the native C code in some way directly via some kind of TCP/IP socket.

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

Wed Nov 21, 2012 6:24 pm

Good point on error propagation from native code to HTTP !
Andy60 wrote:Absolutely right, of course I need Webiopi installed on the Pi (which is ok if I intend to use it anyway on my Pi) and have to configure ip and port to make the HTTP Rest API calls from Android/Java. Well if you have something better ... I'm quite curious what that would be .... 8-)
It still relies on WebIOPi REST API, but it installs it by itself on the Pi ;)
It's mostly interesting as I plan to release some official WebIOPi apps on both iOS and Android : it will helps novice users.

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

malonecc
Posts: 9
Joined: Sat Sep 29, 2012 8:15 pm

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

Thu Nov 22, 2012 1:05 pm

Sorry, I'm totally newby on JavaScript.

How can I read state of one gpio in my javascript code?

I'm trying:

function callMacro6() {
if (gpio18.status){
alert("My rele is ON.");
}
else{
alert("My rele is OFF.");
};

Thanks in advance.

malonecc
Posts: 9
Joined: Sat Sep 29, 2012 8:15 pm

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

Thu Nov 22, 2012 1:47 pm

Well I find a work around with:

if (w().GPIO[18].value == 1){

...
...
...

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 Nov 22, 2012 9:27 pm

:roll: I think I have to add some getters in the JS lib ;)

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

padge
Posts: 2
Joined: Fri Nov 23, 2012 2:31 pm

Re: WebIOPi : Startup default states?

Fri Nov 23, 2012 2:51 pm

Is it possible to specify the startup states of the gpio pins (in/out, hi/low) so that webiopi sets them when it starts? Im running on a headless pi and would like it to come up in a specific state if the power bounces.

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

Re: WebIOPi : Startup default states?

Fri Nov 23, 2012 3:40 pm

padge wrote:Is it possible to specify the startup states of the gpio pins (in/out, hi/low) so that webiopi sets them when it starts? Im running on a headless pi and would like it to come up in a specific state if the power bounces.
yes if you write your own script, check http://code.google.com/p/webiopi/wiki/PYTHON

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
oldcyberdude
Posts: 9
Joined: Fri Nov 02, 2012 4:35 pm
Location: Aiken, SC

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

Sun Nov 25, 2012 4:18 pm

trouch;
Where did the that great demo page (controlling all the GPIO pins) go. I upgraded to 0.5.1 and I really miss that great page to test out my protoboard and demo webiopi to friends.

I do like the id/password but now I only get a 404 I really need that demo page. Not really thrilled with the 0.5.1 demo

Thanks for all your work.

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 Nov 25, 2012 4:25 pm

it depends on how and where you launch webiopi

in the package, you have a demo folder, go in it then :
sudo python demo.py

now open a browser to
http://raspberrypi:8000/demo.html

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
oldcyberdude
Posts: 9
Joined: Fri Nov 02, 2012 4:35 pm
Location: Aiken, SC

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

Sun Nov 25, 2012 5:09 pm

This is your new demo.... I'm looking for that neat demo page you used as index.html in 0.3 version. It worked like a charm to control the GPIO pins. Now everything seems broken with 0.5 upgrade. I hate to be a pain but I've taken a step backwards with the upgrade.

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 Nov 25, 2012 5:22 pm

if you want the RPi header app, you just have to open a browser to
http://raspberry:8000/webiopi/ or http://raspberry:8000/ as usual
the old "example app" has been replaced by demo.html

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
oldcyberdude
Posts: 9
Joined: Fri Nov 02, 2012 4:35 pm
Location: Aiken, SC

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

Sun Nov 25, 2012 5:40 pm

I'm sorry we aren't communicating better. Let me try one more time.

In the 0.3 version there was an index.html (along with webiopi .css and webiopi.js) in the top webiopi directory. These files worked great in /var/www/webiopi with lighttpd.

In 0.5.1 these files are no longer there.

I have tried to take the 0.3 files and make the js and CSS changes but no luck.

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 Nov 25, 2012 5:52 pm

PHP with lighttpd/apache support is discontinued !
http://code.google.com/p/webiopi/wiki/CHANGELOG

You have to run the python server then open to the url given :
http://code.google.com/p/webiopi/wiki/INSTALL

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
oldcyberdude
Posts: 9
Joined: Fri Nov 02, 2012 4:35 pm
Location: Aiken, SC

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

Sun Nov 25, 2012 7:01 pm

thanks for your patience. Everything I was looking for is in /htdocs! Thanks again.

HeavensBlade
Posts: 26
Joined: Fri Aug 03, 2012 10:45 am

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

Mon Nov 26, 2012 9:51 pm

Hey,
how can I get the GPIO direction in python.
In case GPIO 22 is set as IN and as my program goes to GPIO.output(22, 1) I get an error.

I can't find that in the wiki.


#Edit:
Ok, just tried what was obvious.
GPIO.getFunction(22)
did it!

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 Nov 26, 2012 10:18 pm

HeavensBlade wrote:Hey,
how can I get the GPIO direction in python.
#Edit:
Ok, just tried what was obvious.
GPIO.getFunction(22)
did it!
Yes you're right, I have to add this in the doc.

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

rthorson
Posts: 3
Joined: Tue Oct 30, 2012 12:49 am

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

Tue Nov 27, 2012 5:15 am

I am having problems installing Python. I get errors similar to http:mirrordirector.raspbian.org etc.

Not found

Is there any other way to install python-dev without using sudo aptitude install python dev?

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 Nov 27, 2012 9:43 am

rthorson wrote:I am having problems installing Python. I get errors similar to http:mirrordirector.raspbian.org etc.

Not found

Is there any other way to install python-dev without using sudo aptitude install python dev?
two reasons :
1) your package index is out of date, try "sudo aptitude update", then retry install python-dev
2) the repo may be down, try later

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

stuartmarsden
Posts: 4
Joined: Sat May 26, 2012 12:52 pm

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

Wed Nov 28, 2012 8:41 pm

Have just put a patch on google code that adds 1-Wire support

http://code.google.com/p/webiopi/issues/detail?id=11

ENHANCEMENT - Patch against Rev 605

Really like webiopi. I am planning to use it as the basis of a swimming pool control server. To do this I am using a Dallas 1-Wire temperature sensor. I decided I might as well add 1-Wire functionality to webiopi if I have to write it anyway.

The patch is based on the w1-gpio module. The first thing it does is detect if the module is loaded and if so turns GPIO pin 4 into ALT mode to stop it being used. It adds at the bottom of the table a list of all detected 1-Wire devices and lets you read from them. The raw data is displayed or by checkbox can have the temperature extracted.

I have updated the RESTAPI docs to show what you can do. 1-Wire can be enabled or disabled which loads or unloads the w1-gpio module. A list of devices can be requested and then the data for a deviceId can be taken. This is easily manipulated by Javascript like extracting the temperature.

The webiopi main page will show the 1-wire devices below the GPIOs only when it is enabled. The list is updated dynamically so new devices will appear when they have been connected with no user intervention. They will also be removed when disconnected.

I only have one device so have only tested with that but it should work with many. It will only work with devices that give data in the w1_slave file. It does not support writing to devices but it could be added easily.

Hope it is useful to others. Any comments welcome.

Stuart

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