Project showcase
Automated LED Lighting for Planted Aquarium

Automated LED Lighting for Planted Aquarium © CC BY-NC-SA

Never forget to turn ON/OFF your aquarium lights.

  • 3,985 views
  • 3 comments
  • 6 respects

Components and supplies

About this project

A couple of years ago I decided to set up a planted aquarium. I was fascinated by the beauty of those aquariums. I did everything which I was supposed to do while setting up the aquarium but neglected one most important thing. That thing was lighting. Everything looked fine for few days but then algae started growing everywhere in the tank and the plants were not doing great. It is a tough job to get everything back to normal.

Now after many years, I want to set up the aquarium again giving importance to lighting. I did some research on the internet and found that plants need continuous exposure to light for around 10-12 hours daily. I also came to know that plants respond more to the red and blue spectrum of light.

The trick is to simulate nature as closely as possible inside the aquarium. I could have manually switched ON or OFF the lights but why not automate it. This reduces the human error. So, I decided to make a LED lighting system which turns ON and OFF automatically using Arduino. This makes the lighting period consistent which is what the plants need.

The plan is to turn ON and turn OFF the LEDs at a specific time of day. The LEDs won't turn ON to the full brightness immediately but instead, it will reach from zero brightness to full brightness in an hour. This is to simulate the sunrise. Same applies while turning OFF the LEDs.

The job of providing the exact time is done by the Real Time Clock or RTC. The advantage of using an RTC over millis() is that precise time can be obtained directly. Also, the RTC module has its own battery back up. So even if the Arduino is powered OFF or is reset the time is not lost. This makes it perfect for our application.

Why just control the lighting? As I had some relays laying around, I will be using them to switch ON or OFF some of the appliances like the filter, air pump, heater, etc. too if needed. I added a 12V DC computer fan to provide ventilation.

Code

Fishtank Controller.inoC/C++
/*Automated LED Lighting for Planted Aquarium. 
 * 
 *Author: Neeraj R. Rane  
 *Please note that the time is in 24-hour format.
 *So, enter the time accordingly for proper functioning.
*/


#define OLED_RESET 4
#include <Adafruit_SSD1306.h>
#include <DS3231.h>

DS3231  rtc(SDA, SCL);

//Please note that the time is in 24-hours format. Set the time accordingly.
int ledStart = 21;       //Set the LED start hour
int ledStop = 23;        //Set the LED stop hour
int fanStart = 21;        //Set the Fan start hour
int fanStop = 23;         //Set the fan stop hour

int minutes,hours;
int potPin = A0;
int manualSwitch = 6;
int fanPin = 2;
int relay1 = 3;
int relay2 = 4;
int relay3 = 5;
int wLed = 9;
int rbLed = 10;

Adafruit_SSD1306 display(OLED_RESET);

void setup()
{
  pinMode(manualSwitch, INPUT);
  
  pinMode(wLed, OUTPUT);
  pinMode(rbLed, OUTPUT);
  pinMode(fanPin, OUTPUT);

  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  
  rtc.begin();
  
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(1000);
  display.clearDisplay();

  display.setTextColor(WHITE);
}

void loop(){
  String time_3231 = rtc.getTimeStr();
  hours = time_3231.substring(0,2).toInt();
  minutes = time_3231.substring(3,5).toInt();
  display.setTextSize(2);
  display.setCursor(32,1);
  display.print(hours);
  display.print(":");
  display.println(minutes);

  if(hours >= fanStart && hours < fanStop){
    digitalWrite(fanPin, HIGH);
  }
  else{
    digitalWrite(fanPin, LOW);
  }
  
  if(hours == ledStart){
    if(minutes >=0 && minutes <=59){
      wLedStart();
    }
    digitalWrite(rbLed, HIGH);
  }
  
  if(hours>ledStart && hours<ledStop-1){
    digitalWrite(wLed, HIGH);
    digitalWrite(rbLed, HIGH);
  }
  
  if(hours<ledStart || hours>ledStop){
    digitalWrite(wLed, LOW);
    digitalWrite(rbLed, LOW);
  }
  
  if(hours == ledStop - 1){
    if(minutes>=0 && minutes<=59){
      wLedStop();
    }
  }

  if(hours == ledStop){
    digitalWrite(rbLed, LOW);
  }
  
  if(digitalRead(manualSwitch)==HIGH){
    manualMode();
  }
  
  display.display();
  display.clearDisplay();
}//main loop ends here

void wLedStart(){
  int fade = map(minutes,0,59,1,255);
  analogWrite(wLed, fade);
}

void wLedStop(){
  int fade = map(minutes,0,59,255,0);
  analogWrite(wLed, fade);
}

void manualMode(){
  digitalWrite(rbLed, HIGH);
  while(digitalRead(manualSwitch)==HIGH){
    display.setTextSize(1);
    display.setCursor(0,20);
    display.println("Manual Mode");
    display.display();
    int brightness = analogRead(potPin);
    brightness = map(brightness,0,1023,0,255);
    analogWrite(wLed, brightness);
  }
  digitalWrite(wLed, LOW);
  digitalWrite(rbLed, LOW);
}

Schematics

Fishtank Controller

Comments

Similar projects you might like

SMART Home LED Lighting System and More

Project in progress by Joey Pongallo

  • 5,947 views
  • 4 comments
  • 13 respects

Aquarium Ambience Lighting (LED) Control

Project showcase by randtekk

  • 1,044 views
  • 1 comment
  • 2 respects

Automated Staircase RGB LED Lights

Project tutorial by Team NotEnoughTech.com

  • 27,609 views
  • 19 comments
  • 98 respects

LED Emergency Lights using WS2812 RGB LED Module

Project tutorial by bigboystoys13

  • 10,004 views
  • 5 comments
  • 20 respects

Automatic LED Stairs Lighting Arduino Shield

Project tutorial by Aivaredze

  • 2,121 views
  • 1 comment
  • 12 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 17,290 views
  • 4 comments
  • 34 respects
Add projectSign up / Login