Iasonas Christoulakis
Published © GPL3+

SmartGardenSystemSGS

It is a system that monitors temperature, humidity and soil moisture and show the measurements on a LCD, also contains a photocell.

IntermediateFull instructions provided4 hours983
SmartGardenSystemSGS

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×1
Maker Essentials - Mini Breadboards & Jumper Jerky
Pimoroni Maker Essentials - Mini Breadboards & Jumper Jerky
×2
LDR, 5 Mohm
LDR, 5 Mohm
×1
LED (generic)
LED (generic)
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Gravity: Analog Soil Moisture Sensor For Arduino
DFRobot Gravity: Analog Soil Moisture Sensor For Arduino
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Buzzer
Buzzer
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fritzing

Hand tools and fabrication machines

CUBExUS Waterproof electrical box

Story

Read more

Schematics

Schematics

All connections about programming

Schematics

Code

SmartGardenSystem

C/C++
#include <dht.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
 dht DHT;
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);
 #define DHT11_PIN 8
//----------------------------
//monitoring initialization
//---------------------------
const int buzzer = 13;
const int LED_Pin = 12;
int Input_Value = 0;
const int LDR_Pin = A0;
const int Moisture_Pin = A1;
const int threshold = 30;


void setup()
{
  Wire.begin();          
  Serial.begin(9600);
  pinMode(LED_Pin , OUTPUT); 
  pinMode(buzzer,OUTPUT);

  lcd.begin(16,2);
  lcd.print('Hello World!');
}
void loop()
{
    
 //LDR Value
  Input_Value = analogRead(LDR_Pin);
  
  //LDR Settings

if (Input_Value<threshold) 
{
  digitalWrite(LED_Pin , HIGH);
  digitalWrite(buzzer,HIGH);
  delay(1000);
  digitalWrite(buzzer,LOW);
  
  
  
}
   else if (Input_Value>threshold)
{
    
    digitalWrite(LED_Pin , LOW);
    
       }
     
//Humidity Value
  
  int chk= DHT.read11(DHT11_PIN);
  delay(1000);
  int temp=DHT.temperature;
  delay(1000);
  int hum=DHT.humidity;
  delay(1000);
  
//Soil Moisture Value
   float moi_percentage;
   int moi = analogRead(Moisture_Pin);
   delay(500);
   moi_percentage = (100 - (100*(moi/1023)));

if (isnan(DHT.humidity) || isnan(DHT.temperature)) 
{
    Serial.print("ERROR");
    lcd.print("ERROR");
    return ;
  }
//Serial Monitor
Serial.println("=================================");
  Serial.println("LDR reads...");
Serial.print("LDR_Value=");
    Serial.println(Input_Value);
Serial.println("=================================");
  Serial.println("DHT11 reads...");
   Serial.print("Temperature= ");
   Serial.println(DHT.temperature);
   Serial.print("C\n\n");
   Serial.print("Humidity= ");
   Serial.println(DHT.humidity);
   Serial.print("%\n\n");
 Serial.println("=================================");
  Serial.println("Moisture Soil Sensor reads...");  
   Serial.print("Moisture= ");
   Serial.println(moi_percentage);
   Serial.print("%\n\n");

//lcdOptions
   lcd.clear(); //refresh lcd every 0.75sec
   lcd.setCursor(0,0);
   lcd.print("Temp:");
   lcd.print(round(DHT.temperature));
   lcd.print("C");
   lcd.setCursor(0,1);
   lcd.print("Humidity:");
   lcd.print(round(DHT.humidity));
   lcd.print('%');
   lcd.setCursor(9,0);
   lcd.print("Moi:");
   lcd.print(moi_percentage);
   lcd.print("%");


    delay(1000);
//--------------------
//Monitor Processing
//-------------------

    
}

Credits

Iasonas Christoulakis

Iasonas Christoulakis

9 projects • 31 followers
Biomedical Engineer MedispLab Instructor Former General Manager at IEEE NTUA Student Branch

Comments