summaryrefslogtreecommitdiff
path: root/dev_scripts/sen15901rain.py
blob: ed541892d1b4d0662081a9a243c0a5332bc588e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from gpiozero import Button
import time

rainCount = 0
bucketSize = 0.2794 # size of bucket in ml
rain = Button(6) # setup GPIO 6 as a button

# every tip add 1 to count
def tipped():
    global rainCount
    rainCount +=1
    print (rainCount * bucketSize)

def resetRainfall():
    global rainCount
    rainCount = 0

rain.when_pressed = tipped

"""
# test loop

while True:
    rain.when_pressed = tipped
    time.sleep(1)
"""