summaryrefslogtreecommitdiff
path: root/dev_scripts/sen15901rain.py
diff options
context:
space:
mode:
authorars <asav1410@gmail.com>2020-06-17 15:59:52 +0100
committerars <asav1410@gmail.com>2020-06-17 15:59:52 +0100
commitf665f78155047838dc924634ebe4128f7add5542 (patch)
treefa0b6d2fd4a7b26d7fac2d557066044384d33010 /dev_scripts/sen15901rain.py
Initial commitHEADmaster
Diffstat (limited to 'dev_scripts/sen15901rain.py')
-rw-r--r--dev_scripts/sen15901rain.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/dev_scripts/sen15901rain.py b/dev_scripts/sen15901rain.py
new file mode 100644
index 0000000..ed54189
--- /dev/null
+++ b/dev_scripts/sen15901rain.py
@@ -0,0 +1,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)
+"""