Introduction: LED Light Fixture on a Timer for Planted Tanks and Aquariums

About: Recently graduated engineering student with too much free time :)

This is an aquarium LED light bar lamp controlled with Arduino. Commercial aquarium LEDs with timers can be expensive. This light will gradually turn on over the course of an hour in the morning, then gradually dim for an hour to turn off at the end of the day.

This project involves programming (code provided), 3D printing (files provided), and soldering. However, this project could be done without soldering using just a breadboard and without printing via some adhesives for the LED strip. This is essentially an addressible LED strip on a timer.

This was inspired by a guide found on MUO with some modifications required for it to work. That guide can be found here: https://www.makeuseof.com/creating-diy-aquarium-lighting-with-arduino/ . I have only made a few projects with Arduino, so I wrote this tutorial trying to keep beginners in mind.

Supplies

Electronics components:

  • Arduino microcontroller - I used an off-brand Arduino Nano.
  • Real Time Clock (RTC) module - I used PCF8523 but it was unreliable. It seems DS3231 is preferred by many makers. The RTC requires a coin cell battery to run, the size of which varies by module.
  • WS2812B LED strip - I used the width of my light bar x3, or roughly 1 meter. They are very bright so you could use even less. If you plan on sticking the LEDs onto something instead of printing a fixture, make sure your strip has adhesive sticker on the back. The waterproof strips are slippery and don't stick well to adhesives.
  • 5V power supply and wires - Mine came with the positive and ground wires attached to a USB plug. I cut the plug off the end and striped the ends to expose two bare wires for breadboarding. If you cannot solder the tips to hookup wire or jumper wires, you will need some way to attach it to your breadboard, such as a 2-pin breadboard terminal block.
  • On/off rocker switch - Optional. You could just pull the plug when you want to turn it off.
  • Capacitor - Optional. I used 1000 uF.

Breadboarding/circuit prototyping tools:

  • Breadboard
  • Jumper wires, male-male dupont wires, or 22 awg hookup wire pieces with stripped ends.

Soldering tools:

  • Protoboard - I used a 5x7 cm board due to the size of my components.
  • Hookup wire - 22 awg solid core copper wire. Another flexible wire can be useful for connecting the LEDs to the circuit board.
  • Soldering iron and solder - using flux can help.
  • Wire strippers and tweezers - I only used a box cutter and flush cutters to cut, strip, bend, and hold wire. But these tools would have helped a lot and are affordable if you plan to make more electronics projects.
  • A circuit board holder or a third hand are useful if you have it.
  • Multimeter - useful for troubleshooting.

Programming:

  • A USB cable to connect to your Arduino
  • Arduino IDE

3D printing:

  • PLA filament
  • 2x M3 x 8mm bolts and corresponding nuts
  • Clear filament - Optional. You can use a sheet of paper to diffuse the LEDs. If you do choose to print a panel to diffuse the light, check Rygar1432's tutorial on Printables for tips: https://www.printables.com/model/15310-how-to-print-glass
  • Adhesive rubber feet - Optional. I like the domed silicone 6mm x 2mm feet for my projects.

Most of my electronics components were purchased from Amazon or a site like Digikey.

Step 1: Wiring the Circuit

Using the electronics components and breadboarding tools listed above, arrange your parts to create this circuit. I attached an image of my completed breadboard circuit, without the optional switch and capacitor.

Searching for your board's pinout diagram can help you identify which pins to connect. For this project, you need to identify 5V, GND, SCL, SDA, and a digital pin (I used pin 7).

Step 2: Set Up the Arduino IDE

Connect your Arduino to your computer and open the Arduino IDE. Make sure to select your correct board, bootloader (usually the default), and port (usually the default) in the IDE under the Tools menu.

Go to Sketch > Manage libraries > Include library and make sure you have the FastLED, Wire, and RTClib libraries added.

If you are interested in learning more, there are example programs under File > Examples specific to these libraries that you can explore to familiarize yourself with them.

Step 3: Programming

In summary, this program will connect to the RTC and LEDs. Based on the time of day, it will turn on/off and change the brightness of the LED strip. You can download the code and change the values as described in this step. This program assumes a one-hour dimming period from near-maximum brightness. It also assumes the brightening/dimming starts after 12am and finishes before 12am.

For this beginning section of code, you will need to:

  • Ensure LED_PIN number corresponds to the pin on the Arduino board that your LED is connected to.
  • Set LED_COUNT to the number of LEDs in your strip.
  • Update the RTC module to the one you have.

In the void setup(), you will need to:

  • IMPORTANT: Note the rtc.adjust() function. When first uploading your code to your Arduino, you need this line to be uncommented. After it uploads, you can comment it out/remove it and reupload with this change. Your RTC module's time only needs to be set once, otherwise it will reset every time you power your Arduino.
  • Update the setLEDColor function to the RGB color code you want for your LEDs.

In the void loop(), you will need to:

  • Update the time_start variable to the hour of day you want the lights to turn on. To start at 1pm, you would set it to 13.

Update the time_dark variable to the hour of day you want the lights to start to dim.


Now we have to verify that the program works as intended. Part of this is making sure it works while plugged into 5V power without a connection from Arduino to the computer.

To check that your Arduino is trying to turn the lights on at the correct time: Open the serial monitor while the Arduino is still plugged into your computer. It should output the current time, maybe off by a few seconds.

To make sure the RTC module is tracking the current time: unplug the Arduino, turn off power, and then plug it in again. Refresh the serial monitor and make sure the time is accurate.

To check the LEDs' behavior is getting brighter and dimming as intended: adjust the variables time_start and time_dark to the current hour. Reupload the code and check the serial monitor to make sure the number on the line below the time statement is increasing/decreasing as intended.

Step 4: Soldering

Once you confirm your program works as intended, you can begin soldering the components to a protoboard. I started by soldering the Arduino to the board, then the RTC module. Cut and strip solid core 22 gauge hookup wire and bend it to connect the pins as you did on the breadboard, then solder them in place. I ended up cutting off the first few LEDs on my strip and soldered three wires directly to the copper contacts.

Tips for soldering to protoboard:

  • Ventilation is important! Use a fume extractor, fan, open a window, or wear a respirator. Solder typically has lead and is not safe to inhale. Keep pets and children out of the room.
  • Cut the wire longer than intended and trim the excess after soldering.
  • Bend a 90° in the stripped part of the wire through the holes in the board to keep them in place. You may need pliers for this; I couldn't do it with my nails.
  • Make sure you heat the wire and the copper pad completely when melting solder to form a good joint.
  • Tweezers can be useful for holding parts in place while soldering.
  • Dipping the tips of the components in flux before soldering can help things go smoothly.
  • If the solder does not adhere to the leads on the switch or any pins you might solder, rub the surface with sandpaper.

If your protoboard is too large, you can use a knife or box cutters and a ruler or straightedge to score a line across a row of holes. Score both sides, then press the scored line over the edge of a table to snap the board to size.

The 5V power cable, LED lights, and rocker switch will be easier to use if you connect them with flexible wire instead of solid core wire. For the LEDs, you can see I used male-female dupont wires in place of flexible stranded copper wire on the protoboard. Then the LEDs were soldered to hookup wire and then plugged into the female side of the dupont wire.

My board will likely look very different from yours depending on the tools and parts you have available. These images show you can make a circuit board even without all the necessary tools, it just might not be very clean. I tried to make this with spare parts and things I had from previous projects. My RTC module is very old and did not track time properly without a capacitor, though I have yet to determine the reason.

Step 5: Troubleshooting Your Protoboard

If things aren't working properly, you can use a multimeter to troubleshoot it.

  • Set it to DCV, which is sometimes labeled V with a solid and dashed line. While the circuit is powered on, probe the positive and ground terminals for each component. It should read around 5 volts (the RTC module may be slightly less, between 3V-5V). If one part does not read 5V, the circuit may not be connected properly.
  • You can use continuity mode (sometimes denoted by a diode symbol) to make sure your connections are solid. The multimeter reading should be at or near zero when the two probes are connected. You can also use this mode to check for shorts. Ie, if two parts might be touching, that shouldn't be, use the probes to make sure the reading does not reach zero and that the parts are not touching.

Also double-check your code to make sure the clock and LEDs are working as intended in the serial monitor.

Step 6: 3D Printing

The 3D printed components are:

  • Supporting arm
  • Supporting arm, mirrored
  • LED lampshade bar
  • Diffuser sheet (optional)
  • Case for circuit board
  • Lid for circuit board case

The arm was modeled to fit my tank specifically, a 2.5 gallon Aqueon open-glass tank. The connection snaps onto the plastic brim of my tank, but a different shape may be necessary for your tank. You can model your own support arm part*, as long as it can securely rest on the edge of your tank without wobbling on one end and has a 3.5mm hole for an M3 bolt on the other end. I mirrored the supporting arm .STL in my slicer to get the second arm for the other side.

The LED bar is roughly 24 cm long, the longest I could comfortably fit on my print bed. Oriented at a 30 degree angle. I had issues with uneven cooling and part warping on one side, so use a large brim when printing. If you design your own, something that could be printed in two separate halves and attached afterwards may work better for less warping.

The case was designed to hold a 5x7 cm protoboard. It has a little bit of space underneath and mounting holes for M2 screws to secure the board. The fit was tight enough that the screws were unnecessary. There is space for fingers to pull the board out, the Arduino cable, the rocker switch, and slots for the wires. The lid fit over these components and covered the finger slots and Arduino cable access. If you make your own, I found that a 0.2 mm tolerance was a little bit too tight for my print and 0.25 mm may work better. You can also reduce horizontal expansion or sand the parts to remove layer lines (allowing them to slide past each other more smoothly).

More information on specific printing instructions can be found on my Printables page: https://www.printables.com/model/753274-aquarium-lamp-and-circuit-board-box

*I just modeled an "Alternate support arm brimless" STEP file for anyone who wants to modify and print it for a brimless tank. It's currently designed for a 6mm thick piece of glass. I have not tested this part. I do not know the tolerances required for printing and fitting this over glass. I recommend using sandpaper to smooth the surfaces that will come in contact with the glass or place some fabric in between. I do not know if it's fish-safe for 3D printed parts to contact water, and this extends roughly 1" into the tank. Use at your own risk.

Step 7: Assembly

If you don't have a 3D printer, use adhesives to attach the LEDs to the wall or a surface behind the aquarium. You could place the circuit board in a small box to keep everything contained.

For the lampshade, there is a slot for an M3 nut to fit snuggly, allowing you to position it at the correct angle in the support arms and tighten a bolt on either side to secure. Tighten one arm at the correct angle, then loosely add the second arm, position on the tank, and tighten all the way. I added slots along the inside of the bar to press fit my silicone-covered IP65 LED strip. If you have regular non-waterproof LEDs, they should adhere in the slots.

For the support arms, if you have a small 2mm thick adhesive rubber bumper, stick it to the small slot at the base of each support arm. This will keep the arm from sliding around.

For the circuit board box, press the board and switch into place. The lid should slide tightly over the top, but there are two holes in the back for M2 screws to hold it in place if necessary. Optionally, attach rubber feet to the bottom.

If your tank has a clear back like mine, you could use wire wrap to keep the wires tidy if you have some.

Thanks to this new LED I can see the snails and plants in my tank very clearly!

Anything Goes Contest

Participated in the
Anything Goes Contest