Temperature and Humidity Monitoring System using Arduino and dht11

Hello Friends,

Welcome to yet another Arduino project from TEXOBOT.

This time, we will show you how to make a temperature monitoring alarm using Arduino UNO.

This project has great importance in many industries to monitor the temperature and to trigger some specific action like

  • Turn on the exhaust fan

  • opening the emergency exit

  • Notify the user through SMS or push notification

  • Turn on the sprinkler and much more.

Before we move forward, we would like to thank SEEDS STUDIO for sending this kit (Grove Beginner Kit For Arduino)

This kit is based on an Arduino UNO compatible board named Seeeduino Lotus.

The Arduino Uno is one of the most common Arduino boards available for beginners because of its user-friendly nature in both Hardware and programming areas.

The Arduino GROOVE beginner kit makes Arduino more user-friendly by providing 10 essential sensors all-in-one kit, no breadboard, no soldering and even no wiring is needed.

Their website has a great tutorial about the usage of this kit with 10 different programs about each sensor. So even a person has zero knowledge about Arduino can learn this independently.

We strongly recommend this product for beginners who wants to get familiar with Arduino.

Buy Arduino GROOVE beginner kit ........ Aamzon.com / Amazon.in

Let’s understand the working principle of this project.

The temperature sensor will send Temperature and humidly values to the Arduino and the values will be displayed on the OLED display. When the temperature reaches beyond the threshold, Arduino will trigger both LED and Buzzer which will be used to notify the user. OLED display will warn the user about the raise in temperature by displaying a warning icon.

Require Components

Now let’s understand little bit about the sensors used for this project.

The first module is the Grove – Temperature and Humidity sensor

DHT11 Temperature & Humidity sensor provides a pre-calibrated digital output. A unique capacitive sensor element measures relative humidity, and the temperature is measured by a negative temperature coefficient (NTC) thermistor.

The second one is the Grove - OLED Display.

The Grove - OLED Display is a 0.96" 128×64 pixels passive display matrix module with Grove I2C Interface.

The third one is the Groove LED.

.

This sensor has a got a red LED and a potentiometer on-board to manage the power requirements of the LED. The PCB of this module has mounting holes which can be mounted on the required surface of your prototype.

The fourth and last one is the Grove - Buzzer module

The Grove - Buzzer module has a piezo buzzer as the main component. The piezo can be connected to digital outputs and will emit a tone when the output is HIGH. Alternatively, it can be connected to an analog pulse-width modulation output to generate various tones and effects

If you prefer to use these modules elsewhere then you can simply break the modules out from the Kit! All these sensors are compatible with both Arduino and raspberry pi.

You can find the corresponding Arduino pin details of each component on the board itself.

Please refer this circuit diagram if anyone wants to implement this project without using the kit.

Arduino Code

Now we can upload the sketch to our Arduino.

Connect Seediuno to your computer using the USB cable and upload the code shown here.


Arduino libraries download link:


OLED Display header file:- Click here to download

Adafruit Sensor header file:- Click here to download

DHT Library:- Click here to download


Click here to view the Arduino Code

//download ZIP libraries from github link and add to your Arduino IDE by navigating to Sketch --> Include Library --> Add ZIP Library

#include <U8g2lib.h> // OLED Disply header file | downlaod link:- https://downloads.arduino.cc/libraries/github.com/olikraus/U8g2-2.27.6.zip and https://github.com/adafruit/Adafruit_Sensor.git

#include <Wire.h>

#include "DHT.h" // https://github.com/adafruit/DHT-sensor-library


// Temperature bit Map, pixels 20*20

const unsigned char temp_bmp[] U8X8_PROGMEM = {0x00, 0x06, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x09, 0x00, 0x80, 0x19, 0x00, 0x80, 0x19, 0x00, 0xc0, 0x39, 0x00, 0xc0, 0x39, 0x00, 0xc0, 0x39, 0x00, 0xc0, 0x39, 0x00, 0xc0, 0x3f, 0x00, 0x80, 0x1f, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x06, 0x00};

// humidity bitmap, pixels20*20

const unsigned char hum_bmp[] U8X8_PROGMEM= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x80,0x10,0x00,0x00,0x00,0x00,0x40,0x20,0x00,0x20,0x40,0x00,0x20,0x40,0x00,0x10,0x80,0x00,0x10,0x80,0x00,0x08,0x00,0x01,0x08,0x00,0x01,0x08,0x00,0x01,0x08,0x00,0x01,0x08,0x00,0x01,0x08,0x00,0x01,0x10,0x80,0x00,0x00,0x00,0x00,0x40,0x20,0x00,0x80,0x10,0x00};

//TexoBot ICON bitmap, pixels 64*64

const unsigned char texo_bmp[] U8X8_PROGMEM = {

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B11100000, B00000111, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B11111000, B00111111, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B11111110, B01111111, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B11111111, B11111111, B00000001, B00000000, B00000000,

B00000000, B00000000, B10000000, B00001111, B11110000, B00000011, B00000000, B00000000,

B00000000, B00000000, B11000000, B00000011, B11000000, B00000011, B00000000, B00000000,

B00000000, B00000000, B11100000, B00000001, B10000000, B00000111, B00000000, B00000000,

B00000000, B00000000, B11100000, B00000000, B00000000, B00001111, B00000000, B00000000,

B11111110, B11111111, B11111111, B00000000, B00000000, B11111110, B11111111, B01111111,

B11111100, B11111111, B01111111, B00000000, B00000000, B11111110, B11111111, B00111111,

B00000000, B00000000, B00111100, B10000000, B00000001, B00001110, B00000000, B00000000,

B11100000, B11111111, B00111111, B11100000, B00001111, B11111100, B11111111, B00000111,

B11000000, B11111111, B00111111, B10000000, B00000001, B11111100, B11111111, B00000011,

B00000000, B00000000, B00111110, B10000000, B00000001, B00011100, B00000000, B00000000,

B00000000, B11111100, B00111111, B10000000, B00000001, B11111100, B00111111, B00000000,

B00000000, B11111000, B01111111, B10000000, B00001011, B11111110, B00011111, B00000000,

B00000000, B00000000, B01111000, B00000000, B00000111, B00011110, B00000000, B00000000,

B00000000, B00000000, B01110000, B00000000, B00000000, B00001110, B00000000, B00000000,

B00000000, B00000000, B11100000, B00000001, B00000000, B00000111, B00000000, B00000000,

B00000000, B00000000, B11100000, B00000001, B10000000, B00000111, B00000000, B00000000,

B00000000, B00000000, B11000000, B00000011, B11000000, B00000011, B00000000, B00000000,

B00000000, B00000000, B10000000, B00001111, B11110000, B00000011, B00000000, B00000000,

B00000000, B00000000, B00000000, B11111111, B11111111, B00000001, B00000000, B00000000,

B00000000, B00000000, B00000000, B11111110, B01111111, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B11111000, B00111111, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B11000000, B00000011, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,


};


//TexoBot ICON bitmap, pixels pixels 50x50

const unsigned char Warning_bmp[] U8X8_PROGMEM = {

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000011, B00000000, B00000000, B00000000,

B00000000, B00000000, B10000000, B00000111, B00000000, B00000000, B00000000,

B00000000, B00000000, B10000000, B00000111, B00000000, B00000000, B00000000,

B00000000, B00000000, B11000000, B00001111, B00000000, B00000000, B00000000,

B00000000, B00000000, B11100000, B00011111, B00000000, B00000000, B00000000,

B00000000, B00000000, B11100000, B00011100, B00000000, B00000000, B00000000,

B00000000, B00000000, B11110000, B00111000, B00000000, B00000000, B00000000,

B00000000, B00000000, B01111000, B01111000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00111000, B01110000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00111100, B11110011, B00000000, B00000000, B00000000,

B00000000, B00000000, B10011100, B11100111, B00000000, B00000000, B00000000,

B00000000, B00000000, B11001110, B11001111, B00000001, B00000000, B00000000,

B00000000, B00000000, B11001111, B11001111, B00000011, B00000000, B00000000,

B00000000, B00000000, B10000111, B10000111, B00000011, B00000000, B00000000,

B00000000, B10000000, B10000111, B10000111, B00000111, B00000000, B00000000,

B00000000, B10000000, B10000011, B00000111, B00001111, B00000000, B00000000,

B00000000, B11000000, B10000001, B00000111, B00001110, B00000000, B00000000,

B00000000, B11100000, B00000001, B00000011, B00011110, B00000000, B00000000,

B00000000, B11100000, B00000000, B00000011, B00011100, B00000000, B00000000,

B00000000, B01110000, B00000000, B00000011, B00111000, B00000000, B00000000,

B00000000, B01111000, B00000000, B00000000, B01111000, B00000000, B00000000,

B00000000, B00111000, B00000000, B00000011, B01110000, B00000000, B00000000,

B00000000, B00111100, B10000000, B00000111, B11110000, B00000000, B00000000,

B00000000, B00011100, B10000000, B00000111, B11100000, B00000001, B00000000,

B00000000, B00001110, B10000000, B00000111, B11000000, B00000001, B00000000,

B00000000, B00001111, B00000000, B00000000, B11000000, B00000011, B00000000,

B10000000, B11111111, B11111111, B11111100, B11111111, B00000111, B00000000,

B10000000, B11111111, B11111111, B11111111, B11111111, B00000111, B00000000,

B00000000, B11111110, B11111111, B11111111, B11111111, B00000001, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,

B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000


};



char led = 4; // use arduino pin 4 for LED

char buzzer = 5; // user arduino pin 5 for buzzer

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R2, /* reset=*/U8X8_PIN_NONE); //Initialize the display - U8G2_SSD1306_128X64

#define DHTPIN 3 // DHT_sensour outpin will be connected to Arduino pin 3

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

int BuzzerFrequency = 1020; // set buzzer frequenc to 1020Hz

float temp, humi; //variable for string Temperature and humidity values

float temp_limt = 35; // Temperature threshold


void setup() {

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

dht.begin(); // Initialize the DHT sensor with the .begin() method.

pinMode(led, OUTPUT); // set LED pin as output pin

pinMode(buzzer, OUTPUT); // set Buzzer pin as OUTPUT pin

digitalWrite(buzzer, LOW); //Bzzer off

u8g2.begin(); // Initialize the OLED Display sensor with the .begin() method.


TexoBot_ICON(); //call OLED print function to print TexoBot icon

delay(2000);

}


void loop() {

if(temp<temp_limt){ //check wether the current temperature is less than the temperature thresold

Temp_show(); //call OLED print function to print Cureent Temperature and Humidity values

delay(500);

}

else{

tone(buzzer,BuzzerFrequency);

digitalWrite(led,HIGH);

Temperature_Warning(); //call OLED print function to print temperature warning on the screen

delay(250);

digitalWrite(led,LOW);

delay(250);

noTone(buzzer);

digitalWrite(led,HIGH);

delay(250);

digitalWrite(led,LOW);

delay(250);

Temp_show(); //call OLED print function to print Cureent Temperature and Humidity values

delay(500);

}

}




void Temp_show(){ //function for displaying the current temperature and humidity on OLED display



temp = dht.readTemperature();

humi = dht.readHumidity();


u8g2.firstPage();

do {

u8g2.setFont(u8g2_font_t0_16b_mr);

u8g2.setCursor(32, 16);

u8g2.print(F("temp:"));

u8g2.setCursor(72, 16);

u8g2.print(temp);

// u8g2.setCursor(88, 16);

// u8g2.print("C");

u8g2.setCursor(32, 48);

u8g2.print(F("humid:"));

u8g2.setCursor(80, 48);

u8g2.print(humi);


u8g2.drawXBMP(0, 0, 20, 30, temp_bmp);

u8g2.drawXBMP(0, 35, 20, 20, hum_bmp);

} while (u8g2.nextPage());

}


void TexoBot_ICON(){ ////function for displaying the TexoBot icon on OLED display

u8g2.firstPage();

do {

u8g2.setFont(u8g2_font_t0_12b_mr);//

u8g2.drawXBMP(32, 0, 64, 64, texo_bmp);

u8g2.setCursor(44, 54);

u8g2.print(F("TexoBot")); // write something to the internal memory

} while (u8g2.nextPage());

delay(2000);

}


void Temperature_Warning(){

u8g2.firstPage();

do {

u8g2.setFont(u8g2_font_t0_12b_mr);//

u8g2.drawXBMP(41, 10, 50, 50, Warning_bmp);

u8g2.setCursor(43, 15);

u8g2.print(F("CRITICAL"));

u8g2.setCursor(33, 60);

u8g2.print(F("TEMPERATURE"));

// u8g2.setCursor(31, 35);

// u8g2.print(F("Texobot")); // write something to the internal memory

} while (u8g2.nextPage());

delay(2000);

}

We have added comments in the program for better understanding of each codes. We have also added links to watch Arduino IDE installation for Windows and Ubuntu in the description. This will help you to understand more about Arduino if you are using it for the First time.


Project Testing

Now let’s test the project.

We have added our TexoBot Logo to look the project more professional.

TexoBot LogoTemperature and Humidity

Now on the OLED screen you could see the Temperature and Humidity. Let’s increase the temperature by keeping the Lighter close to the DHT 11 temperature sensor. You could see that the temperature and humidity is increasing slowly.

So, after the temperature reaches beyond 35 degree Celsius you could see that Arduino has triggered Both LED and Buzzer. Also a critical temperature warning symbol has appeared on the screen.

Now let’s wait for some time to get the temperature back to normal. Now you could see that the Alarm has stopped and the warning symbol is no more displayed on the OLED Screen.

Watch Full Video:

We hope that you have enjoyed this Project. And we would like to thank you once again for reading this article.

Please do not forget to subscribe to our YouTube channel if you like this video.