I've been running a PI3 with a rain gauge attached for a few months now,
and all seemed to be fine. However a few days back, it started going
mad. I now appear to be getting something like 0.66 inches of rain a
minute (looking out of the window I can see that this is not happening).
I've tried unplugging the gauge, but I still get the problem, suggesting
GPIO rather than the gauge itself. Stopping and restarting the software
appeared to help for a couple of days, but it has started again.
Rebooting doesn't work either. The Python3 code below is started at
boot up, and can be run with nohup. Any suggestions on where to start
looking ?
Thanks
Adrian
from gpiozero import Button
path='/home/pi/weather-station/rainfall.txt'
rain_sensor = Button(6)
while True:
rain_sensor.wait_for_press()
# Do not maintain counter internally, if the code crashes, you'll
lose the number.
# Read the number of flips from the file, file is cleared at
midnight, so it might not exist, need to work around that.
try:
rainin = open (path, "r")
count = int (rainin.read ())
rainin.close ()
except IOError:
count = 0
# increment the number
count += 1
# Write back to the file, this will start a new file. Do the sums
elsewhere on how much rain there has been
rainout = open (path, "w")
rainout.write (str(count) + "\n")
rainout.close()
# Put in a slight pause, other wise it will get multiple senses for
each flip
rain_sensor.wait_for_release(1)
--
To Reply :
replace "bulleid" with "adrian" - all mail to bulleid is rejected
Sorry for the rigmarole, If I want spam, I'll go to the shops
Every time someone says "I don't believe in trolls", another one dies.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|