I have always liked aquariums. It’s fascinating to have a piece of a whole different living biome sitting right there in your living room.
But one thing has always bothered me. The lights. At bedtime the lights either trigger off from a timer, or you flip the switch in the back, and with a little “Click” the beautiful ambiance is destroyed. Your fish are immediately plunged into pitch black night, causing a temporary, skittering panic. Can you blame them? They think their sun just blew up.
Fortunately, a very cool DIY solution is easy to make, and cheap. Your fishes will get to enjoy a beautiful aquatic sunset like they surely remember somewhere in their evolutionary past, and you don’t need to sacrifice live plants, grow lights can be included easily. Check out the below video of our 55 gallon. I adjusted the transition time to 60 seconds so that you can see a full “day”. The night lights at the start and end are a bit dark to show up on the camera, but they look much cooler in person!
Of course, there are some off-the-shelf solutions. For example, these you can find at your local pet store. But they are not grow lights, and only have a night time setting, no transitions. Nope.
These ones are a little closer. For $70, it has both grow lights and RGB lights, with a IR remote control. But as far as I can tell, you just press the button and it goes to whatever setting, there is no transition. The transition was the whole point for me, plus there are only a couple bad reviews. Nah, we can do better!
Lets Make it! What do I need?
Surprisingly little! The total cost will come to about $80 (for a 55 gallon). Here is the BOM:
- (1) RGB LED Strip (weather proof) – $16
- (1) Cool White LED Strip (weather proof) – $20
- (1) Arduino Pro Mini (or similar) – $10
- (4) N Channel MOSFET – $7
- (1) 10K Linear Potentiometer – $1
- (4) 10k Ohm Resistors – $1
- (1) 12 Volt Power Supply (3A or more) – $25
Hook it up!
The electrical hook up is pretty straightforward. Refer to the below Fritzing diagram.
Aquarium lighting bread board hook-up.
In case you are not familiar with the components, let’s briefly discuss each one individually.
RGB LED strip: Strip of RGB (Red-Green-Blue) LED lights. RGB LED’s are very cool. Each individual LED is actually 3 different LED’s one Red, Green, and Blue. By varying the brightness of each color (using PWM – see micro controller section), you can create almost any color imaginable, just the same as if you were mixing watercolor paints. Usually you need to consider things like current limiting resistors, but these strips have already taken care of that, all you need is to apply 12 Volts. These strips are “common cathode”. That means that you apply 12 volts to one wire (the black one) and all the red, green, and blue wires need to be attached to ground to create their respective colors.
Cool White LED Strip: Very similar to the RGB led strip. Only apply 12 volts and ground and it will light. This strip was included solely for plant growth, as it has a 10,000 Kelvin lighting temperature. You may have noticed at the store you can buy cool or warm white bulbs. Warm is around 3,000 K, and cool is typically around 6,000 K. The higher Kelvin ratings are generally better for plant growth.
Arduino Pro Mini: The arduino is the brains of the operation. it’s keeps time, and adjusts output based on that. The pins that control the LED’s are capable of Pulse Width Modulation (PWM). PWM is exactly what it sounds like. To control the LED brightness, you turn them on and off very quickly. The higher the % of time spent on vs off, the longer the pulse width, the brighter the light. Cool! Note that not all arduino pins are capable of PWM, that’s why we used the pins we did.
N-Channel MOSFET: Metal-Oxide Semiconducting Field-Effect Transitor. MOSFET. Whew! Think of it like a switch on your wall, they are the muscle of the operation. It’s purpose is to switch high voltage/current loads that the arduino is incapable of doing on it’s own (it’s designed to be a sensitive brain, not a strong muscle). Not only that, but MOSFET’s can switch at very high speeds like we need for PWM. There are 3 pins. One of them is listening to the arduino signal. The other two are connected (current can flow) when the signal goes high, but otherwise disconnected. Be aware that there are also P-Channel MOSFET’s which function similarly, but would not work as replacements here.
10K Linear Potentiometer: A potentiometer is a variable resistor. You can change it’s resistance value linearly from 0 up to 10k Ohms. In this case, it will be a user control that will set the time of day, as we rotate.
10K Ohm Resistors: These resistors are needed as good practice for wiring. They are called pull-down resistors. Their job is to make sure that if the arduino signal wires are disconnected, the MOSFETs do not switch on and off randomly.
12 Volt Power Supply: Takes the AC in your wall and makes it 12 Volt DC. Needs to be able to handle the current required by the LED’s. If you have a smaller aquarium, and fewer lights you can get by with less power.
Load the Code.
My favorite part! Connect the arduino via USB and load the following code. There is a variable called transitionTime, set it to something like 10000, or 20000 milliseconds (10-20 seconds) in the beginning so that you can quickly see if you like the transitions speeds and colors. I still think they need tweaking a little. Later you can set it to a full day (86,400,000 ms/day). We will discuss how it works, and how to change colors in the next section.
Cool! How Does it Work?
The Arduino program is really pretty simple. We want to vary the brightness of lights based on time right? Lets say time is X and brightness is Y. We want to go from brightness y1 to y2, in the time period x1 to x2. Sounds like the makings of a line to me. At the very bottom of the code you see a function defined called “Fade”. It’s inputs are x1, x2, y1, y2, and time. The task of Fade is to calculate the equation of a line based on those values, and use the time to output the brightness. “Fade” allows us to adjust the colors based on any start and endpoints, at different rates (slopes) without having to include the bulky text to recalculate the line every time.
The timing is controlled simply by delay(20) and the currentTime variable. This is not ideal. What’s happening is that the program is holding 20 ms every iteration, and the variable currentTime gets increased 20 ms every iteration. The problem is that the program takes time to compute everything. Not a lot, but some, and it’s not included included when the code iterates, so eventually (over a couple days) you will notice the program has begun to lag behind real time a little. I suspect there are other ways around this (any tips anyone? Comments!), but with the potentiometer allowing adjustment, it’s easy enough to fix, and the program is simple.
I’m happy with the results, it adds another aspect of peaceful nature-y feel to the aquarium. So let me know what you think, if you build one yourself, if you see ways to improve my code, etc. I did not mention how to mount them, there are many different possibilities, and it depends a bit on the type of light hood you already have. Thanks for reading!