CHEERSNetworkClimate & health

Home / Resources / Weather station

CHEERS technical resources · WindChaser

Source code for wind_bearer_software.sensor_func.rain_gauge

WindChaser technical documentation: Source code for wind_bearer_software.sensor_func.rain_gauge. Original instructions, component references and source limitations.

Original documentation: Min Tai Yap and Julian Walker · © 2025. Migrated to CHEERS on 3 December 2026. This is working documentation; unresolved source gaps remain visible.

Software source reference
"""
Contains a helper function to measure the rainfall per minute using the rain gauge. We use the measurements
ml for the volume of water that is caught in one bucket of the rain gauge before it tips, and mm for the
depth of water that accumulates on a flat surface after all evaportation, percolation, and runoff have been
accounted for. 1mm of rainfall is equivalent to pouring one liter of water over one square meter.

For further information about rainfall measurement, refer to
:ref: https://www.niubol.com/Product-knowledge/Understanding-rainfall-measurement.html#:~:text=The%20rain%20gauge's%20working%20principle,electrical%20circuit%20to%20the%20recorder.

Authors:
    Min Tai Yap <Min.Yap2@monash.edu>
"""

import RPi.GPIO as GPIO
import time
import os

from wind_bearer_software.utils.io_utils import get_path, read_dict

flag_1 = 0

[docs] def rain_detect(rain_count, hall_effect_sensor1_pin, rain_scoop, funnel_area): """ Detects a bucket tip of the rain gauge, which corresponds to a tip in the voltage of the Hall effect sensor. Everytime a bucket tip is detected, the number of bucket tips up until execution is updated by one. The rainfall measured in ml collected in the rain gauge and mm up until execution are calculated based on this number of bucket tips. :param rain_count: Number of bucket tips recorded until execution :param hall_effect_sensor1_pin: Pin of the hall effect sensor installed in the rain gauge :param rain_scoop: ml of water needed to tip a bucket in the rain gauge :param funnel_area: Area of the funnel mm^2 :returns: A tuple containing the current number of recorded bucket tips, as well as the currently measured uncalibrated rain in mm and ml/m^2 """ global flag_1 if flag_1 == 0: if GPIO.input(hall_effect_sensor1_pin) == 1: flag_1 = 1 rain_count += 1 else: if GPIO.input(hall_effect_sensor1_pin) == 0: flag_1 = 0 # Convert the rainfall collected in the funnel (given in ml) to mm rain_ml = rain_scoop*rain_count rain_mm = rain_ml * 1000 / funnel_area return rain_count, rain_mm, rain_ml