You are on page 1of 3

#include <DHT.

h>

#include <LiquidCrystal.h>

#define temp 13

#define DHTTYPE DHT22

#define soil A0

#define relay 6

DHT temp_sensors(temp, DHTTYPE);

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

float Celcius=0;

int soil_Value;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

pinMode(soil, INPUT);

pinMode(relay,OUTPUT);

temp_sensors.begin();

lcd.begin(16, 2);

lcd.setCursor(0,0);
lcd.print("temp");

lcd.setCursor(0,1);

lcd.print("moist");

void loop() {

// put your main code here, to run repeatedly:

Celcius=temp_sensors.readTemperature();

Serial.println(Celcius);

lcd.setCursor(5,0);

lcd.print(Celcius);

soil_Value = analogRead(soil);

soil_Value = map(soil_Value,550,0,0,100);

lcd.setCursor(6,1);

lcd.print(soil_Value);

Serial.println(soil_Value);

if(soil_Value>=0)

digitalWrite(relay,HIGH);

else if(soil_Value<0){

digitalWrite(relay,LOW);

}
delay(1000);

You might also like