[Project] $20 (or so) Watering system with Vera Control

to contribute something useful, here is what i have done in the gardening matter:

Parts used:

[ul][li]2 x 1/4" Valves US $6.29 from Alibaba (seller sucks but the product is okay)[/li]
[li]1 x Raspberry PI B US $43 from element14[/li]
[li]1 x PI-Face Board US $44 from element14[/li]
[li]1 x PC Power supply[/li]
[li]20 Meters Telephone cable[/li]
[li]2 Liters of Coffee/Red-Bull[/li][/ul]

well i have to admit, it is alittle bit more than 20Bucks, but the Raspberry does mainly other jobs like holding my mysql datamine database and xbmc data, webserver and hosts another 6 Door sensors (they also show on the vera) so the more expense are somewhat compensated.

basically a Aurdino for 10bucks and a relay can do just the same. and we back to 20 Bucks :wink:

the RPI runns a small python script … that listens on the inputs and doestrigger the veras switches accordingly in realtime.
and it listens also to http commands to trigger the outputs.

so on the Vera … we have Virtual switches using

  • D_BinaryLight1.xml or D_Relay1.xml (as you prefer)
  • I_VirtualSwitch.xml

and a scene with no action.
in the scene have triggers set up for the virtual switch turned OFF and ON
and in the luup section simply have the http call to the PI to actually do what the switch should
like:

luup.inet.wget('http://172.16.67.21:8000/?output1=0', 5)

all the rest is very straight forward (i guess)
i just have not yet managed to get the pipes dry … they tend to leak (used alot of rubber tape but there is still getting some drops of water out … (i’m just not good in this things) :wink:

oh as for the sprinklers itself. i simply connected a plastic garden hose (20 meters)

used a lighter and a paperclip … (make it hot with the lighter) and punch a few holes here and there …
not perfect, but works and its dirt cheap :wink:

sorry i forgot the logic:

devices:

[ul][li]71 - waterpump (may not needed)[/li]
[li]26 - weather plugin[/li]
[li]30 - weather plugin (could be physical sensor as well)[/li]
[li]158 - virtual switch for sprinkler 1[/li]
[li]159 - virtual switch for sprinkler 2[/li][/ul]

luup:[code]
luup.log(“##51: Sprinkler Controller”)
local wason = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, 71)
local cg = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “ConditionGroup”, 26)
local c = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Condition”, 26)
local h = tonumber((luup.variable_get(“urn:micasaverde-com:serviceId:HumiditySensor1”, “CurrentLevel”, 30)) or “0”)

function s51end(oldstate)
luup.log("##s51end oldstate: " … oldstate)
if (oldstate == “0”) then
– water back off … because it was off
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },71)
end
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },158)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },159)
return true
end

function s51onR()
luup.log(“##s51onL”)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },158)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },71)
return true
end

function s51onL()
luup.log(“##s51onL”)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },159)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },71)
return true
end

function s51off()
luup.log(“##s51off”)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },158)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },159)
return true
end

– do this only if no rain
if ( string.find(cg,“sleet”) or string.find(cg,“rain”)
or string.find(c,“rain”) or string.find(c,“thunderstorm”) )
and (h>69) then
luup.log(“##s51 Rainy … do nothing”)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },158)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },159)
return false
else
luup.log(“##s51 No Rain … so make it rain!”)
luup.log("##s51 Waterpump Pre Status: " … wason)
– we need water !
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },71)

luup.call_delay( ‘s51onR’, 2)
– after 40 minutes turn it all off
luup.call_timer(“s51off”, 1, “40m”)
– turn on the other side 2 minutes later
luup.call_timer(“s51onL”, 1, “42m”)
– finsih up
luup.call_timer(“s51end”, 1, “50m”, “”, wason)
end

luup.call_timer(“s51off”, 1, “55m”) – this is just to be safe the sprinklers are really off
return true
[/code]

Very interesting project !!!

I was also trying to control the raspberry pi from vera 3 with UI5 to launch a the camera and do some picture comparations but I do not know how to launch the process from vera.

You said something about a python script. which one are you using?
It would be very appreciated if you can share.

Thanks in advance !!!

I just changed the script that i found on github for the piface to auto populate the virtual switches, and added a backdoor uri so i can call sh scripts via vera, perfect for image processing and email actions and so on
I control even my router this way (if i out of the house it turns off the bandwith-limit for my torrent client running on the appletv) :slight_smile:

Sent from my iPhone using Tapatalk

since the vera keeps randomly rebooting … it’s also good to add the “off” commands to starup_lua in app section …
to ensure the valves turned off (if the vera reboots while the script was running they may stay open otherwise)

also the Weather Plugins POP values are pretty much useless if the weather does change during the day.

what i do now is i added another variable to the weather plugin “pop_future”
this is populated IF POP.1 is greater as it was before and reset after the sprinkler did run.

so i have a more acurate POP value as its beeing collected for 24 hours … instead of just taken from right now.

This has inspired me to make something simliar but use a z-wave power plug to turn it on off and then

http://nicegear.co.nz/robotics/12v-solenoid-valve-34/
http://nicegear.co.nz/electronics-gear/power-supply-12v5v-2a/

I’m just wondering, anyone got suggestions how to waterproof the connections to the solenoid? I’ve never done anything like this before, it seems simple in theory, but I keep thinking power + water == bad. 12v isn’t much, but…

I’m then planning on installing the z-wave power switch and the 12v adapter in a waterproof box and use a outdoor power plug going into that box. Then to turn it on/off its just a switch in vera. I already have a hose with screw in sprinklers in it (very low tech) so basically just after a way to control an outdoor tap on/off from vera.

just put a standard fuse between the Power suply and the valve (as closest to the power supply as possible)

standard car fuse will do with lowest rating . and all is good.

the contacts are quite far apart … so if they will be short dure the water sure you have bigger problems as the power running trough it :wink: