This will show you how to make your own "tipping bucket" rain gauge with a NodeMCU, that makes it easy to send data to an online service of your choice. In this tutorial we are going to collect data from the rain gauge and then transmit it every 30 minutes to the readiness.io service.
The nodeMCU uses the ESP8266 Chip from Espressif. It has built-in Wifi and is compatible with the Arduino IDE. If you haven't used a NodeMCU before check out this quick start guide.
Step 1: Components
Step 2: Building a Tipping Bucket
Tipping buckets are a fairly common tool for measuring rainfall. It is a simple device that consists of a funnel which directs the water into a bucket. Once the bucket fills up it tips over activating a switch, tipping out the water and begins filling up the bucket on the other side. - See wikipedia for more info
For your own rain gauge the simplest option is to buy one. Something like this or this would work with our setup. If you do buy one - you don't need to worry about the Hall effect sensor or magnet. If you're looking for something a bit more agricultural you can out one together from parts you can pick up at your local hardware store. Check out the design from these guys
In our case we've 3D printed one. We've based ours on this one by BulldogLowell. We've modified it slightly to fit our sensor and magnet.
The STL files can be found in our Github repository
Every time the the bucket tips, the switch registers one count, which we can convert into a height of rainfall. The height of rainfall can be determined by the ratio of the volume of rain collected to the collection area:
rainfall height (cm) = volume collected (mL) / collection area (cm2)
For our collector we have a collection area of 5.5cm x 3.5cm (19.25cm2) and a collection per tip of the bucket of 2.5mL. This gives us a rainfall height of 0.1298cm or 1.298mm per tip.
A couple of notes when installing the unit
- Ensure that the unit is completely level - if not the buckets won’t collect the same volume for each tip - and your results won’t be accurate
- Install it off the ground - at least a metre high. This is to reduce the likelihood of anything being accidentally tipped into it (like dirt).
- Ensure that there is nothing above the gauge. It might seem obvious but its important there there isn’t anything like tree branches or leaves within a few feet of it to ensure nothing can interfere with the rain. (And remember tree branches grow over time.)
Step 3: Wiring It Up
Here is the basic wiring diagram for the device. You can see what the final version looks like at the end of this instructable and how to connect it up to you tipping bucket.
The LED and push button aren't necessarily required but are useful to publish a manual reading and check that its working.
Step 4: Source Code
For the rain gauge we will be posting the data every 30 minutes to the readiness.io service. We'll be using the readiness.io library that manages the wifi and service connections. We've also split out all of the configuration variables in a separate .h file.
Within the RainGauge.ino code we have three interrupts performing the key functions
- Rain Interrupt - detects when the bucket is tipped and adds it to the collected rain height
- Timer Interrupt - which periodically (we've used 30min) takes the rain height and sends it to the readiness.io server and then resets the height.
- Push Button Interrupt - which performs the same function as the timer manually (we've used this mostly for testing is optional)
You can download the full source code here
Step 5: The Finished Product
Here is the final rain gauge. The nodeMCU is housed in the enclosure with the wires for the tipping bucket entering through the cable gland to ensure that its water tight and safe to be install outside. Our wires are fairly should but you can make them as long as you need.
You can also see the inside of the tipping bucket. The sensor is attached to the wall, whilst the magnet is fixed to the swing arm of the tipping bucket, so that every time it fills up and tips over it registers a reading. The hardest part of assembling the tipping bucket it positioning the sensor and magnet correctly. Just close enough to take a reading but not tool close that it always remains on.