As many of you are aware of by now, I have a (un)healthy obsession with fish. I also have a terrible memory. And the ability to program web applications. And the tendency to enjoy taking ideas all the way to their logical conclusions.
Possessing any of these attributes in isolation is not so bad of a thing.Â But when all of them combine into one person, well…Â You end up with some really oddball (yet fun) projects.
Bearing all that in mind, I’d like to tell you about a project I’m in the middle of right now – the FishApp.Â FishApp started out as a PHP/MySQL web application that I created to help keep track of the water quality in my fish tank, and to view changes in water parameters over time (to identify trends and causal relationships, for example).Â That didn’t sound like such a difficult project…
This is where things started getting out of hand (in a good way).Â I decided that there may be other fish nerds on the internet who may want to use the service, so I added multi-user capability to the FishApp.Â Which meant I had to make everything more user-friendly and build out the Admin area a little btter.Â I had to give users the option to upload a fish tank picture (and resize it for them, etc).Â And what if they had multiple tanks?Â And so on.Â All of those features are currently built into the fishapp.Â We’ll see if anyone decides to use it or not!
There’s nothing too crazy going on in the FishApp code.Â The graphs are generated by Flot (using a custom PHP wrapper I wrote and dubbed “phlot”).Â There’s jQuery and the jQuery UI tools all over the admin area, and of course a rather simple MySQL database in the back.
There were a few technical challenges to address, however.Â The last graph on the page displays the average “age” of the water in your fish tank.Â It is a good idea to periodically change out some of the water in the fish tank for fresh water (to reduce things like Nitrates and accumulated minerals).Â This reduces the weighted average age of the water in your fish tank.Â This is my favorite feature, as it adds a visual display to an important piece of information that is normally invisible.
I also wanted the appÂ to send reminders to do maintenance tasks now and then.Â However, if you have a large fish tank, you may only do a water change once a month, but if you have a small tank, you may want to do it every week.Â I needed to give the users the opportunity to decided their own parameters for alerts.Â In addition, I wanted users to be able to get an alert when their tank’s water age reached a certain number of days.Â The SQL code necessary to aggregate across all the different maintenance types and tanks and users became quite large, however well-placed database indexes keep things running smoothly.
If you haven’t nodded off yet, you might be thinking that I’ve just about pushed this idea as far as it can go.Â You would be mistaken.
Sometime in the middle of the project, I discovered this awesome open-source hardware/software microcontroller project called Arduino.Â The Arduino project does what frustrated software engineers have longed to do since they days they first fired up QBasic on their friends’ computers – interface with the REAL WORLD.Â Easily.Â You can program the Arduino using a comfortable C-like language in its easy-to-use development environment.Â It can read sensor values, move servos, control motors, light LEDs, make sounds, etc.Â Anything you can wire up to it, you can use (basically).Â People were doing cool stuff like improving their espresso machines, building real-life pong interfaces, tweeting their energy usage, and the like.Â So naturally I decided my fish tank had to be web-enabled.
I am still in the middle of this section of the project, but here are some ideas of what I plan on doing with the FishApp:
- Use an ultrasonic distance sensor & some code to determine when I have just done a water change, and automatically post JSON data to the FishApp’s API.Â No more forgetting to put water changes into the app.
- Monitor the tank’s temperature over time using a neat little National Semiconductor chip.Â I should be able to detect and diagnose any big swings in temperature in real time.
- Control some LED moonlights for my tank, both on a programmed schedule, and using an infrared remote control.
- Allow web users to feed my fish a special treat (once a day) by pushing a button on the web page.Â AJAX + Arduino + Servos for the win!
- Set up a FishCam – a webcam to view the action in the tank.
- Every now and then, tweet what is going on in the fish tank.
- Buy a PH probe and graph real-time PH values (especially important if I decide to do some CO2 injection in the tank at some point).
- Build a turbidity meter to measure the water clarity (following instructions from an awesome Forrest Mims electronics book).
As you can see, the list goes on and one.Â The first few features are already in development, the rest may follow afterward.
As I said, the FishApp is not finished.Â It is not very polished currently, and not really ready for prime-time.Â I just wanted to post this blog to give a sneak-peak of what’s in the works.Â Now go check it out!