Sunday, January 11, 2015

Christmas Tree Watering

For our first Christmas in Washington, we purchased a real, live Christmas tree.  My wife loved it; it looked and smelled great, making our living room absolutely festival.  She feared for its health, though, during our trip out of town over the holiday weekend and asked if there was anything that could be done to ensure it was watered while we were away.  Of course there was; we've got technology for such things. With only a small amount of work, I had an Arduino-based system constructed and installed, ready to serve all our Christmas tree watering needs.

I took the timer code and hardware from the moth-balled daylight alarm clock and repurposed it to check the water level in the tree stand and the water level in the reservoir every day at noon.  If there wasn't enough water in the tree stand and there was water in the reservoir, the program would turn the pump on, checking every tenth of a second to see if the tree stand had filled up.  Once it had, the pump was turned off.

For water level sensors I used two wires glued down to the edge of the tree stand and reservoir. As you've probably heard, tap water is quite conductive so as long as both ends of the wires were in the water, the circuit would complete through a resistor divider network.

The pump was driven by a Darlington transistor feeding the coil of a 5V relay.  Much like in my root beer temperature controller project, I used the relay to control one pin of a 120V AC plug. This plug was mounted in an outlet box with a pig tail that was plugged into the wall.  This effectively created an Arduino programmable outlet which, in this case, was powering the pump.

Here is the complete schematic:


And here is a photo of the installed system, in all its bread-board glory.



The reservoir is a simple five gallon bucket; you can see the blue and white wires used to sense the water level in the bucket at the top of the photo.  The tube on the right provided a conduit  between the reservoir and the tree stand for the water.  The black cord going into the bucket is the power for the pump; the other end is plugged into the outlet.

On the right-hand side of the picture you can see another set of blue-and-white wires running under the tree; those were used to sense the water level in the tree stand.  The Arduino and DS1307 can be seen plugged into the bread-board along with the resistor divider network (hidden among the pine needles).  (You might notice the Arduino has a lot of extra hardware on the PCB; this is actually a Ruggeduino, a fully protected Arduino clone which I highly recommend.)

As to performance, the system worked just fine; there were only two minor hiccups.  Problem one: the DS1307 is known not to be terribly accurate and it wasn't. I checked the time on it when we were taking down the tree yesterday and over the course of a month or so, it had drifted about 20 minutes.  There are Arduino libraries out there that can be used to correct this (by putting in user-specified drift constants) but I didn't bother to implement them.  In this application, whether the tree was watered at 12:00 or 12:05 didn't really matter.

The second problem was result of me not thinking about the placement of the tube in the tree stand. On my first test, I placed the end of the tube as low in the stand as I could.  When the pump turned on, the water flowed smoothly into the stand and when the pump turned off... the water continued to flow.  I verified the pump was off but the water continue to come, slowly overfilling the tree stand.  I lifted the tube out of the tree stand and the water stopped.

By placing the tube outlet so low in the tree stand, I had managed to accidentally use a trick common to flood-irrigation farming.  If you place the outlet of a tube lower than the inlet, and can somehow get the water started flowing all the way through the tube, no external energy is needed for the water to continue to flow.  By turning the pump on I had started the system flowing and by placing the outlet of the tube low in the tree stand, I had ensured once it started, even turning the pump off wouldn't stop it.  Simply positioning the outlet of the tube higher along the trunk with the outlet pointed down solved this problem.