Saturday, February 27, 2010

Garduino Redux

A while back I made a "Garduino", based on an article Luke Iseman wrote for Make Magazine #18. It's an Arduino-controlled plant growing rig.

Luke's original version monitors moisture and automatically waters the plants when they need it, and it monitors light level via a photoresistor and turns on a supplementary grow light as necessary. My version includes the light monitoring, but I omitted the moisture sensors and water pump in favor of an Earthbox self-watering planter. I figured that since Luke's version involved dumping water into a large bucket, manual refill is manual refill and I might as well just refill an Earthbox. I'm stupid, so I need to keep it simple, you see.

Anyway that's all old news. A while back, I put up some videos on YouTube, documenting the growing process:
Since recording those videos, I moved the circuitry from my breadboard to a permanent home on an Arduino protoshield, but until fairly recently that was about it. It's been running great for months now. It turns out that even with the grow light I don't get a terrible lot of light over there, so the basil's growing slowly enough that I only just now have enough of it to make some pesto. But alas, this is the best I can do unless we move somewhere with better lighting. I credit the Garduino with this being possible at all.

However there's been an annoyance: periodically the thing will just reset itself. I think this was because the host would occasionally brownout the USB voltage, making the Arduino reset. But whatever the cause, this has 2 problems: it means that I need to reset the Arduino's onboard time (since it doesn't have battery backup or even a clock), which in turn means I need to hook it up to a computer to access the serial port. For various reasons I have only one computer which can program the thing, which means I have to haul out a laptop to do this, and then physically sit next to the thing, tethered, to do the reset.

I resolved to solve this.

The lightbulb went on when Brian Jepson told me about the Sparkfun BlueSMiRF, which is a Bluetooth RFCOMM-to-serial-TTL bridge. In practice, it takes your "Serial.print" output from an Arduino program and makes it available over Bluetooth to a PC..... or a phone. Android, meanwhile, added an API for Bluetooth RFCOMM in version 2.0. My wife got me a BlueSMiRF for my birthday, and it was off to the races.

I rewrote the Arduino code into a simple finite state machine, and added the ability to accept commands over serial. It's a very simple project, so there are only 2 commands: reset, and set current time. I encountered some interesting open-source related issues in doing this, but that's another post.

I then wrote a spiffy little Android app that pairs up to the BlueSMiRF, reads the state dumped from the Arduino every 3 seconds, and then makes a pretty little Android UI. It shows me a Sun, Moon, or Clock depending on which state the Arduino is in (daytime, nighttime, or waiting for clock data), and reports the other status fields like light intensity and status.

All told, it's working pretty well! There are a couple minor bugs I need to fix, but it's doing what I need it to do, and it's pretty fun to whip out my phone to see how my grow lights are doing. A little pointless maybe, but fun.

My source is up on Google Code, if anyone cares.

2 comments:

Ian Cole said...

I love the arduino + android concept.

I'll just mention that there are also inexpensive realtime clock modules that would maintain time even with power failure. Just another option if you don't want to have to reset it manually :)

Dan Morrill said...

Yeah I know. But this way I get to talk to control my grow-lights with my phone!!! ;)

Although the REAL reason I did this is because I needed the general structure of the code... for my next Arduino project.