Digital rain gauge

By Martin M.

Overview

This rain gauge implements the use of a water wheel in order to accurately measure rainfall (.01 in) and display it digitally. The wheel itself has 8 sections with each section being marked by a magnet. As a section collects water, it gathers weight, which allows the wheel to turn. The magnet passes by a Hall Effect sensor, which adds a predetermined amount of water (namely the amount that a wheel can hold). The amount of water is actually smaller than can be displayed on the sensor, so every two events equals the .01 that can be displayed. The display ranges from 0.00" to 9.99" and has a button to reset the value.

Most digital rain gauges work by the use of a tipping bucket design. When water fills the bucket, it tips to the other end. The problem that I saw in the design is that it is only practical when the bucket is large. A larger bucket tends to be inaccurate; the amount is only added when the bucket tips, but does not keep track of when the bucket is any fraction from being full. The solution is obviously to have small buckets that tip more frequently, but this gets to be impractical in heavy rain storms. The solution that I came up with was to use a wheel so that a bucket can be smaller and always replace the used bucket.

Hardware

The rain gauge consists of a three digit display with display controller (PCF8566), tactile switch (to reset the gauge), slide switch, Hall Effect sensor, and crystal oscillator (for future functionality, such as rain intensity and duration). The controller itself is an ATtiny45. The TPS60310 from Texas Instruments is used to regulate the voltage power supply. The gauge is powered by two AAA batteries.

Schematic Main PCB Sensor PCB

The display is an output from the controller to a controller responsible for outputting the data to a screen. By using the I2C interface of the device, it is able to update the display independently of the controller in two wire mode. The controller uses one wire that keeps a clock for synchronizing with the microcontroller and the other for data input from the microcontroller (SCL and SDA respectively). The display is three digits long and is able to be measured to the nearest hundredth.

The tactile switch is a small button mounted on the controller and is used for resetting the gauge to 0.00 after the maximum is reached. It must be done manually in order to reset the gauge for another rainfall event. The crystal oscillator currently serves no purpose in the program; it was included in order to increase functionality in the event that the controller would be reprogrammed to display other events, such as rainfall intensity, duration, and other time related events.

The TPS60310 is used to regulate the voltage supply. It converts the power from the batteries into the necessary 3.3V that is necessary to power the device. The reference voltage for the device is also 3.3V. The Hall Effect sensor is a magnetic sensor that captures a rising edge event from a strong North Pole. Magnets are then mounted on the wheel corresponding to each "bucket" at even intervals. As each magnet passes by the sensor, the voltage drops to 0 and the pin change event in the microcontroller triggers subroutines discussed in software. The sensor is mounted on a separate board because of water proofing problems and the electrical sensitivity.

Software

The device was programmed using the assembly language. The display is configured to I2C interfacing in slave mode and is given the display information from a data register. The clock is set to run at 31kHz internally (1:256) with timer 1 to count every .5 s (1:64). The code itself is relatively simple. First of all there is a pin change interrupt for the sensor. Every time a magnet on the wheel passes the sensor the SENS_ISR sub routine is called: a 16 bit register is incremented for each event and, if necessary, carries over if the number is larger than can be expressed in 8 bits (larger than 255). It then checks to see if the number is equal to 2000 (10.00") and then saturate the value until the button is pressed to reset.

Second, the TIM1_OVF subroutine is executed when the timer overflows (every .5 s) and executes two calls to subroutines bin2BCD and displayData. The bin2BCD method takes the numbers from the counting register and copies them to a working data register to make into digits. First, since every event that is detected, the value that we have counted so far is divided by two. Second, it subtracts 100 until the value becomes negative, each time incrementing the dig1 register. After it becomes negative, it adds 100 (63 and 37) and continues on to the second digit in the same manner, this time subtracting 10. The third digit represents what remains. The displayData method encodes each of the three digits by a permanent data register storing the values for the seven segment display (the first digit uses a separate register that places a decimal after the digit). It then sends a call to the controller to write these digits to the display.

The remainder of the code is used to initialize the microcontroller and write to the display using the I2C interface.

Assembled device

Here are some photos. The board is designed to fit into a 4"x2"x1" plastic project box from Radioshack.

Left to right: rain whater wheel with magnets for sensoring rotation, Hall effect sensor mounting, display assembly side and top views.

Downloads


Last modified:Mon, Jan 23, 2023.

01551