Humidity & Temperature Alarm with Arduino Nano

 DHT11 is a humidity and temperature sensor module used to monitor environment humidity and temperature. It can also be used to check healthy environment condition for plants or human beings. Here a simple automatic environment humidity and temperature monitoring system with alarm is demonstrated that sounds alarm from buzzer if the environment temperature is outside the range 20 to 25 degree Celsius and environment humidity is outside the range 35% to 40%. Arduino Nano is used to acquire the humidity and temperature data from the DHT11 and is also used to display the temperature and humidity on LCD.

Circuit Diagram of Humidity & Temperature Alarm with Arduino Nano

The following shows the circuit diagram of interfacing Arduino Nano, DHT11 module and LCD.

Arduino Nano DHT11 LCD Buzzer circuit diagram
The above circuit diagram shows how the LCD, Buzzer and DHT11 module are connected to the Arduino Nano. The whole system circuit is powered using 5V power supply.

DHT11 Sensor

The following picture shows DHT11 sensor module.

dht11 module

The DHT11 module has three pins- Vcc, Data and ground. The Vcc and ground are connected to power source from 3.3V to 5V and ground is connected to the power ground. The data pin is used to acquire humidity and temperature data using microcontroller or microprocessor or MCU board like Arduino Nano. Here it is shown how to interface DHT11 module with Arduino Nano, acquire the humidity and temperature data and display on a 16x2 LCD(Liquid Crystal Display). The DHT11 module data pin is connected to digital pin 9 of Arduino Nano.

Buzzer

The sound buzzer which sounds alarm if the temperature is outside the range 20 to 25 degree Celsius or if the humidity is outside the range 35% to 40%. In the above circuit diagram the buzzer is turned on and off using a BC547 transistor. The base of the BC547 transistor is connected to the Arduino Nano digital pin 8 with 1KOhm resistor in series. The buzzer is connected to the BC547 BJT transistor collector. The emitter is grounded.

LCD

A 16x2 LCD is connected to the Arduino Nano pins 7 to 2 as shown in the above circuit diagram. A 10Kohm potentiometer is connected to control the contrast of the LCD.

Program Code

The following is the Arduino Nano program code that displays the current environment humidity and temperature on LCD and sounds alarm if the temperature is out of the range 20 to 25 degree Celsius and if the humidity is out of range of 35% to 40%.

#include <LiquidCrystal.h>

#include <DHT.h>    //include the DHT library


#define DHTTYPE DHT11 // define DHTTYPE as dht11
#define DHTPIN 9     // define DHTPIN as pin 9

#define RS 7
#define EN 6
#define D4 5
#define D5 4
#define D6 3
#define D7 2

#define buzzPin 8

// initialize the LCD library
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);

// initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);   

void setup () {
  dht.begin();
  lcd.begin(16, 2);
  pinMode(buzzPin, OUTPUT);
  // print initial message to the LCD.
  lcd.print("DHT11");
  lcd.setCursor(0, 1);
  lcd.print("Humidity/Temp.");
}


void loop() {
  delay(1000);  // Wait one seconds between measurements
  float H = dht.readHumidity();     //Read Humidity
  float T = dht.readTemperature();    // Read temperature in Celsius

    // Check if any reads failed and if exit
    if (isnan(H) || isnan(T)) {
    lcd.print("Failed to read!");
    return;
    }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Humidity:"); 
  lcd.print(H);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print("Temp.:"); 
  lcd.print(T);
  lcd.print((char)223);
  lcd.print("C");

  if(T<20.0 || T>25.0){
	digitalWrite(buzzPin, HIGH);
	}
  else if(H<35.0 || H>40.0){
	digitalWrite(buzzPin, HIGH);
	}
  else{
	digitalWrite(buzzPin, LOW);
	}
  
}

 Video Demonstration

 The following video demonstrates how the humidity and temperature alarm with Arduino Nano. It shows as the temperature gets outside the 20 to 25 degree Celsius or if the humidity gets outside the 35% to 40% then buzzer will sound.


Summary

So here it was demonstrated how can build a humidity and temperature alarm system using Arduino Nano, DHT11 sensor module, Buzzer and LCD. The buzzer sounded alarm when the environment temperature or humidity is outside a pre-selected range. One can add to this system DC motor that is turned on by Arduino Nano if the temperature is high or humidity is high to lower the temperature or humidity. See the tutorial Arduino Nano & LDR controlled DC Motor for learning how to control dc motor using Arduino Nano.

Post a Comment

Previous Post Next Post