This project is a full sensor suite device for a garden or your indoor plants. This has a Moisture Sensor, Temperature/ Humidity Sensor, Light Sensor and Real Time Clock that output to a 20×4 LCD I2C screen.
Note:
- If the project fails to print out to screen it may be an issue with the DS3231 Clock module. Comment out the clock code and see if it works.
Prerequisite Classes:
- Arduino – I2C 20 x 4 LCD Display
- Arduino Modules – Real Time Clock Setup (DS3231)
- Arduino Sensors – DHT11 Temperature/ Humidity Sensor Setup
- Arduino – Photoresistor (Light Sensor)
- Arduino – Soil Moisture Sensor
Libraries:
- New Liquid Crystal Library – https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
- Liquid Crystal I2C Library – https://www.arduinolibraries.info/libraries/liquid-crystal-i2-c
- Adafruit DHT Library – https://github.com/adafruit/DHT-sensor-library
- DS3231 Library – http://www.rinkydinkelectronics.com/library.php?id=73
Functional Parts in the Project:
- Arduino Uno – https://store.arduino.cc/usa/arduino-uno-rev3
- 20 x 4 I2C LCD Screen – https://amzn.to/2JVuKzn
- 560 Piece Jumper Wire Kit – https://amzn.to/2MsCLjL
- 220 Ohm Resistors – https://amzn.to/2RiiMD9
- Breadboard Kit – https://amzn.to/2Xih5ei
- DS3231 Clock Modules – https://amzn.to/3brhqyd
- 3V Batteries – https://amzn.to/360DIGa
- Soil Moisture Sensor – https://amzn.to/2jEDyjQ
- Photoresistor – https://amzn.to/2lfakbA
- DHT11 Sensor – https://amzn.to/3fUOqST
#include <DHT.h>
#include <DS3231.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
//Light Sensor
#define lightSensor A0
//Soil Moisture Sensor
#define moistureSensor A1
//Configure DHT11 Sensor
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
//Configure I2C 20x4 LCD Display
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);
//Configure DS321 Real Time Clock
DS3231 rtc(6, 7);
void setup()
{
//Start LCD Screen
lcd.begin(20, 4);
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH);
//Start Temperature Sensor
dht.begin();
//Start Clock
rtc.begin();
//The following lines can be uncommented to set the date and time
//rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
//rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(1, 1, 2014); // Set the date to January 1st, 2014
}
void loop()
{
//2 Second Delay to Allow DHT11 to Calibrate
delay(2000);
//Get Light Level
int lightLevel = analogRead(lightSensor);
//Get Moisture Level
int moistureLevel = analogRead(moistureSensor);
//Standard LCD Print Out
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(rtc.getTimeStr());
lcd.setCursor(10,0);
lcd.print(rtc.getDateStr());
lcd.setCursor(0, 1);
lcd.print("Temp ");
lcd.setCursor(5, 1);
lcd.print(dht.readTemperature(true));
lcd.setCursor(11, 1);
lcd.print("Hum ");
lcd.setCursor(15, 1);
lcd.print(dht.readHumidity());
lcd.setCursor(0,2);
lcd.print("Light Level:");
lcd.setCursor(13,2);
lcd.print(lightLevel);
lcd.setCursor(0,3);
lcd.print("Moisture Level: ");
lcd.setCursor(16,3);
lcd.print(moistureLevel);
}
Be the first to comment