$USD
  • EUR€
  • £GBP
  • $USD
PROJECTS ArduinoGravity

Autonomous Indoor Greenhouse - Mature Real Working Project

DFRobot Nov 06 2019 824

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

Project Creator: vinikon

Things used in this project

Hardware components

Arduino Nano R3 ×1

Arduino 4 Relays Shield (It is a 4 relay block.) ×1

Ultrasonic Sensor - HC-SR04 (Generic) ×1

PIR Motion Sensor (generic) ×1

LED (generic) ×1

Adafruit Standard LCD - 16x2 White on Blue (I2C interface soldered on it.) ×1

DFRobot Gravity: Analog Capacitive Soil Moisture Sensor- Corrosion Resistant(A simple sensor)×2

RobotGeek DC Liquid Pump - Large×2

Liquid valve×1

Water Tank×1

DHT22 Temperature Sensor×1


Hand tools and fabrication machines

Soldering iron (generic)


Story

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.

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

The "furnace" and an additional heating element
Humidity control is done by a small 12V "squirrel cage" fan.

When triggered by the board, it pumps fresh air inside the greenhouse
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.

The LCD shows: temp, humidity, water level and soil moisture for zone1 and zone2.
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.

Not very "top-notch" technical execution but I like gardening more than soldering
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.

A two-pump watering block
Soil moisture sensor and an irrigation head
Water level ultrasonic sensor. 

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
//===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("%");
}
REVIEW