After much fiddling about, I’ve finally got my remote data logger for the ReefKeeper 2 running well. You may have noticed the Tank Status widget to the right recently. It shows my current temperature, pH, and power channel status on the RK2, pretty much in real time. Clicking on the widget takes you to the historical graph page where you can view history on various time scales. This is still very much under development (currently working on optional channel graphing) but it’s already pretty neat!
Read on for the gory details on how I put this together…
The Problem
As of firmware version 2.2, the RK2 will log the current temperature, pH, and channel status via serial. I was very excited at this prospect when it was first announced. Dreams of logging my tank to the web server (or even controlling it!) swam (hee!) through my imagination. Digital Aquatics eventually provided a small Windows app to receive this data, log it, and draw nice little graphs… but there were several things that bummed me out with how this worked:
1. The app is Windows only.
2. The app provided no way to send data to a remote machine, or upload graphs/data in an automated way.
3. The graphing app is fairly primitive (though DA promises they have something really neat in store soon)
4. Because of some nasty back-stabbing competition, DA is reluctant to provide any information or documentation on how any of this works.
5. Even if I do get a windows box connected, I don’t want to leave it running all the time to collect data.
6. The app is Windows only!!
Obviously this just would not do. So, I figured out the serial pin out, the data format, and came up with my own solution. Overall, I’m very, very happy with what I ended up with. I wish the RK2 would do more via the serial port (wave status, night mode, standby mode, power loss detection, configuration/control via serial…etc) but just being able to look at whats going on in my tank from anywhere is super-cool. I’m sure as DA adds more functionality to the serial communications, I’ll be able to expand what my own solution can do.
Reading the serial port

The serial pin out wasn’t difficult. The RK2 came with a little serial adapter for upgrading the firmware, and it was just a matter of looking at the example to make the required splitter and cabling for simultaneous use of the temp probe and serial port. Nothing exciting yet!
BTW– The serial settings are 115200/8/n/1 with no flow control in case anyone else out there is trying to figure that out. The unit basically spits out a string once a second that looks something like this:
AAAB CCDD EE
AAA = Integer part of the temperature.
B = Float part of the temperature.
CC = Integer part of the pH.
DD = Float part of the pH.
EE = Single byte hex string (high nybble first) representing the channel status.
Getting the data on-net
So, this was the tough part. The RK2 has no built-in network capability, and my tank is nowhere near a place where I could plug it into wired Ethernet. I had to somehow read the data on the serial port and get it on my home network via wireless. At first, I thought I’d build a little BSD or Linux host out of a Soekris chassis or similar, have it read the serial port and send the data somewhere. This turned out to be fairly expensive, probably $300-$400 in parts. Sure, I could have done it cheaper with some old PC hardware, but I really wanted this to fit nicely under the tank, be invisible, and silent.
After a little digging around, I ended up with a WiBox by Lantronix. This nifty little device is made for just this sort of application. It has two serial ports and can act either as a serial terminal server (inbound connections), or it can pack up serial data and send it to a remote host via a UDP or TCP connection. It’s small, supports 802.11g wireless, WEP, WPA, uses very little power, and retails for around $200. Still a bit pricey, but my marine fish tank hobby is not about cheap! ;)
Filling in the gaps
So, now I had my data bouncing off my web server and into the bit bucket on the other end of the Inter-tubes. Time to do something cool with it. I had to write three bits of code to get this all working together.
RK2D: First up was a little TCP listener written in Perl::POE. It basically just accepts the TCP connections from the WiBox, filters out the duplicates (sucker logs every second!) ans stuffs it into a MySQL table. It’s really quite simple… probably only 30 lines long. It took a whole hour to learn Server::TCP in POE and write the little daemon.
Tank Status Widget: This was fun. It basically just reads the newest table entry and displays the current temp, pH, and channel status. The neat part is that it is accurate up to the second, as the RK2 logs so damn often. I took several pictures of my RK2 in the dark to try to get the look and feel down. I drew the graphics in Xara based on these photos.
Graphing: The graphing page took a bit of fiddling. For the actual charts, I used some freebie flash-based package called amChart, only because I liked the way it looked and it would allow me to display multiple axes. (Yes, I should be shot for using flash… I’m sorry) Oh yeah, and it was free. The biggest challenge here was sifting through the huge amount of data. Even tossing dups, I’m getting over 6000 log entries per day. Trying to graph that much over several days proved impractical (PHP is slooooow) and I ended up having to aggregate and average into regular time slices.
I’ll be working on expanding this over the next few weeks. I’d like the channel graphing to be more flexible. At the moment, I just have two channels hard-coded for my lights. Shouldn’t be too hard to make each channel a config option in the WP widget to control whether a channel is graphed, its color, and if it starts hidden or not.
Stay tuned!
Tags: Gadgets, ReefKeeper

Internet fish geek!
You know you want this too.
…
yeah
Dude, seriously, how is this project coming along? any plans to integrate some new features in the new firmware update??
J,
It’s working rather well! I’ve added arbitrary graphing of channels, and it’s all controlled through the WP widgets. You can click on the little RK2 image to get to the graphs, or:
http://reef.pantshead.com/rk2/
I think I’m pulling everything that the current firmware (version 2.4) provides… what new features are you referring to?
EP,
Fricking awesome, your kung fu is strong. WP integration, custom daemon, pretty graphics for the Wp widgets.. EXCELLENT!!! Great job man. About the new firmware and features, I didn’t see the post date on this until way after, for some reason I thought it was an old post which is why I mentioned the new firmware. I retract my previous question ;)
Very interesting app configuration, any recent progress? Do you have any plans to make it available?
Perhaps. It’s very specific to operating with the Lantronix box at the moment, so I’m not sure how many folks would find it useful. The only real problem I’ve run into is the reliability of my ISP. :P
Eggplant
Do you think you could perhaps send me the widget app? I’m going to get my RK2 hopefully soon and get to work with a cheap wi-fi adaptor and see if I can make it work. My understanding is that the part I need to get to work is the TCP port listner.
Thanks!
Wow, this is AWESOME! I WISH I had access to your RK2D TCP listener! Then I could use PHP/MySQL to do all the fun stuff I want to do on my web page. Any way I can get you to share? :) Ryan
i have a laptop that i’m not using that is strictly for my RK2 and it’s also plugged in to my internet wireless modem with an ethernet cable. the rk2 is plugged into this computer with a USB to serial adapter. how can i access this laptop with the RK2 through another laptop so that I can view the status of my tank when i’m away?
Victor,
The folks at Digital Aquatics provide the MyReef application. This can run a small web server so you can look at your RK2 stats remotely. I imagine all you would need to do beyond setting up MyReef would be to forward port 80 through your home device to the laptop.
There are probably tons of folks on the Digital Aquatics forums that have done the same thing:
http://reefcentral.com/forums/forumdisplay.php?s=&forumid=329
[...] is neat. I rigged up my own network connectivity for the RK2 a while back. That basically just reported temp, pH, and channel status for me. This looks like a [...]