The Casequarium was born out of a desire to put together a salt-water aquarium that could keep fish alive and healthy without much upkeep on my part. When I set out building the controller some two and a half years ago, I had just taken a job that required occasional travel, sometimes long and unpredictable hours, and required I move some distance from my hometown, leaving behind friends and family. I was going to be away more than I was home.

I had read before I got started that salt-water aquariums need near constant tweaking and babysitting, but I'm a controls engineer, and I build electronics. There's no problem so complicated that an ample application of code and motors can't solve. So I outlined the requirements for daily aquarium upkeep and set about building a system to do my work for me.

-Lights that turn on and off at a preset time

-Temperature monitoring and control

-Automated feedings

-Air pump and water filter pump control

I also wanted to use as many commercial, unmodified devices that attached directly to, or are submersed in the aquarium. That way if a pump or heater died, i could make a quick trip to the pet store, buy a replacement/upgrade, plug it in, and not worry about having to break out the soldering iron, dremel, or laptop.

To accomplish all of these things, I gathered the following:

- Real Time Clock module that communicates over I2C

-LCD Display, I2C compatible

-4 port relay board

-8" x 8" x 6" plastic J-Box enclosure

-Wall receptacle box and cover large enough for 3 duplex outlets.

-1 GFCI plug, because electricity and water

-2 standard outlets as slaves to the GFCI

-Arduino RBBB with ATMega328

-Bluetooth to TTL Serial Adapter for wireless programming

On the aquarium side:

-Digital temperature monitor, bought for the submersible thermo-probe

-Programmable fish feeder, modified to receive commands from the Arduino

-120v 30w aquarium heater

-120v aquarium air pump

-120v side mounted filter pump, came with the tank

-120v flourescent light and hood, also came with the tank

There have been some other minor hardware modifications along the way that either didn't work and were scrapped, or were fixes to broken hardware. After around 6 months of running the setup, the controller started randomly freezing and power cycling, I narrowed the issue down to power outages, so i added a 9 volt battery with a 1n4001 in series to act as a battery backup for the controller. I couldn't heat the tank or run the air pump on a 9 volt, but at the very least i could keep the feedings on the same schedule. Eventually the power outage issues went away, and so did the battery backup. A month or so later, the lm7805 built into the RBBB Arduino started acting flakey and running terribly hot, so it was disabled and in its place went a beefier linear regulator. Two years and running strong.

The code behind the arduino is some of the most extensive I have written for a microcontroller, at nearly 1000 lines with many subroutines and interfacing with multiple pieces of hardware, it was both challenging and fun. The code is what has needed the most attention over the last two years, almost as much as the long term maintenance of the tank itself. I have made lots of changes and improvements over time, learning lots about the Arduino IDE, and even writing my own library that I used extensively in an effort to make a microcontroller act more like the PLC's that I program for pay. There's too much code to go over in a single post, so I will detail snippets in separate posts as time allows. The code in its (ugly/undocumented/bloated) entirety is available for download via the dropbox link on the page. Please use it as an example of how not to code. Seriously. It sucks.