This article chronicles my attempt to build an aquarium monitor using the Arudino platform.

The first order of business was to determine which of the many shields/modules I wanted to use. Frankly, I didn’t spend enough time on this phase. I found some guy that built basically what I wanted to emulated his selections. In the end I think I would of chosen a few different solutions, but the solution I came up with meets the needs. You can see the list of parts at the end of this article.

For this project there are 5 major parts: Arduino, pH meter, Temperature meter, a real-time clock, and the display. I opted against any switches or input devices. Largely because I didn’t think the project through, but it all worked out. Now that the project is complete, I realize I didn’t need the RTC; showing the date or time is superflous, and only lead to a larger LCD to accomodate the date and time.

The Arduino was easy; I had one laying around, but I decided to order a new Uno just so I would have the latest HW and also a backup should something go wrong (which it always does). I order the same pH sensor, RTC, and temperature sensor from the project I found on the web. Then I started looking into LCDs. Based on my calculations, needed a 20×4 LCD and I wanted a backlight. The 4 line LCD drove the cost up a bit – I probably could of shaved $10 off by using a 20×2.

After about 4 hours of surfing, I had ordered all the parts. Well, almost all – things do change after all. The biggest thing I overlooked during the initial planning was the enclosure. I did remember to order a box when I was ordering some of the other parts, but didn’t really consider how everything would be mounted, or really if everything would fit. I only looked at the size of the LCD and guessitmated the depth necessary and ordered the first inexpensive enclosure I found on Jameco’s website. Although it was not a bad choice, it did cause some extra headaches during the final construction phase.

Will all the parts ordered, I began writing the SW. Using the data sheets, libraries from other similar projects, and examples from the web, I built the shell of the program in about 2 hours. Not bad.

As the parts arrived, I began integrating them. First was the LCD. It took about 15 minutes to get it up and running. No joke. It took longer to solder the wires to the part than it did to get it work. My “sample” code worked the first time without any problems. Hey, this is easy…or not.

I then moved on to the pH probe. Initially I had quick success. My draft needed some tweaking to work properly but then started returning results. Easy. Then not so much. Every attempt I tried to optimize the code and error proof it lead to failures. The sample code on the manufacturer’s website was a little broken and I really wanted to harden it. But every attempt to arrange the code and do something “sane” with it lead to errors and failure. It took about 4-6 hours to finally get the pH probe working properly and have a resilient module that was relatively graceful in the face of errors and issues. Looking back, although it was frustrating and maddening, half a day’s working time is really not too bad.

After the pH probe was complete, I moved on to the temperate sensor. I wanted to tackle that last as it was the most “DIY”, but my RTC module had not arrived yet. So I followed a tutorial I found on the web to wire up the probe read samples. I “worked” the first time. Then I noticed the temperature was nearly accurate, but fluctuating by 2-4 degrees over the course of *every* sample. I sampled every second and got, well, various results. All the results were close to the actually temperate, but I wasn’t expecting such a wild variation in samples.

Well, it’s analog and that’s to be expected in a prototype environment. The signal is not clean and it’s likely noise. So I implemented an averaging system where I only reported the average of 5 samples. Then I upped it to 10 samples for more stability. The reported temperature still changed every sample, but the variance was closer to 1 to 1.5 degrees between samples instead of 2-4 degrees. It was getting late and I felt I could live with the results. I tossed and turned all night wondering why the signal was so jittery. Surely the analog input had more to offer than essentially 0.5V ripple for every sample?

After a few hours spent trying to get my digital oscope working, which ended in failure, I spend a few hours Googling for possible answers. I never found the magic bullet, but I found *a lot* of people with stable readings with millivolt variances over minutes if not hours. Now I was mad. Surely something is wrong with my systems. Even more pissed my oscope wasn’t working and I had no insight into the analog signal. If I could just see the signal I would know if it was noise, or some dorky code, or some thing else.

Turns out it was a little of all of them. After many attempts to use a different reference voltage I made the startling discovery that I failed to call init on the temp probe module. As such, the analog pin was never set to “input”. Since the analogRead function should do that, no worries. However, the code to set the reference voltage is in the init routine and was never being set. As such, the external reference voltage was being ignored. After calling init I started seeing rock solid samples. Then I wired a solid reference voltage from the 3.3V pin of the Arudino and everything fell into place. Now I see less than a millivolt ripple across samples. At last, success.

Now, if I just had my RTC module I could wrap this project up. Only about 8 hours invested so far. Not bad. After a few days of waiting, I got bored and decided a PCB would be easier to wire things up. So I spent an evening drawing up parts and designing a simple single-sided PCB. I spent the following evening making the PCB, and the following evening testing it.

After first plugging the PCB in everything worked perfectly. Then I moved something, not sure what, and the pH probe stopped working. After an hour of farting around, no luck. I took the PCB out of the equation and returned the whole system to the series of wires and breadboard. No luck. The pH module was dead. Or so I thought. The module has some status LEDs and they were on. Sometimes they flashed. That signaled to me the module was working in some way. So I switch the TX/RX pins in the software and moved the pins on the Arudino. It was ALIVE (again). Whew. Didn’t want to drop another $25 bucks for a pH module. But it looks like the Arudion pins I was using are fried. Crap. Just bought the Uno and it lasted exactly 5 days before getting partially fried. Well, such is life I guess.

We now into calendar day 7 after receiving the first set of parts, which was calendar day 12 of the process. WTF – where is my RTC module? So I emailed the company. “Can I please have a tracking number so I can figure out where my part is?”. A day went by. Then 2. Then 3. Now I’m pissed. Just as I was pondering my not-so-nice follow up email I received a response:

Your order was shipped by standard post from our Asia distribution center
Thailand on July 14th via HongKong Post as per your online shipping method
Tracking number is unavailable on the shipment.

The package will reach you shortly.

For your information, Standard Post does not have any tracking information;
therefore, we are unable to advise you on the exact transit point of your

Asia? WTF? So all those jokes about the slow boat from China I made where accurate. Ok. I wait then.

3 more days go by and viola – the package arrives. I open it and find the module and a R/W CD with the handwritten word “mini” on it (or something close to that – the hand writing was not too legible). I’m guessing the CD has some source code or the product manual or something for the part. But I don’t know. And I will never know. The last thing I’m going to do is put a CD from China into my computer. Now since I have a Mac I may be better protected, but I’m not going to find out.

Like the LCD it took about 15 minutes to get the RTC working, and about an hour to tune it to my desires. The next day I spend another hour or so adding an input routine to set the time.

So after 12 working hours spread across 2 weeks I have a fully functional system. Now I need to finish the code and make it solid. First order of business is to use interrupts to update the LCD every second and to sample the pH and Temperature consistently. I’ll spare you the details, but I never got the interrupts working the way I wanted. The temperate sampling code requires some delays to get an accurate sample and the delay routine relies on interrupts. So that means you can use delay within an interrupt. I have a lead on a better approach, but haven’t had time to implement it. Largely because I’m writing this instead of coding.

Where does this story end? I guess I could keep tweaking the code forever, but I’m drawing the line. I spend a few hours shoehorning the hardware into the box I got, which was no small feat, and I’m moving on. Once I get a couple connectors in the mail the project will be complete. I’ll post pictures when I get a chance.

Parts List
* Arduino Uno
* pH Stamp
* pH Probe
* RTC Module
* LM34
* Enclosure
* BNC Connector
* Power Supply
* Stand Offs
* 4x40x1/2″ flat head screws
Total Cost: $124.08 ($160.88 with shipping and tax)

Link to Products, Information, and Vendors
* Sparkfun
* Using Temperature Sensor
* Using pH Stamp
* Using DS1307 RTC