Rushabh Jain
Published © GPL3+

Hydroponics

Automatic plant growth model.

IntermediateFull instructions provided10 hours20,243
Hydroponics

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
DHT11 Humidity sensor
×1
Relay (generic)
×1
RobotGeek Light Sensor
RobotGeek Light Sensor
×1
Temperature Sensor
Temperature Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Hydroponics

Code

Hydroponics

Arduino
#include <SimpleDHT.h>


int pinDHT11 = 41;
int coolingFan=50;
int heatingFan=48;
int heater=3;
int LEDrow1=25;
int LEDrow2=27;
int LEDrow3=29;
int LEDrow4=31;
int pump=31;

SimpleDHT11 dht11;


void setup(){
  Serial.begin(115200);
  pinMode(coolingFan,OUTPUT);
  pinMode(heatingFan,OUTPUT);
  pinMode(heater,OUTPUT);
  pinMode(LEDrow1,OUTPUT);
  pinMode(LEDrow2,OUTPUT);
  pinMode(LEDrow3,OUTPUT);
  pinMode(LEDrow4,OUTPUT);
  pinMode(pump,OUTPUT);
}

void loop(){
  temperature();
  light();
  humidity();
}

void temperature(){
  int value= analogRead(A10);
  float volts=(value/1024.0)*5.0;
  float temp= volts*100.0;
  Serial.print("temp=");
  Serial.println(temp);
  delay(1000);
  if(temp<25){
    digitalWrite(heater,LOW);
    digitalWrite(heatingFan,HIGH);
  }
  else{
    digitalWrite(heater,HIGH);
    digitalWrite(heatingFan,LOW);
  }
  if(temp>30){
    digitalWrite(coolingFan,HIGH);
  }
else{
    digitalWrite(coolingFan,LOW);
  }
}

void light(){
float ldrdata=analogRead(A8);
float resistorVolt=(1024-ldrdata)/1024.0*5.0;
float ldrVolt=5.0-resistorVolt;
float ldrResistance= ldrVolt/resistorVolt*5000.0;
float lux = (12518931)*(pow(ldrResistance,-1.405));
float photons= lux*0.019;
//Serial.println(photons);
delay(1000);

if(photons<50){
  digitalWrite(LEDrow1,HIGH);
  digitalWrite(LEDrow2,HIGH);
  digitalWrite(LEDrow3,HIGH);
  digitalWrite(LEDrow1,HIGH);
}
if(photons>100){
  digitalWrite(LEDrow1,LOW);
  digitalWrite(LEDrow2,LOW);
  digitalWrite(LEDrow3,LOW);
  digitalWrite(LEDrow4,LOW);
}
}

void humidity() {

  // start working...
 //Serial.println("=================================");

  //Serial.println("Sample DHT11...");

  

  // read without samples.

  byte temperature = 0;

  byte humidity = 0;

  int err = SimpleDHTErrSuccess;

  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {

    //Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000);

    return;

  }

  int humid=(int)humidity;

  //Serial.print("Sample OK: ");
 // Serial.print(humid); Serial.println(" H");
  // DHT11 sampling rate is 1HZ.
  delay(2000);

  if(humid<85){
    digitalWrite(pump,HIGH);
    digitalWrite(coolingFan,LOW);
  }
if(humid>94){
  digitalWrite(coolingFan,HIGH);
  digitalWrite(pump,LOW);
}
}
  

Credits

Rushabh Jain

Rushabh Jain

10 projects • 43 followers
An engineer who loves to solve problems with technology. Expertise in Embedded firmware and software.

Comments