Cali Kid Corals

Raspberry Pi/Reef Angel Aquarium Controller

Hey guys. I thought I'd share a project I've been working on. This is going to be super nerdy. Consider yourself warned. :)

For a long time now I've thought it would be fun to build my own aquarium controller. I'm pretty sure I can get the software end working, and I have some experience with electronics, but building everything from scratch (especially analog stuff like pH probe inputs) and packaging it nicely was daunting enough that I never did it. Recently I took a look at the Reef Angel stuff and the openness of it seemed really awesome. All the source code is there, and even the schematics are published on the website.

I've also been wanting to do something with the Raspberry Pi. If you aren't familiar with it, the Raspberry Pi is a credit card sized single board compter. It has a 300Mhz CPU, 512MB of RAM, USB, Ethernet, a GPU, HDMI, and audio ... all for just $35. So, you probably see where I'm going here. I thought it would be fun to try hooking up the Pi to reef angel hardware. I spent some time studying the schematics and found that most of the reef angel hardware connects using an i2c bus. i2c is a very common standard in electronics for connecting all sorts of components. In fact, that raspberry pi has i2c built in and comes with linux drivers for it!
The reef angel hardware uses USB cables (mini connectors upstream and USB-A connectors downstream) but it's actually i2c rather than USB.

The second interesting feature of the reef angel is the connection between the relay box and the head unit. This is a DB-25 connector like you would use for an SVGA monitor. This cable caries i2c, but also includes wires to control each relay. I can drive the relays either using output pins on the pi, or by using i2c and the reef angel relay box expansion module.

Next up I'll post some photos showing where I'm at with it and what I'm doing on the software side. Big shout out to Roberto for making such awesome hardware and making it an open platform so nerds like me can tinker with it.
 
Okay here's the basic hardware I started with. The ReefAngel relay box, IO module, relay expansion module, and hub. And of coure, the Raspberry Pi.
9430444845_40a6340acf_c.jpg


It wasn't long before I had a mess on my hands:
9430445919_e8d2ffa063_c.jpg

But here it is basically all hooked up. I also got an i2c LCD display kit from adafruit. It's able to connect to the ReefAngel expansion hub just like everything else!
9430447789_9d111f5fd0_c.jpg
 
In terms of software, I wanted to start with a web app so I could do everything on either my laptop, tablet, or phone. I decided to do the server software in python (PHP... never again!). I'm using tornado, which is python web framework that makes it super easy to set up a server that can reply to requests from a browser. In the frontend I'm using jquery and jquery UI along with WebSockets, which allows the browser to keep a live connection open to the server so it can update when new data comes in from the controller. So far I have it working enough that I can set up a basic timer, click buttons to turn relays on and off, etc. but nothing very pretty or worth showing off just yet. That's about it for now! I'll try to update this thread as the project progresses.
 
very very VERY cool! Raspberry pi's are quite powerful for such a small package. They will only be getting smaller too. Can't wait to see more on this.
 
Sweet! I wish the picture links worked. Warning: RasberryPi I/O are NOT 5V tolerant. A lot of the I2C peripherals will use a 5V pullup. Not sure about ReefAngel. Look into using "Xively." It is a great way for a microcontroller to "push" data to the cloud. So you can see it remotely without port forwarding your firewall.
 
Thanks, guys! Good point about the 5v thing, Mark. Maybe that's a good reason to stick with the other setup the pi only talks to the relay expansion module. I think I fixed the picture links. Are they working now?
 
Pictures are working now.
I2C should be fine, even if 5V pullups. Not enough current to do real damage. Something like 2mA in. Just be careful of SPI or others that really drive in.
I can tell it will work - you have a real soldering iron
Silly thought : You could get a Gertboard (Raspi interface board), which is atmel based, then port the reef angel code to it..... :)
Curious though: Why a small LCD display, instead of a full on VGA? Raspi has the capability, and it would be impressive graphics
 
The LCD is a quick and easy way to provide some status information and requires very little work to get up and running. I don't plan to make it the interface through which you use the controller, though. I could write a full linux GUI app, but that would be a lot of work (and is what I do for a day job). I'm also not sure I could get a touch interface working well and I don't want a button or joystick based interface. It seems like a better way to get a great interface is to push it off to a separate device. An LCD on the Raspi would be cool, but it's not going to be able to compete with, say, a Retina iPad. So, I decided to focus on the client/server architecture and web frontend first. Next, if I still feel motivated, I might write a native iOS frontend. Later on I could upgrade to vga and write an OpenGL app if I want to make the status display slicker.
 
Hmm, what you really need to do is take advantage of the H.264 encode capability on the Raspi. Meaning, HD video streaming of your tank!!
Heck, you are doing an iOS app anyway, what is a little bit of extra tweaking.
:)
Actually, your plan makes a lot of sense. I just look at my little screen for temp and error messages, but then look online for detailed data logging. Very handy for reducing worry when on vacation as well.
 
This is really cool! I have been meaning to work on a project with similar goals but work has kept me busy such that I have had little time other than for basic maintenance of my tanks.

I will definitely follow this thread with interest!
 
Hey Erin, I have a spare Gertboard (IIRC) if you're interested. There was an ordering mixup and I somehow got two (paid for both of them) and I've been meaning to offload it if someone needed it on BAR. I've been meaning to go further on my RPi than just setting the OS up and toying with it but have been recently preoccupied with the forum. :)
 
I've made some progress on this project. I switched to using i2c to drive the relay module, rather than the 15 pin connector. That allowed to really streamline the hardware. I cut a hole in the enclosure and attached a USB jack for connecting to the reef angel. I also wired in the temperature sensor and used some ICGel to secure it.

Denzil, thanks for the gertboard offer but I think I'm good for now. I'm going to try and keep the hardware simple and really focus on the software.

8D625B30-49B4-4410-A445-F1AFD9B9B330-4275-000003725AA7BA4F_zpsb950f069.jpg~original

3203E7C2-DA9E-443D-9AD9-0E34584F9E5D-4275-0000037206E39F7D_zpsf67c0d9b.jpg~original
2013-08-10104938_zps6b9824ff.jpg~original
 
On the software front I've made some progress, too. The basic architecture is that there are "devices", which talk to physical hardware. Devices can have "variables" which are either inputs (read from the hardware), outputs (write to the hardware), or options (configure the behavior of the hardware).

Then there are also rules, which have connections to variables. The rules run periodically to read from the connected inputs and write to the connected outputs.

Anyway, here's the device page, where you can configure device options and switch outlets on and off. It keeps in sync with the pi so when something changes you instantly see it reflected there.

ScreenShot_zps54dfc211.jpg~original


I also have a status page kind of working where you can drag widgets around on a grid. I'm thinking of having various types of widgets, from a simple temperature readouts to full interactive graphs.

I have rules working on the server side, but there's no UI for them yet. Still lots to do!
 
FANCY!
In fact a bit too clean. I bet a bunch of nice duct tape would cover that bit of temp sensor wire that is sticking out,
and just give it that better look. :p
Advice though: You might want to stress test the I2C for reliability. It is not uncommon
to have issues, especially with all the wiring and questionable grounding.
Are there registers in the I/O expander? You could read/write those non stop for a day, and see if there are
any errors.
 
Back
Top