Notes from Sand Hill


XTension Tech Notes

Sandhill Crane

ID: TN.Rain Gauge
Subject: Using XTension and a rain gauge
Applicability:All versions of XTension after 1.0
Contributor:Michael Ferguson

There is a common rain gauge which is basically a 8" cylinder leading to a funnel which directs any water into a see-saw type divided bucket. As water accumulates in one side of the bucket, it tips the bucket to that side. This empties that side of the bucket and in so doing, forces a small magnet to trip a reed relay.

By attaching a sensor to the relay contacts, you can detect the periodic dumping of the bucket and relate it to an accumulation of rainfall. Each time the gauge is tripped, it means that 1/100th of an inch has fallen :

Here's an example, inside and out :

By attaching the output of the rain gauge to the input contacts of a simple "PowerFlash" module from X-10, you can get a X-10 command each time the rain gauge trips. You actually will get two X-10 messages, one for the ON, and an OFF when the reed switch relaxes after the magnet passes.

A very inexpensive source of a rain gauge is from Radio Shack, but it is a Kit and really does require some assembly. If you find this kit, you will want to see how the magnet and the reed switch are mounted :

Put it into XTension :

Create a new database unit in XTension, and assign it a house/unit code which is the same as the PowerFlash unit. Call this new unit "Rain Gauge". It should not be a "dimmable" unit.

Assign the following scripts to the ON and OFF scripts for the new unit :

this should be pasted as the ON script for "Rain Gauge" :
--this script tallies hourly rainfall
set value of "Hourly Rainfall" to ((value of "Hourly Rainfall") + 1)

this should be pasted as the OFF script for "Rain Gauge" :
--this script tallies hourly rainfall
-- note that this script is just a backup for the ON script
if (status of "Rain Gauge") is not true then
set value of "Hourly Rainfall" to ((value of "Hourly Rainfall") + 1)
end if

Now, each time the rain gauge trips, the "Hourly Rainfall" will be incremented by 1.

The next thing we need is a "roll-over" function which periodically adds the hourly rainfall to the daily, weekly, monthly and yearly counters.

Create 4 new units in the database named Daily, Weekly, Monthly, and Yearly ...Rainfall. Make each of them "dimmable", and give them NO address.

Now create a new a global script by pasting in the following, and name it "Rain Man".

--This script runs hourly and accumulates
-- daily, weekly, monthly and yearly rainfall

if (value of "Hourly Rainfall") is not 0 then
set HR to (value of "Hourly Rainfall")
set value of "Daily Rainfall" to ((value of "Daily Rainfall") + HR)
set value of "Weekly Rainfall" to ((value of "Weekly Rainfall") + HR)
set value of "Monthly Rainfall" to ((value of "Monthly Rainfall") + HR)
set value of "Yearly Rainfall" to ((value of "Yearly Rainfall") + HR)
end if

--Now clear the hourly rainfall tally, ready for next hour...
turnoff "Hourly Rainfall"


Now create a scheduled event which executes "Rain Man" every hour, on the hour, forever. Note that you will also want to create scheduled events which every day, week, month and year reset (turnoff) their corresponding counters.

Now, you need to set up the rain gauge and the powerflash and start things right with XTension. If you are not starting on January 1, then you may want to set the counters to values which are reasonably accurate for your area at the time of year when you do set up the gauge.

Position the rain gauge in a place where it won't fill up with leaves, it's bottom is level, and you can easily inspect and maintain it.

Don't forget to take apart the gauge periodically and make sure that there isn't anything restricting the free movement of the see-saw, and the funnel is not blocked.

Note that each 'count' of the rain gauge represents 1/100th inch of rain, and there is no way of representing decimal values in any of the displays of XTension (thru 1.6). You might want to divide the total counts by 100 to round the value to whole inches. For weekly, monthly or yearly figures, this would be adequate resolution and displays nicely in the XTension lists.

Additional help is available on our website:
Or directly to Michael and Paul Ferguson at: 407-349-5960
Or mail to Sand Hill Engineering Inc. Box 517 Geneva FL 32732
All icons, graphics and text copyright 1997 Sand Hill Engineering Inc.