Rain Sensors: Gauge In progress

Introduction

The purpose of the project is to measure and record rainfall.

The project requirements are:

  1. To measure the rainfall over a series of predefined periods
  2. To display the current rainfall
  3. To record each period's rainfall in a file on removable storage in a format suitable for importing into a spreadsheet

This page is structured as if there was an orderly, linear process from design to construction. The truth is that process was iterative, through design, construction, testing, redesign … and so on. Every single 3D printed component was re-designed and re-printed at least once, with some being printed several times. Other components were destroyed during testing and had to be replaced. I've not gone into all the gruesome details here, because that would make this page much too long and difficult to read. However, some design changes are referred to in the text where the learning point is important.

Design

Design Overview

This project comprises a 3D printed rain gauge coupled to a microcontroller, storage and display.

The gauge collects rain and funnels it down into a pivoted bucket componet, comprising two buckets with an attached magnet as shown in figure 1:

Rain gauge bucket illustration

Figure 1: Illustration of the rain gauge bucket

The two buckets are pivoted about their common centre point. The mechanism starts off angled so that one bucket is higher than the other. Rain coming in from above fills the raised bucket. When sufficient rain has gathered in the bucket it pivots and empties its contents, bringing the other bucket up under the water flow. The process then repeats.

Each time the buckets pivot the magnet moves past a reed switch causing a pulse to be emitted that can be be processed by a microcontroller.

Rain Gauge Assembly

The rain gauge assembly is designed to capture and funnel rain water onto the buckets shown in figure 1. Renderings of the CAD designs of the components of the assembly are shown in figure 2:

Renders of all rain gauge assembly component CAD designs.

Figure 2: Renders of CAD designs of all components

The following list describes the numbered items in figure 2:

  1. Funnel
  2. Case in which the funnel is mounted that contains and protects the buckets
  3. "Plug" that fits inside the hole at the botton of the funnel that reduces the aperature through which water can flow.
  4. Buckets & magnet holder
  5. Cap to cover the exposed side of the magnet in the magnet holder. §
  6. Bucket pivot unit & reed switch holder
  7. Bracket that holds the pivot unit inside the main case
  8. Mounting brackets to be used to fasten the rain gauge bucket assembly to a wooden baseboard

Notes:

Original design by Christopher Barnett, modified by cahamo. Some are adaptations of Christopher's original STL files while others were recreated from scratch.

Original design by cahamo

STL files

The CAD designs were saved as STL files. These files can be downloaded from the cahamo/rain-sensors repository on GitHub.

All files are made available under the Creative Commons - Attribution - Share Alike license v4.0. Files originally created by Christopher Barnett are copyright © 2024 Christopher Barnett. Files created by cahamo are copyright © 2024, Peter Johnson.

Microcontroller

The pulses emitted from the gauge are counted by a microcontroller which calculates the amount rain that must have fallen to trigger each pulse. The total rainfall is displayed on a screen and recorded in memory. Periodically the data is stored on an SD card.

The microcontroller program must be calibrated before use. The amount of rain captured by the funnel and the volume of water needed to tip the pivoted buckets is required to do this. The catchment area of the funnel can be measured. The amount of water that is required for a bucket to tip and empty must be arrived at by experiment.

Construction

Rain Gauge

The rain gauge components described above were 3D printed on a Bambu Labs A1 3D printer using Bambu Basic black PLA. The models were sliced using the Bambu slicer using the default 0.20 mm strong print profile. The following montage shows all the printed parts. The parts are not to scale relative to each other:

All the rain gauge 3D printed parts

Figure 3: All 3D printed components

A 10mm ⌀ × 3mm deep neodymium magnet was glued into the magnet holder attached to the buckets. The magnet cap was then glued over the exposed part of the magnet. Superglue was used in both cases.

Magnet fitted to the magnet holder

Figure 4: Magnet fitted to the magnet holder

A normally open, plastic bodied reed switch, 2.7mm square section × 14mm long, was soldered to two 20cm lengths of 7/0.2mm stranded wire. The reed switch was then mounted into the provided channel in the bucket pivot unit, securred by superglue. Heat shrink was added to protect sections of the wire. The pivot unit was then bolted to its base with 2 × M3 nuts and 10mm hex head bolts.

Bucket pivot with magnet attached mounted to its bracket

Figure 5: Bucket pivot unit, with reed switch, attached to the mounting bracket

A 5cm long piece of round 3mm ⌀ mild steel bar was cut to use as an axle that allows the buckets to move within the pivot unit. The axle holes in the pivot unit had to be drilled out to 3.2mm in order for the axle to fit. A M3 washer was threaded over the axle on either side of the buckets to limit side to side movement. The "pimples" surrounding the holes on the side of the buckets component were filed down until the bucket rotated freely on the axle with minimal side to side movement. The axle is a snug friction fit in the pivot unit meaning that the axle remained stationary while the bucket pivoted on it. At this stage the wires from the reed switch were glued in place with superglue to avoid them fouling the axle.

Bucket sub-assembly completed

Figure 6: Completed bucket sub-assembly

Once the interaction of the magnet and reed switched was proved to be working as expected the reed switch was covered in hot melt glue to protect it from the elements.

Reed switch covered in hot melt glue

Figure 7: Reed switch protected by hot melt glue

The funnel plug, that gradually narrows the drain hole, was fitted into the hole at the bottom of the funnel. The plug had to be filed to fit snugly, so that its top was flush with the top of the hole in the funnel, with the plug's bottom sitting proud of the funnel base so that it fits throught the hole at top of the case. Superglue was run around the joint between the funnel and plug then further filing ensured that the boundary of the funnel plug with the funnel hole was as smooth as possible. The funnel was now bolted its containing using 4 × M5 nuts and 12mm hex head bolts.

Funnel mounted on top of the case

Figure 8: Funnel fitted on top of the case, showing the adapted drain hole.

The small images in figure 8, clockwise from top centre are: the holes in the funnel aligned over the case top, as printed; the plug after filing to fit in the bottom of the funnel; the plug protruding from the funnel base; the plug protruding into the top of the case & the plug after gluing in place and filing flush with the funnel hole.

It was now time to assemble the complete gauge. The funnel / casing assembly, gauge assembly and mounting brackets all had their mounting bolt holes drilled out to 3.2mm ⌀ and were then bolted together using 4 × M3 nuts, washers and 16mm hex head bolts. The wires from the reed switch were led out to one side.

Completed rain gauge assembly

Figure 9: Completed rain gauge assembly, including underside view.

Control unit

To follow

Bill of materials

The following components are required:

  1. 3D printed parts specified in figure 2
  2. Neodymium magnet: 10mm ⌀ × 3mm deep
  3. 5cm of 3mm ⌀ circular mild steel rod
  4. Reed switch: normally open, plastic body, 2.7 square section × 14mm long
  5. Nuts:
    • 6 × M3
    • 4 × M5
  6. Bolts:
    • 2 × M3 10mm hex head (any other head type is suitable)
    • 4 × M3 16mm hex head (any other head type is suitable)
    • 4 × M5 12mm hex head (any other head type is suitable)
  7. Washers:
    • 6 × M3

Calibration

The gauge needs to be calibrated before being used. We need to know how much water is required to tilt a bucket. To do this we simply pour a measured amount of water through the gauge and count the number of times the bucket tilts. The amount of water required to tilt the bucket is the volume of water put through the gauge divided by the number of tilts counted. It is advisable to run the test several times and to use the average of all the results.

Circuit

An Arduino Nano clone was used to count the number of times the gauge's reed switch closes while pouring water. The count was displayed on a 2×40 character I²C LCD display. To enable several tests to be undertaken sequentially a momentary push button was used to clear the counter. Figure 10 below shows the circuit:

Calibration circuit diagram

Figure 10: Calibration circuit diagram

One of the wires from the rain gauge reed switch is coupled to Nano pin D6 while he other connection to the reed switches is connected to ground. Similarly, one terminal of the push switch is connected to Nano pin D2 and the other terminal is also connected to ground. Both pins D2 and D6 are configured as input pins that are pulled up to 5V internally. The I²C display is connected to 5V, ground and to Nano pins A4 and A5, which double as the Nano's SDA and SCL I²C control pins respectively. Nano is powered by connecting 5V to its 5V pin and ground to a GND pin.

The circuit was built on a breadboard as shown in figure 11 below. The leads from the rain gauge were connected to the circuit via crocodile clips. 5V power was supplied by a breadboard power supply, connected to a 9V wall wart via a barrel jack.

Calibration circuit as built

Figure 11: Calibration circuit as built

Software

The microcontroller program was written in C++ using VSCode and and PlatformIO extension. The code was targetted at the Arduino platform. The source code is available from the code/gauge-calibration directory of the cahamo/rain-sensors project on GitHub.

Results

10 successful calibration tests performed. For each test a kitchen measuring jug was filled with approximately 800ml. This water was poured into the gauge as slowly as possible. After the jug was emptied the number of bucket tilts was read from the LCD and recorded. The count was then reset using the push switch and the experiment was repeated. The results of the tests are shown in the following table. The left column contains the number of tilts recorded per 800ml of water for each test while the right hand column shows the average number of millilitres of water required to tilt a bucket in that test, rounded to 2 decimal places:

Number of tilts Volume per tilt (ml)
140 5.71
131 6.11
137 5.84
130 6.15
139 5.76
140 5.71
135 5.93
137 5.84
142 5.63
137 5.84

The results were averaged using more than one averaging algorithm before arriving at an estimated bucket capacity of 5.85 ml.


That is as far as things had progressed as at 2025-02-17.

Back to main project page