Showing posts with label electronics. Show all posts
Showing posts with label electronics. Show all posts

Thursday, December 27, 2012

Automatic Christmas Tree Waterer

This project was a good exercise and learning experience for me. I learned a couple things the hard way (sometimes the best way):
  1. It turns out water isn't as conductive as I thought it would be.
  2. 5vdc in tap water is enough to electro etch (erode/dissolve) small wires in about a day.
Watering live Christmas trees is a real pain. Depending on the size of the tree and stand you could be crawling underneath twice a day to refill. Or you can forget to water it and have a very dead tree early in the season. I've had this idea mulling about in my head for a couple of years now, but never really got the bug to try it out. But this year when we went and got our tree I saw something at the farm that really lit a fire under me. I saw a long funnel with a sensor that let you know when the tree was dry. I picked it up and told my kids, "Hey! This was my idea. But mine's better. It fills the tree up for you."

My son responded, "Well, why don't you build it?"

So I did...

The idea was simply to have a water tank beside the tree that could hold enough water to keep the tree fed for a few days, some simple sensors in the tree stand to sense when the water was low, and a pump to refill the tree.

After some Google searching I found a similar project for Self-Watering Plants which I used as a starting point. I already had an Arduino on hand that wasn't currently being used, and with a "shield" attached to it I could make something semi-permenant that could be reused year after year but still make the Arduino available for other projects. Of course, I also considered building a dedicated circuit with a 555 chip (or similar) and avoid using a micro-controller, but I'm not skilled enough with circuit design to be that clever. Also, I wanted to be able to do some things that I had absolutely no idea how to do otherwise, and I needed to get something in place quickly. And, having an easily programmable controller made it very easy to make some much needed adjustments.

Controller circuit, Prototype #1

My first prototype used the digital pins on the Arduino for the water sensors, with the assumption that putting the leads in water would be just like closing a switch. This didn't work at all. In all my planning and testing I never actually tried the leads in water, and it turns out that water isn't quite conductive enough for this to work. Back to the drawing board...

Controller circuit, Prototype #2

This time instead of making my own shield from some perf board, I bought a Protoshield kit for Arduino.

Can I just go on a tangent and gush about this awesome little kit? (Of course I can, it's my blog.) For a little less than $10 (and can even be found at RadioShack...that's where I got it) you get a very nice board that makes it super easy to build an ad-hoc shield for your Arduino AND it comes with a whole bunch of components. I highly recommend this product.

And while I'm at it, can I also complain about the odd header spacing on the Arduino? Why in the world is one of the headers shifted by half a space, making it impossible to interface properly with standard perf boards? This is the stupidest thing I've ever seen. Love you Arduino, but come on!

Anyways...

The second prototype used the analog pins (A2, A3, A4) to read the low (and variable) voltage value actually being conducted through the water. When the leads are dry the voltage is 0 (or very close to it), but when wet there is a high enough reading to make a comparison in the code.

I thought the 9V battery would be plenty for powering the Arduino. Unfortunately either the batteries I used were old and nearly dead already, or the board was using a lot more juice than I thought it would. I was replacing the battery every day. After 4 days of that I just powered it with a USB adapter and ditched the battery.

The relay I used also came from RadioShack (5VDC/1A SPDT Micro Relay, Model: 275-240)

Final Circuit Schematic - The LED is used as a status indicator and is mounted in the tree

(See the very bottom of this post for the final Arduino code.)

I picked up a submersible water
pump at the local pet store.

This submersible water pump is low power so it won't burn out the relay. It's also nice and quiet. It only comes on for less than a minute once or twice a day, but I don't want something that's loud and scary. This has a very soft, pleasant hum.

Tree water sensor, Prototype #1
Tank water sensor, Prototype #1

The first sensor prototypes were just very thin wires from a phone cable. I didn't think I would need much more than that. But after a couple of days the sensor malfunctioned and the tree peed all over the carpet (and got several presents very wet). It turns out that the 5v lead that was always on was getting etched away, or basically dissolved. Then when the tree started filling up it didn't know when to stop and just kept filling...2 gallons of water soaked into my living room carpet. My wife was not amused.

Tank (top) and tree (bottom) water sensors, Prototype #2

So I beefed up the sensors by soldering them to some heavier wire. Then I also changed the controller circuit and code. Instead of running the sensors from the constant 5v power, I got the power from a digital pin (Pin 10, shown in the schematic above) that I could turn on and off. Then I could just turn it on long enough to get a reading and turn it back off again. I set the code to take readings every 5 minutes. I could actually set it for a much longer period than that, like every hour, but I also wanted to be able to monitor it and make sure the code is behaving the way I wanted it too. With these 2 changes I added a great deal of life to the sensors and haven't had any problems since.

Water tank and controller - they can be disguised as a present by putting a wrapped box over the top
Fill tube and sensor wires - the fill tube must not be submerged in the
water or it siphons the water back out into the tank.

After making all of the above fixes it's been running great. I only have to refill the tank every few days, and the tree never runs dry.

Green indicator light, upper left corner

When the indicator light starts blinking I just refill the tank.

Even though I'm happy with this final prototype, I've still got plans for more improvements. I'm thinking of trying a capacitive sensor for improved resistance to etching and allow for better adjustment of water depth. Several people have suggested I build a kit or product for sale, which I think would be an interesting challenge. Something like that would require a lot more design and testing. This is close, but not yet marketable.

Arduino code:
(If you don't see the above code, click me.)


Saturday, January 22, 2011

Brain Machine

I can't take naps. I'm capable of it, I just shouldn't. I alway feel worse after and then I have trouble going to sleep at night. But sometimes I really want to. "Just 15 minutes" I say. But 15 minutes always turns into 2 hours and then the rest of the day is ruined. So I just avoid them now.

Then I read about the Brain Machine by Mitch Altman from Make magazine. It caught my attention and I added it to my project list. Since I can't afford to do every project I like I let the list act as my filter. Anything on the list I'm still interested in after a few months gets bumped up the list and as money and time become available they get started. This was exactly how things went for the brain machine.



Make's Maker Shed store has one available for sale, and I was going to buy it there, but when I went to finish the check-out and saw the $14 shipping price I decided to look around to see if somewhere else had a better deal.

And a better deal I found, at Adafruit Industries. Not only was their shipping cheaper ($7), but the kit was priced $5 less too ($30). They also had much better instructions - plenty of pictures and enough detail that even a beginner could easily put this together.

The kit arrived quickly and had everything needed for assembly. Even batteries, shrink tubing, and wire ties. (You'll need to provide your own tools.) I was very impressed. It's these little conveniences that so often get overlooked that I really appreciate.


I may have gone a little crazy with the hot glue.

Assembly was very easy and went smoothly. It took me about 2 hours total, and that includes the time I spent mopping and turning the ribs out in my smoker. I almost made one mistake during assembly that (fortunately) Adafruit's terrific instructions helped me avoid. I had accidentally soldered the wrong color wire onto the negative lead on one of the LEDs. The instructions recommend testing the LEDs before making any final solder joints on to the board. I could have just let my experience fool me into thinking this wasn't necessary, but decided to take the little extra time and effort to test anyway. To my surprise I found this error before I soldered the wires to the board. It wouldn't have been a major error, but I would have wasted a great deal more time. And I hate making such simple mistakes.



The first time I gave them a try I was really surprised at how a couple of blinking lights will produce such wild patterns. Something I didn't expect at all. But all the hype around these things led me to think I'd have a more meditative "transcendent" experience. I actually spent most of the time feeling like I was going to go blind from the bright lights. And yes, I had my eyes closed. The lights were just too bright for my comfort. I tried it a couple times with the same results. Lots of cool patterns, but disappointment overall.

So I put a piece of masking tape over each of the LEDs to see if that would help. Boy what a difference. (This is recommended in the instructions, so it's not like I'm the first person to have this problem or solution.) Now it's a much better experience. I can enjoy the light and sound show without any discomfort.

But even after adjusting the brightness of the lights I wasn't quite sure if it was doing anything for me. Then as I was relaxing with them one day my wife walked into the room and suddenly jolted me out of a trance. And that's when I actually perceived the effect it was having on my state of relaxation. Even though I was fully conscience I had been put into such a relaxed state that when jolted out of it I felt like I was being woken up from a dream.

Now when I want a nap (and it's quiet in the house) I can just slip the Brain Machine on and relax for the 14 minute cycle. When it's over I do really feel better. I don't quite feel physically re-energized, but I'm in a better mental state. In fact, yesterday I went snow caving with my son. It was exhausting with very little sleep. I had some work to do after we got home, but was having a hard time concentrating and feeling motivated to work. So I took a 15 minute break with the Brain Machine and felt better for it. All the benefits of a nap without the pesky side effects.

By the way, my wife dislikes the blinking lights very much, even with 2 pieces of tape (I just use one). So your mileage will vary.