OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Python interval program update 9/23/13 Re: Re: Python interval program update 9/23/13



Hi Dan,

Thanks so much for adding the per station rain sensor option. That’s great! Plus all the other fixes and updates.

It took me a while to feel confident to do the “git pull” to bring in your commits and merge them with my local changes for the garage door and rain sensor. I’m new to git. I’ve been reading a really good on-line free book,, which has helped me quite a bit. also helped with understanding what I needed to do to fix the conflicts I had in and home.js.

Since the rain sensor is functional now, I wonder if you would consider adding code to to define the pin, set up the gpio, read the pin, and poll it.

Here’s the way I’ve done it, adding to the appropriate sections:

def getRainState():
if GPIO.input(pin_rain_sense):
res2 = 0
res2 = 1
return res2

pin_rain_sense = 25

GPIO.setup(pin_rain_sense, GPIO.IN, pull_up_down=GPIO.PUD_UP)

And inserting a call to get the rain sensor state in the main loop:

def main_loop(): # Runs in a seperate thread
""" ***** Main algorithm.***** """
print 'Starting main loop n'
last_min = 0
while True: # infinite loop = time.time()+((*3600 # Current time based on UTC time from the Pi adjusted by the Time Zone setting from options. updated once per second.

Other folks might choose a different input pin for the rain sensor, but the rest of the code would be there.



Thanks again!