# My Raspberry pi DIY aquarium controller



## abrous3d (Nov 27, 2014)

Hello to all DIYers of this forum.

This is my first post in "Planted Tank" although I am following your conversations for a long time. 
I'd like to present an open aquarium controller I am working on for some time. 
The controller is based on a Raspberry pi B+ and a custom PCB.











It is designed to be completely WEB based. The controller provides the following characteristics :

- Lights controller : 3 channels PWM with configurable output levels + 3 relay switches. The light controller is driven by 3 programmable arbitrary waveform generators and a time scheduler so sunrise/sunset, peak hours and moonlight effects can be easily programmed. 
The scheduler gets information from a .ini style file. Among others this file contains the scheduler section. This section looks like this:

[Lights]
A1=10:30,0
A2=11:00,50
A3=13:00,50
A4=13:30,100 

B1=10:00,0
B2=10:10,10
B3=10:30,10

...etc

Every channel currently supports up to 16 points per day. Between points the controller ramps up or down linearly. 

- High quality instrument grade pH sensor 20bit interface with automatic temperature compensation.

- CO2 controller with programmable set point, hysteresis, alarm points etc

- High quality RTD (pt100) 20 bit temperature sensor.

- Temperature controller with programmable set point,hysteresis,alarm points etc and separate outputs for heaters and coolers/fans etc.

- on board RTC (DS1307) with battery backup (in the case of internet connection failure).

- Three (3) auxiliary 20bit differential analog inputs for other sensors (TDS, pressure, level etc )

- Two One-Wire interface conectors wit 3/5V interface. I am currently using one of them to interface an AM2302 Temperature/humidity sensor.

- i2c and I/O expansion connector for future upgrades like more pwm channels,extra i/o etc.

- On board buzzer for alarms.

- Mysql database logging.

The main controller app is programmed in plain ansi C. It is still under development but it is fully operational. What is missing is the WEB part.
I abanoned my initial idea to base the web part on Apache/PHP server and I am currently working on a NodeJS version. Since my experience in web programming is limited, this is gonna take some time  
I was hopping to find people willing to contribute in coding but I am still working on it alone.
Currently I am using the .ini file to configure the controller. You can download the current snapshot of the code from my GIT repository here. 

The hardware part of the controller is based on a custom board called piAquarium shield. 

You can download the pcb files from my piAquarium site here. I admire that it's assembly is not for the fainthearted but I am sure that many people here are able to build it successfully.

Feel free to comment.


----------



## Linwood (Jun 19, 2014)

Do you have information on the sensors used? 

I did a light controller (for the LED+) but when I started shopping for sensors, other than temperature, they seemed ridiculously expensive. 

I tried a flow meter (to monitor my filter), and the inexpensive flow meters added huge resistance, dropped flow in half from the meter.

I did see some decent level meters to track water level. 

But I'd love to track other parameters, if there are relatively inexpensive ways.


----------



## abrous3d (Nov 27, 2014)

Linwood said:


> Do you have information on the sensors used?
> 
> I did a light controller (for the LED+) but when I started shopping for sensors, other than temperature, they seemed ridiculously expensive.
> 
> ...


I have no experience with flow sensors, I've never used any. 
For temperature sensing I use DIY RTDs (pt100). You can buy the row sensor from Mouser. It is something like this (http://gr.mouser.com/ProductDetail/...Mks3Lma1jF4OGiZKD38meqWKFD5CFglVglCqx4XlXXg==) or this (http://gr.mouser.com/ProductDetail/...s3Lma1jF4OGiZKD38me081Qzq7%2bgY1ZZgKZonGX4A==). It is fairly easy to impregnate and wire them like this :










For pH Sybon Scientific will do if you want a cheap solution (http://fish.aquaristic.net/Sybon-Scientific-pH-Electrode-standard-grade.html). 
For level metering a pressure sensor is the cheapest solution. See the TI paper here. Probably I'll add this feature to piAquarium sometime soon.
Another interesting sensor I support in piAquarium (although not directly related with the tank itself - but a nice addition for those interested to monitor the surrounding environment as well) is the environmental AM2302[/url] (Temperature/Humidity). It is dirt cheap (~4 Euro) and impressively accurate. It is available through Amazon.


----------



## Linwood (Jun 19, 2014)

Thank you. That ph sensor is much closer to what I had in mind. I tried to find some specs on it, and can't, but will keep looking. Yes I want cheap, but would like to know how accurate it is also. 

For level sensing, this is one thing I found that was intriguing, also a bit pricey though: 

http://www.adafruit.com/product/464

Not sure I'd drive a top-off system with it (at least without a double check for safety), but an interesting thing to use to monitor evaporation rates, especially if you had the ambient humidity/temp as you mention with that last sensor.

Have you ever seen affordable sensors for other water parameters, like nitrates especially?


----------



## robsworld78 (Aug 14, 2014)

Here's another cheap PH probe. I have 2 arriving today or tomorrow, just need a stamp now to get it working.

http://www.banggood.com/PH-Electrode-Probe-BNC-Connector-for-Aquarium-PH-Control-Meter-Sensor-p-912723.html


----------



## mistergreen (Dec 9, 2006)

Linwood said:


> I tried a flow meter (to monitor my filter), and the inexpensive flow meters added huge resistance, dropped flow in half from the meter.


Yeah, I hope they make a cheap non mechanical flow sensor sometime. There are ones using light or ultrasound which is awesome because it doesn't restrict flow but they're hundreds of dollars.


----------



## jmelvin (Aug 11, 2014)

I have a question about the pH probe you are using. My controller is web based as well using html5 with 11 inputs accepting 0-5v, 0-10, 10k out 4-20ma. Does the probe you are using use any of those types of inputs? I will go deeper into my setup in another post when it's done. Thanks

Edit: Flowline makes great level sensors and +GF+ George Fisher makes a wide variety of flow meters along with pH, temp, ORP, alkalinity, acidity. Granted they are rather expensive but you get what you pay for. Lol

Sent from my Tweaked N3.


----------



## abrous3d (Nov 27, 2014)

This is my very first attempt with the web interface. I abandoned the traditional Apache/PHP approach in favor of Node.JS. My knowledge for both is very basic so it does not make any difference. The interface is ugly and limited in terms of functionality but I'll improve it.


----------



## abrous3d (Nov 27, 2014)

jmelvin said:


> I have a question about the pH probe you are using. My controller is web based as well using html5 with 11 inputs accepting 0-5v, 0-10, 10k out 4-20ma. Does the probe you are using use any of those types of inputs? I will go deeper into my setup in another post when it's done. Thanks
> 
> Edit: Flowline makes great level sensors and +GF+ George Fisher makes a wide variety of flow meters along with pH, temp, ORP, alkalinity, acidity. Granted they are rather expensive but you get what you pay for. Lol
> 
> Sent from my Tweaked N3.


I am using a native pH electrode. pH electrodes have extremely high output resistance in the GigaOhm range so in order to interface them with any type of A/D you have to use an op-amp as buffer. This op-amp must have input bias in the range of fA like the one I am using in my circuit. This is necessary to keep biasing errors low.
If you don't want to mess with ic's and pcb stuff probably this is what you are looking for (http://atlas-scientific.com/product_pages/components/raspberry_pi.html and http://atlas-scientific.com/product_pages/circuits/ezo_ph.html).


----------



## ichristos (Aug 25, 2014)

Γεια σου φιλέ
I am using an arduino controller for lights, co2, dosing pumps and I was thinking about a pH probe. Is it possible to have the probe in the water 24/7 or you put it in the water occasionally? Also how do you maintain that and what's its life expectency? (PH probe)

Ευχαριστώ


----------



## abrous3d (Nov 27, 2014)

ichristos said:


> Γεια σου φιλέ
> I am using an arduino controller for lights, co2, dosing pumps and I was thinking about a pH probe. Is it possible to have the probe in the water 24/7 or you put it in the water occasionally? Also how do you maintain that and what's its life expectency? (PH probe)
> 
> Ευχαριστώ


Γεια σου,

pH probes are designed to stay submersed 24/7. With the proper maintenance and re-calibration they can operate for many years. To maintain your probes you need a pH probe cleaning solution and a pH probe maintenance solution. 
To interface such an electrode with your arduino you need a pH board interface like the one listed in one of my previous posts.


----------



## saiko (Mar 30, 2007)

Not every pH probe can be submerged 24/7. The electrolyte in them can spoil soon. The test/lab ones are the cheaper ones, used to measure a sample and store. 

There is a whole different line for measuring 24/7, seen them mentioned as online-meter probes.


That apart, yours is a very interesting build coming up! Will be waiting for more.


----------



## abrous3d (Nov 27, 2014)

saiko said:


> Not every pH probe can be submerged 24/7. The electrolyte in them can spoil soon. The test/lab ones are the cheaper ones, used to measure a sample and store.
> 
> There is a whole different line for measuring 24/7, seen them mentioned as online-meter probes.


That's true for special purpose electrodes like soil, foodcare, meat etc. General purpose glass or plastic electrodes are usually ok but in any case is good to check the datasheet. 
I prefer Hanna Instruments or American Marine electrodes but a year ago I tried a cheap Sybon Scientific Instruments and I must say that it rocks for its price (22 Euro).


----------



## wijnands (Aug 13, 2012)

extremely interesting this!


----------

