Project showcase
DHT22 Applied To Automatic Irrigation

DHT22 Applied To Automatic Irrigation © GPL3+

Humidity and temperature sensor DHT22 applied to automatic irrigation.

  • 5,330 views
  • 3 comments
  • 17 respects

Components and supplies

Apps and online services

About this project

Humidity and temperature sensor with DHT22 applied to automatic irrigation and switch with transistor, perfect for projects in which temperature and humidity must be controlled and maintained at a certain percentage. The project in this case is developed with an external power source of 12v connected to a motor for water conduction, only drives voltage to the motor when in the transistor there is voltage sent from the arduino to the door of the same, the programming of the Arduino tells me that the temperature must be less than 30 degrees Celsius, if that temperature is exceeded the arduino sends voltage to the transistor and allows me to drive the voltage from the power source to the motor activating the irrigation with nebulizers.

Code

Humidity and temperature sensor with DHT22 and switch with transistor BC547Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 6 //Pin 6 del Arduino Uno
#define DHTTYPE DHT22 //Definir el sensor como un DHT22

DHT dht(DHTPIN, DHTTYPE);

float temperatura;
float humedad;

void setup()
{
  lcd.begin(16, 2);
  pinMode(13, OUTPUT);
 }

void loop()
{
  delay(2000); //Tiempo de espera entre una lectura y otra. Para el DHT22 son 2 segundos
    
  temperatura = dht.readTemperature(); //Lee la temperatura
  humedad = dht.readHumidity(); //Lee la humedad

  lcd.setCursor(0, 0);  //Muestra la temperatura
  lcd.write("Temp.: ");  
  lcd.print(temperatura);  
  lcd.write(" C");

  lcd.setCursor(0, 1);  //Muestra la humedad
  lcd.write("Hume.: ");  
  lcd.print(humedad);  
  lcd.write(" %");

if (temperatura >= 30)
   {
   digitalWrite(13, HIGH); // Enciende el Led 13.
   Serial.write("ON"); // Envía por el puerto ON.

    }
else
   {
      digitalWrite(13, LOW); // Apaga el Led 13.
      Serial.write("OFF"); // Envía por el puerto OFF.
   }
   }


 

Comments

Add projectSign up / Login