Home Garden Monitoring System
by rrbendish in Living > Gardening
1260 Views, 7 Favorites, 0 Comments
Home Garden Monitoring System
This is a system that allows you to monitor the soil moisture percentage, as well as the temperature and humidity in the air. It is fairly simple and cheap to build.
Supplies:
-3 different colored LED's
-10k potentiometer
-LCD Display 16x2
-Temperature and Humidity sensor
-Soil Moisture sensor (you can google soil moisture tester and the one I used will pop up)
-jumper wires
-3 resistors
-power supply
Follow the Schematic
Follow the schematic picture replacing the blue potentiometer with the temperature and humidity sensor. The LCD uses digital pins 12,11,5,4,3,2. Temp and Humidity sensor uses analog pin 1. Soil Moisture sensor uses analog pin 0. The LED's use digital pins 6,8,9.
Upload the Code
#include
#include
#include "DHT.h"
#define DHTPIN A1 // pin the temp. and humidity sensor is hooked up to (analog pin 1)
#define DHTTYPE DHT11 // we are using the DHT11 sensor
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);
int led1 = 6; //LED pin blue
int led2 = 8; //LED pin yellow
int led3 = 9; //LED pin red
int potPin = A0; //input pin for soil sensor (analog pin 0)
int soil=0;
void setup() { Serial.begin(9600);
lcd.begin(16,2); //16 by 2 character display dht.begin();
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
void loop()
{
delay(1000);// Reading temperature or humidity takes about 250 milliseconds!
float h = dht.readHumidity();
float t = dht.readTemperature(); // Read temperature as Celsius (default to be converted later)
lcd.setCursor(0,0); //setting cursor location of where to start printing
lcd.print("T: ");
lcd.print((int)round(1.8*t+32)); //converting celcius to F, prints temp. to the LCD display
lcd.print("*F");
lcd.setCursor(0,1); //setting cursor location of where to start printing
lcd.print("H: "); lcd.print(h); //printing humidity to the LCD display
lcd.print("%");
int soil = analogRead(potPin) ;
soil = constrain(soil, 485, 1023);
soil = map(soil, 485, 1023, 100, 0);
delay(10);
Serial.println(soil);
lcd.setCursor(8,0); //setting cursor location of where to start printing
lcd.print("SM: ");
lcd.print(soil); //printing soil moisture to the LCD display
lcd.print("%");
lcd.print(" "); //clearing for new reading
if (soil >= 75)
{
digitalWrite(led1, HIGH); // if reading is over 75% BLUE LED comes on
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
}
else if (soil >= 35 && soil < 75)
{
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH); // if reading is between 75% and greater than or equal to 35% YELLOW LED comes on digitalWrite(led3, LOW);
}
else if (soil >= 0 && soil <35)
{
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH); // if reading is lower then 35% RED LED comes on
}
delay(100); }
Downloads
Finished
If everything was done correctly your moisture probe should read somewhere under 10% when sitting out in the air. It should also read 100% when placed in a cup of water. The LCD will need to be adjusted with the 10k potentiometer to set the screen contrast that way you can see all the read outs clearly. It's also important to have the resistors in place on the LED's to help protect them.