Room temperature meter (DHT11 + MAX7219 + Arduino pro mini)

 INTRODUCTION

Temperature is one of the important parameter and it needs to measured and monitored in many systems. Finding a perfect temperature sensor that satisfies your projects need is very important, for example if you need to measure body temperature in a medical system then you may need a temperature sensor that is sensitive to small changes. On other hand if you want to measure room temperature then you may not need that much of a sensitive sensor, DHT 11 would be a perfect sensor for that.  

What is DHT 11 sensor?

A  DHT 11 (pronounced DHT eleven) is a temperature and humidity sensor. The sensor module consists of a temperature sensor and humidity sensor connected to a 8-bit microcontroller. The sensors are calibrated to give accurate readings. 


It's small size and low power consumption makes it ideal for projects. There are some precautions we need to take while using this sensor like, 1. The soldering temperature must be less than 260 Celsius,  2.  Avoid the sensor under dew conditions,  3. Do not use this sensor in safety or emergency devices, 4. Keep the sensor at temperature 10 to 40 Celsius and humidity less than 60%RH.

Temperature range is 0 to 50 Celsius with plus minus 2 degree Celsius of accuracy. 

Humidity range is 20%RH to 90%RH  with plus minus 5%RH of accuracy. 

So it's not that sensitive sensor but it does the job.

Components required and circuit diagram

Components list - 

  1. Arduino pro mini
  2. DHT 11 sensor
  3. MAX7219 display module
  4. 5V power supply
  5. CP2102 USB to UART converter
  6. Breadboard and some jumper wires (male to female) 
Circuit block diagram connect the circuit as per above given circuit block diagram.

The DHT 11 and MAX7219 display module both require 5V DC supply. The CP2102 is used for programing the Arduino pro mini as it doesn't have inbuilt USB to UART converter. 

Required libraries

Two libraries are required in this projects code. One is for DHT 11 sensor and another is for MAX7219 display module. 

For DHT 11 sensor     

step1 - open Arduino IDE then click on sketch > include library > manage libraries


Step2 - Search for DHT 11 and you will find DHT sensor library by Adafruit (version 1.4.4) . Install that. 


the library is successfully installed.

For MAX7219 display module

This library is written by me. If you appreciate my efforts please contribute and download

Step 1 - This GitHub page will open. Click on "seg_display_lib.zip".



step 2 - Click on download

The zip file will now be downloaded.  

step 3 - Now we need to include the library in Arduino IDE. 
             open Arduino IDE > Click on sketch > Click on include library > Click on add zip library >
             browse to folder where zip file is downloaded > Select the zip file.
 



This will add the library in Arduino's library folder. 
To understand the display module library click here
Both the libraries are now successfully installed. Now we are ready to execute the code, let's see the code. 


Arduino sketch for the project

#include <seg_display_lib.h>   // include the display module library
#include "DHT.h"               // include the DHT header file  
#define DHTPIN 2               // data pin of DHT 11 is on pin 2 of arduino
#define DHTTYPE DHT11          // We are using DHT 11, there is also DHT 22 
DHT dht(DHTPIN, DHTTYPE);      // the pin and type goes as arguments in this function

int d = 9;   // Din pin of MAX7219 disp module is on pin 9 of Arduino               
int s = 8;   // CS pin of MAX7219 disp module is on pin 8 of Arduino 
int c = 7;   // Clk pin of MAX7219 disp module is on pin 7 of Arduino 

void setup() {
  Serial.begin(9600);         // baud rate is 9600
  Serial.println(F("DHTxx test!")); // test message
  dht.begin();            //Start reading from module
  pinMode(d,OUTPUT);     // All disp module pins are output
  pinMode(s,OUTPUT);
  pinMode(c,OUTPUT);
  disp_init(d,s,c);     // initialize the disp module by running all the initial commands 
}

void loop() {
   delay(1000);  // wait for 1sec here
   int t = dht.readTemperature(); //read the temperature in celcius and put in t variable.
   
   if (isnan(t)) {         // if fail to read temperature then display fail
    seg_dis("FAL",d,s,c);
    return;
  }
  disp(t,d,s,c);  // display the temperature on the display module.       
}                     //end of void loop


Output after running the code.




If you found this blog useful and want to support me, then you can donate me. The money you give will be used to make more advance electronics projects and setting up better lab.


Comments

Popular posts from this blog

Getting started with 7 segment module