This page last changed on Oct 27, 2014 by jules_bike.

I had a Raspberry Pi sitting around and I bought an 8 channel relay and wifi dongle to attach (total cost about €15). I got it all up and running nicely using a tutorial and software from
WebIOPi this is a toolkit for making use of the GPIO pins on the Pi.

The WebIOPi server on the Pi has a browser front end which works 100% and you can switch on/off and view the status of the relays. I also tried hooking up openremote using the http protocol but this is not working 100% and I can't figure out why not.

Has anyone worked with this before? WebIOPi looks like a nice tool as you can also connect sensors etc. Quite a cost effective solution for switches and sensors if it can be set up properly.

Edit:

I've done some searching and found what may be the problem - this is a section from a website that explains better how the functions work:

"With the default header app, you can toggle GPIO functions between input and output, and toggle pin states. Just click on the IN/OUT buttons beside each pin to change their state from input to output.

All GPIO can be directly used with the REST API. For instance, to set GPIO 23 as an output, just make an HTTP POST request on /GPIO/23/function/out then to output a logical 1, make POST on /GPIO/23/value/1. To retrieve states, make HTTP GET on /GPIO/23/function and /GPIO/23/value."

So basically I need to send two commands is this possible in one http command??


I managed to solve it. Turns out you can default the pins to out in the start-up script for webiopi. Now working well. Only issue is the WiFi dongle has no range.....

Posted by jules_bike at Oct 28, 2014 14:24

Hi,
I like the idea of the WEBIOPI integration, do you have any screenshots of the HTTP command configuration from the OR designer you can share?

Posted by edgi at Nov 25, 2014 09:32

Hi - yes it seems to work well although I have got rid of the wireless dongle and wired up ethernet for a more reliable connection.

Here are two commands one for on and one to read the status which I poll every 1 second - I'd normally go more rapidly that that but my Openremote server is polling too many things now. I have reduced the time until I upgrade to something faster.

Depending on how you wire your actuators the command for on is http://192.168.0.14:8000/GPIO/2/value/0
off is http://192.168.0.14:8000/GPIO/2/value/1
status is http://192.168.0.14:8000/GPIO/2/value

You then need a sensor which use the status command and link the on and off with the values 0 and 1.

Finally you create a switch based on the sensor.

Make sure you use post for the on and off commands and get for the status as you see below...good luck!

Posted by jules_bike at Nov 25, 2014 16:04

Hi Jules,

Thanks for your quick reply!

I followed your recommendations, but I still did not work.

I have done the following steps to install webiopi and sync with OR Controller:

1. Install and run webiopi according to the installation instructions - OK
2. Test webiopi in Browser - OK
3. Test webiopi with Android app RPI Automation - OK
4. Set up and run OR Controller - (The GUI is synchronized but the buttons do not respond)

I have also checked that the security key of webiopi is disabled

This is the configuration procedure I've done

command STATUS: http://192.168.0.16:8000/GPIO/7/value

command ON: http://192.168.0.16:8000/GPIO/7/value/0

command OFF: http://192.168.0.16:8000/GPIO/7/value/1

***************************************************************

Do I need to do something more within the RPI settings, a script or something?

Have you any suggestions?

Regards,
EDGI

Posted by edgi at Nov 25, 2014 21:52

Looks ok mostly although you do not need a polling value for the on and off commands - not sure if that would help.

If you just stick the command directly into the browser and press return do they turn the lights on and off?

Posted by jules_bike at Nov 25, 2014 22:06

If you just stick the command directly into the browser and press return do they turn the lights on and off?
**
Do you mean that?

No lights reaction

Posted by edgi at Nov 25, 2014 22:29

Yes that should work?

You should also be able to pull up a page:

http://192.168.0.16:8000/

which will show the configuration of the server and visually check the setup.

Posted by jules_bike at Nov 25, 2014 22:42

Yes!

The problem for me was the definition of the command.

For my it works in this way:

Command ON: http://192.168.0.16:8000/GPIO/7/function/in
Commnad OFF: http://192.168.0.16:8000/GPIO/7/function/out

Works with buttons separately and not with the switch.

Tomorrow I will try the switch configuration and the status image.

Do you work with the switch or command buttons separately?

Thank you!

Posted by edgi at Nov 25, 2014 22:55

Hi I'm not convinced this is correct - each GPIO can be operated as an Input or Output - you need to have them set as Output which you can force by editing the /etc/webiopi/config (assuming you have put it there).

There is a section in the config file (see below) where I default the GPIO's to OUT for the 4 connectors that I am using, you can also default them to come on or off and start up using 1 or 0.

You are probably just toggling between Input and Output and this in turn is tricking the application.

I had the same problem to start with because if they are not set up as OUT then the switch will not work. I use the Switch and it works fine.

[GPIO]
# Initialize following GPIOs with given function and optional value
# This is used during WebIOPi start process
#21 = IN
#23 = OUT 0
#24 = OUT 0
#25 = OUT 1
2 = OUT 1
3 = OUT 1
4 = OUT 1
7 = OUT 1
#8 = OUT 1
#9 = OUT 1
#10 = OUT 0
#11 = OUT 1

Posted by jules_bike at Nov 26, 2014 15:40

Hi Jules,

Thanks for your help.

You are right, it is necessary to modify the config file.

After an extensive search I managed to determine variable name problem "value" instead of "function" and why my RPI did not recognize the command by "value".

It might happen when SD Card's sector gets corrupted and the solution is to remove all python packages, install them again and as always very convenient reboot again.

Once done Voilà! it works like magic for me.

Regards,
EDGI

Posted by edgi at Nov 28, 2014 11:47
Document generated by Confluence on Jun 05, 2016 09:34