# Arduino Tank Controller



## Sinchlid (Mar 23, 2013)

*Fish Tank Controller*
(lighting and heater)​
This controller uses an arduino nano with a LCD display to control the lighting and heating of my 36 gallon tank.









My T8 flourescent 20 watt single bulb light always seemed barely adequate and it is now faulty. 
Perfect excuse to upgrade to LEDs. Building your own is funner and cheaper!









The flourescent tubes and other parts were removed from the light hood. The power wire and switch were left alone.
6 LEDs (2 x Cool White, 2 x Natural White and 2 x Growlight) were wired in series and hot glued to a strip of aluminum.
(in case your wondering, 6 watts of LEDs doesnt even get the aluminum warm)
The LED wires were then connected to the switch and power cord. The cord was then cut on the plug end.
This cord will eventually be plugged into the controller.
This setup produces alot more light at less than 1/3 of the power!
Also have to mention... its DIMMABLE! The LEDs are driven by a Meanwell LDD-350L.
I picked this driver because it takes PWM signal from arduino to dim the output and it is 97% efficient!









The arduino nano is tiny but easy to work with. Pretty much any board from the arduino line-up will work.
The code i wrote can be customized and all settings can be edited.

The time is controlled by a DS3231 realtime clock. It has battery incase the power goes out.
The current day and current time are displayed on the LCD screen.
The current time is also displayed as a scale moving left to right with the on/off times shown as "O" on the scale.
The icon scrolls smoothly along the scale as time changes.









On/Off or Sunset and Sunrise time values are read and the LEDs are adjusted.
It takes about 15 minutes to go from 0% to 100% and visa versa. (the speed can be changed of course)
The LED brightness is displayed on the LCD screen as a scale going from left to right.
The icon scrolls smoothly along the scale as the brightness value changes.
A "cloudy day" feature can be added which could limit or even gently fluctuate the lighting randomly.

A DS18B20 digital waterproof thermometer is constantly monitoring the water temperature in the tank.
The LCD screen displays the minimum temperature, current temp and maximum temp. 
The min and max values reset when the power is reset.
(i built a version of this that logs the time & temp onto a SD card so it can be loaded in EXCEL and graphed)
A relay is connected to the tank heater. Its main purpose is to kill the power when it gets too hot in the tank.
My tank heater is at the minimum setting but in the summer my tank would rise past 30C regularly. 
The heater seems to turn on whenever it wants so this will turn off the power to the heater if it reaches 28C and back on when it dips to 25C.
For the most part the heater should self-regulate so this is an extra layer of protection.
The LCD also displays the heater status and how many times it has turned on.









The LCD itself is a 20x4 I2C display and it cycles through the relay and temperature info.
The LCD turns off the backlight after 40 seconds... unless movement is detected.
Mounted into the door of my tank stand beside the LCD display is a PIR motion sensor.
The PIR motion sensor "wakes" up the LCD and also cycles through the displays (instead of using a button).

I already have home-made LEDs in my 120 gallon tank but they are only attached to a simple timer which is fine but after making this...
That tank will soon have 5 dimming channels. 3 x cool white 20 watt LEDs will be on seperate dimmers so i can get the effect of a cloud moving.
The other 2 channels will be for 10 x Grow LEDs and also 10 x Blue LEDs (for moonlight effects).
I have a 3.5" full colour TFT touchscreen for this next build already ordered and on its way 

If this sounds interesting to you and would like to have me make one for you let me know.
Im open to suggestions and this platform is very versatile, expandable and parts are cheap.
If you want to tackle making one yourself, maybe i can give suggestions.


----------



## The Guy (Nov 26, 2010)

Interesting project, is this a kit that can purchased or are all the components separate and have to be electronics guru to build it.  LOL!


----------



## Sinchlid (Mar 23, 2013)

This is not a kit. There are only 6 components (not including the individual LEDs).
The most expensive part is only about $8. The whole build cost less than $50.
You dont have to be an electronics guru. Chuimanfu wrote up a wonderful tutorial and there is more & more info on the web.
We used similar parts but handled the coding of the controller differently.
You wouldnt have to write any code yourself. just download and install on the arduino.

If you know that the red wire is positive and the black is negative, your 90% of they way there 
The only thing that would be intimidating for some would be the soldering if you've never done if before. (its really easy)

If you want to have something like this for you tank, I can step you through building it and even do the soldering for you


----------



## TomC (Apr 21, 2010)

If somebody was intending to build one, this would make an interesting demonstration for a VAHS meeting. It could just be a partial build if it takes too long. With a $50 dollar price tag, it could even be raffled off. (As long as somebody contributed free labour.)


----------



## Sinchlid (Mar 23, 2013)

I've never been to a VAHS meeting but i'd be willing to tag along with you TomC and give a demonstration.
$50 for a controller seems a bit much if it was simply to have the dimming effect but my alternative was to buy a new ballast (cost around $20) or entire flourescent tank light hood to replace my dead one which would cost the same if not more.
The $50 included the LEDs anyways and i have lots left over 
I have more arduino controllers already that i intend to use for other projects but a tank controller similar to mine can be built in several hours if i have the parts.
The reason you wouldnt find a "kit" is because of the variety of LEDs that could be used. 
I'm using 1 watt LEDs that draw 350 mA but my other tank has 20 watt LEDs that draw 700 mA. The only thing different would be the LED driver or quantity of them used (they cost the same anyways).

Im getting my parts from ALIEXPRESS.com. Its very cheap (cheapest source?) for electronic parts and if you dont mind waiting the 3-5 weeks for free delivery then you'll find it a half if not a third of the price parts sourced from Amazon!

So if you have a barely adequate or crappy light and want to upgrade to LEDs - shoot me a msg.

If anyone want some 24" 20 Watt T8 flourescent tubes... lemme know, the bulbs are still fine and you can have them free


----------



## Sinchlid (Mar 23, 2013)

Well i actually did the math on the cost and i over-estimated.

Parts List:

Arduino nano: 2.89
https://www.aliexpress.com/item/Fre...id=22c7b393-1499-4601-8f76-e34f67475ec4&tpp=1

Nano proto-shield: 1.40 (optional)
https://www.aliexpress.com/item/For.../1790691337.html?spm=2114.13010608.0.0.AcNki8

Realtime Clock DS3231: 0.67
https://www.aliexpress.com/item/Fre...lt&btsid=85de8f8a-4652-4732-bd29-438833676166

PIR motion sensor: 1.08
https://www.aliexpress.com/item/SR5.../2035773471.html?spm=2114.13010608.0.0.uk5dCb

PCB circuit board: 0.21
https://www.aliexpress.com/item/10P...32375369883.html?spm=2114.13010608.0.0.uk5dCb

Booster puck: 0.60
https://www.aliexpress.com/item/MT36...608.0.0.IBqPxy

20x4 LCD: 5.48
https://www.aliexpress.com/item/Sma...32315496335.html?spm=2114.13010608.0.0.u47ODx

DS18B20 temp sensor: 1.32
https://www.aliexpress.com/item/1pc.../1622159040.html?spm=2114.13010608.0.0.u47ODx

LDD-350L LED driver: 7.40 (listed cheaper but no free shipping for some reason)
https://www.aliexpress.com/item/Sum...32703645683.html?spm=2114.13010608.0.0.n9rj49

Connectors: ~1.25
https://www.aliexpress.com/item/SZS...32348142348.html?spm=2114.13010608.0.0.ViO2n3
https://www.aliexpress.com/item/Pro...32559912979.html?spm=2114.13010608.0.0.HyCCwG

TOTAL: about $23.00

The LEDS were about 1.80 for 10.
So even cheaper than i initially thought.


----------



## Gardener (Feb 13, 2011)

Hi Sinchlid, would you be willing to share your schematic and code? What exactly is the booster puck - can't find it on aliexpress.com.


----------



## Sinchlid (Mar 23, 2013)

Gardener said:


> Hi Sinchlid, would you be willing to share your schematic and code? What exactly is the booster puck - can't find it on aliexpress.com.


I added links in the earlier post to the parts that i used. There are lots of vendors that carry the same parts so you may be able to get them cheaper.

I cant figure out how to include the code into this post... anyone help me out?
PM me your email address and I'll forward it to you that way.
Also, Chiuman has his code posted in this thread:
http://www.bcaquaria.com/forum/equi...quarium-controller-have-any-you-tried-127057/

The puck is basically a step up (Boost) or step down (Buck) module... sorry, i used the slang. Buck puck... get it... anyways....
The one i had is a step up "booster". There are other versions that can handle more amps or a larger swing in voltages.
I'd recommend getting 2 or 3 and grab some step down modules while your at it. They're cheap and can really come in handy.
https://www.aliexpress.com/item/MT3...32675986912.html?spm=2114.13010608.0.0.IBqPxy








*The GND and SIG (DIM) are male pins that i soldered onto the board. (5V not used)
These pins are then connected to the arduino GND pin and the PWM pin (Digital pin 3 in my case) 








My nano is mounted on this expansion board... was just going to use it to prototype but it cost 1.40 so i'll leave it and just order another 
https://www.aliexpress.com/item/For.../1790691337.html?spm=2114.13010608.0.0.AcNki8

Sorry about the hand drawn schematic... 
*the arduino is running on 15V which is higher than whats normally recommended but it can handle it. 
I'm using 15V because i found a wall adapter that put out 15V @ 2 amps. 
Its usually best to get a power supply that meets or exceeds the LEDs voltage needs and then lower the voltage with a puck for the arduino.
But really it could be done with pretty much any voltage and those step up/step down pucks as long as the current draw is reasonable.


----------



## Geoffrey (Jun 24, 2015)

Sounds like a fun project...but I have no idea what's going on or what each component does, haha. And really, I guess I have no need for another light.


----------



## Mark Brown (Jan 21, 2017)

you just made my day with this post. I have been searching for some led lighting but I am a cheapskate and building my own is right up my ally! thanks for the parts list I will be pilfering it for my own diabolical need! or maybe I will just build a strip light, hard to say. expect a pm when I fail and beg for your advice


----------



## pinhead (Apr 22, 2010)

I have been running an Arduino controller on my reef tank for quite a few years. It controls my pumps, heaters, feeder and LED lights. It is quite advanced and will do phases of the moon. Jarduino on Youtube

It uses an Arduino Mega and has a colour touchscreen. Parts today without the LED driver are probably less than $25. One thing I found was the stainless steel temperature probe will rust with constant immersion. I covered a replacement probe in PlastiDip to avoid this.


----------



## Mark Brown (Jan 21, 2017)

OK. ..OK. . so before I was impressed but now I'm in love! I just hacked some old led strip lights into my aqueon hood lamp single tube and that got me all hot around the collar but what I am seeing come out of this thread is blowing my mind. you sir are a god among us. Sorry to go and toot your horn like that but I am really impressed


----------



## Bunny (Oct 13, 2013)

When I finish my other planned projects maybe I'll take a crack at something like this. Would be nice to incorporate an auto-dosing system, android app communication and voice activation (just for fun) via my re:speaker (when it eventually gets here)... ahh... so very many projects to play with~


----------

