Project showcase
Autonomous Indoor Greenhouse - Mature Real Working Project

Autonomous Indoor Greenhouse - Mature Real Working Project © GPL3+

Another indoor greenhouse powered by Nano. 100% controlled environment with some extra perks that make life easier.

  • 17,182 views
  • 39 comments
  • 143 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

About this project

Well, I like growing my own vegetables.

I discovered Arduino just several months ago and I was amazed by this little board. Before, I tried Raspberry and Python but wasn't inspired by them.

So, after some tries (reaction timer, automated soil sensor, railroad barrier for my son's train) I decided to build something more serious and functional.

Voilà, it's up to you to look at it.

Project description:

The main structure is a revamped IKEA portable wardrobe. I added styrofoam insulation and built another shelf in the middle. After these I have three shelves. The lowest one is mainly for seed starting: there's a heating mat. The two others are for plants.

Air circulation, heating and temperature/humidity measurement are performed by an ABC pipe "furnace." A DHT22 sensor is used to measure temperature and humidity.

Humidity control is done by a small 12V "squirrel cage" fan.

An Arduino Nano (compatible board) is at the center of control unit. There's an I2C LCD to show all necessary parameters and status. The IR motion sensor triggers the LCD backlight when there's someone in the area.

There's an RTC relay clock which gives, through a digital pin, a "day/night" reference to the entire system. The inside temperature has two setpoints for "night" and "day" to simulate real conditions. The lights stay on during the "daytime" for about 15hrs.

Irrigation system: a rain(snow)water barrel is connected to a two-pump block through an electric valve and a filter. Water level is measured by an ultrasonic sensor. Two capacitive soil moisture sensors monitor humidity and trigger water pumps independently for their respective zone. The irrigation is blocked when water level in the barrel becomes critical and a LED is showing a "low water" warning.

So, basically, this is the project. Please enjoy and ask some questions if needed. I speak also French, Romanian and Russian.

Code

Greenhouse Arduino code. Real, working project.Arduino
Please note that some parts of code are still in development. Always verify compatibility and don't forget keeping my name in reference. Thanks
//===GreenHouse sketch created by Victor Onofrei. 2019===
#include <DHT.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <HCSR04.h>
#include <SandTimer.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27,20,4);
HCSR04 watersens(5,6);
SandTimer timersensor;
SandTimer backlightimer;
SandTimer pump1timer;
SandTimer pump2timer;
const int lowaterled=4;
const int venthum=7;
const int irsensor=8;
const int pump2=9;
const int heaterpin=10;
const int lightpin=11;
const int pump1=12;
const int timerpin=13;
int h=0;
int t=0;
int Soil1=0; //lower soil moisture sensor
int Soil2=0;
int settemp;
int daytemp=26;
int nightemp=23;
int timervalue;
int motiondetect;
int waterlevel;


void setup() {
  dht.begin();
  lcd.init();
  timersensor.start(2000);
  backlightimer.start(30000);
  pump1timer.start(10000);
  pump2timer.start(10000);
  pinMode(heaterpin, OUTPUT);
  pinMode(timerpin, INPUT);
  pinMode(lightpin, OUTPUT);
  pinMode(lowaterled, OUTPUT);
  pinMode(venthum, OUTPUT);
  pinMode(irsensor, INPUT);
  pinMode(pump1, OUTPUT);
  pinMode(pump2, OUTPUT);
  digitalWrite(pump1, HIGH);
  digitalWrite(pump2, HIGH);
 }

void loop() {
  sensorcheck();
  lowater();
  settempset();
  humidcontrol();
  runheat();
  runlights();
  lcdprint();
  lcdbacklight();
  watering();
 }

//===========Functions=============

void sensorcheck(){
  if (timersensor.finished()){
    h=dht.readHumidity();
    t=dht.readTemperature();
    timervalue=digitalRead(timerpin);
    Soil1=analogRead(6);
    Soil2=analogRead(7);
    Soil1=map(Soil1,560,270,01,99);
    Soil2=map(Soil2,545,270,01,99);
    motiondetect=digitalRead(irsensor);
    waterlevel=watersens.dist();
    waterlevel=map(waterlevel,3,57,99,01);
    timersensor.startOver();
  }
}

void lowater(){
  if (waterlevel<=3){
    digitalWrite(lowaterled, HIGH);
  }
  else{
    digitalWrite(lowaterled, LOW);
  }
}

void watering(){
  if ((waterlevel>=3)&&(Soil1<=24)){
    digitalWrite(pump1, LOW);
//    if (pump1timer.finished()){
//      digitalWrite(pump1, HIGH);
//      pump1timer.startOver();
//    }
  }
else{
  digitalWrite(pump1, HIGH);  
}
  
  if ((waterlevel>=3)&&(Soil2<=24)){
    digitalWrite(pump2, LOW);
//    if (pump2timer.finished()){
//      digitalWrite(pump2, HIGH);
//      pump2timer.startOver();
//    }
  }
else {
  digitalWrite(pump2, HIGH);
}
}

void settempset(){
  if (timervalue==HIGH){
  settemp=daytemp;
}
else{
  settemp=nightemp;
}
}

void lcdbacklight(){
    if (motiondetect==1){
    lcd.backlight();
  }
else if ((motiondetect==0)&&(backlightimer.finished())){
  lcd.noBacklight();
  backlightimer.startOver();
}
}

void humidcontrol(){
  if(h>=72){
  digitalWrite(venthum, HIGH);
}
else if (h<=65){
  digitalWrite(venthum, LOW);
}
}

void runheat(){
  if(t>=settemp){
  digitalWrite(heaterpin, HIGH);
}
else{
  digitalWrite(heaterpin, LOW);
}
}

void runlights(){
if (timervalue==LOW){
  digitalWrite(lightpin, HIGH);
}
else{
  digitalWrite(lightpin, LOW);
}
}

void lcdprint(){
  lcd.setCursor(0,0);
  lcd.print("T/H:");
  lcd.print(t);
  lcd.print("/");
  lcd.print(h);
  lcd.setCursor(10,0);
  lcd.print("WL:");
  lcd.print(waterlevel);
  lcd.print("%");
  lcd.setCursor(0,1);
  lcd.print("Z1:");
  lcd.print(Soil1);
  lcd.print("%");
  lcd.print(" ");
  lcd.print("Z2:");
  lcd.print(Soil2);
  lcd.print("%");
}

Comments

Similar projects you might like

Probability | Autonomous Rover

Project in progress by colepurtzer

  • 9,499 views
  • 19 comments
  • 56 respects

Smart Garden

Project showcase by patel Dipen

  • 26,875 views
  • 16 comments
  • 71 respects

Multi-Dashboard Display with Arduino Controller

Project showcase by Colin O'Dell

  • 24,870 views
  • 6 comments
  • 67 respects

WW2 Tank Laser Tag Sherman & Panther

Project tutorial by Arduino “having11” Guy

  • 15,468 views
  • 1 comment
  • 57 respects

'Roger Bot' the Pet Rover

Project showcase by hannu_hell

  • 2,041 views
  • 0 comments
  • 13 respects

Ninja Dollar - LCD game

Project tutorial by anime

  • 2,882 views
  • 3 comments
  • 6 respects
Add projectSign up / Login