Meanwhile, it's back to trying to just reach down into the stand to feel the water level.
-- --- ----- ------- ----------- -------------
Well, it's that time of year again. I'm not allowed to go into stores between Thanksgiving and Christmas — it's a long story involving singing Santa dolls, inflatable snowmen, and spandex bike shorts; and I won't tell it here — so since I can't go shopping I use my time more productively. Or at least I do some hardware hacking...
We have a very nice Christmas-tree stand: it's a tall, heavy, cast-iron chunk that does a wonderful job of holding our tree up. The problem is that it's difficult to determine how much water is in the stand, or whether the tree is getting any water at all. Occasionally our tree will drop all its needles, or spontaneously combust, at which point it becomes obvious that the tree needed more water; but it'd be nice to have some earlier indicator.
I discovered MIT's "High-low tech" site recently, and they have a nice tutorial on using the Arduino to program ATTiny45/85 chips. So I decided to use an ATTiny85 to make a Christmas-tree water-level sensor.
The circuit itself is dirt simple: Battery, ATTiny85, LED, resistor, buzzer, and water sensor. That's it.
The battery is a 3-cell AA battery pack (4.5V), and the buzzer is some random piezo buzzer that's been sitting in my parts bins for years.
The sensor consists of a strip of proto-board with three traces: two long, and one cut about an inch shorter. The way the water sensor works is the pull-up resistors in the ATTiny85 (about 20k) hold the inputs high by default. If a sensor wire and the ground wire are immersed, the small current through the water pulls the corresponding input low. If the water covers all three traces, that's good. If the water gets below the level of the short trace then pin PB3 goes high to indicate low water level, and if the water gets below everything then pin PB4 goes high to indicate very low water level.
The program checks the state of lines PB3 and PB4, and makes the LED blink repeatedly if the level is low. Should the level get very low, the program turns on the buzzer as well. Note: if you're making one of these yourself, make sure the difference in length between sensor wires PB3 and PB4 is enough that the tree won't go from "fine" to "buzzer" in one night. Otherwise the thing wakes you up early in the morning!
Here's the device, as I was testing it in a cup of water. The ground strip is becoming slightly discolored due to something electrochemically interesting going on, even with the low voltage and low current of this application. That discoloration should not interfere with operation, though.
To mount the device, I hot-glued magnets to the back of each piece.
The magnets make it easy to mount the sensor and circuit:
Here's the final product, tucked up under the branches at the top of the stand. It's out of sight unless you duck to look under the tree, and it's much easier to check the water level than before!
The same method could be used with an Arduino instead of the ATTiny85, and the program would work with an ATTiny45 or -25 also. (The compiled code uses fewer than 900 bytes.) If you re-wrote the program in PICAXE Basic, a PICAXE-08M would also work.