Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Reply To: Rain Gauge Tip Data Without Rain

Home Forums Mayfly Data Logger Rain Gauge Tip Data Without Rain Reply To: Rain Gauge Tip Data Without Rain

Shannon Hicks

Below is the code I wrote several years ago that is still running on all our local tipping buckets.  This was way before all the ModularSensors libraries and MMW portal, so things could be written differently now, but it can give you and idea on how the Mayfly handles the interrupt signal from the tipping bucket.  There’s a 1-second delay after a tip is sensed to filter out any switch bouncing that sometimes occurs when a tip happens.

First you need to enable the pullup resistor on pin D10, which is already built in to the Mayfly board, you just have to close jumper SJ12 on the back of the Mayfly.  Then this snippet of the code shows how to set up your sketch to look for a low trigger from the tipping bucket switch:

I’ve sent the full sketch code to various people in the past few years who have requested it, and I thought it was already posted somewhere here on the forum, but if not, here’s the entire sketch.  The biggest weak point is probably the delays that surround the Xbee radio wakeup and sleep, totaling 5 seconds.  If a bucket tip were to happen during these delays, they don’t always get counted.  A better option would be to use a milli timer to let the Mayfly go back to looking for tips and then execute the radio on and off functions independently, without using delays.  But missing 5 seconds out of a 5 minute period isn’t too bad.  (We’ve got Hobo event loggers on these rain gauges to record the actual data, these Mayfly boards are just there to transmit the live tips to our in-house data viz page for realtime viewing.)  If the Mayfly has to do even more time-consuming things like cellular transmissions, then having the secondary device like the Trinket would ensure that no tips are missed.  There are certainly more efficient ways to build a simple counter, but cost-wise, it’s hard to beat a $7 Trinket.  If someone simply wants to count tips of a rain gauge (or any switch close/open event), then this code minus the telemetry stuff works great as an event counter/logger.