Introduction:
Humidity and temperature are common parameters to measure environmental conditions. In this Arduino based project we are going to measure ambient temperature and humidity and display it on a 16x2 LCD screen. A combined temperature and humidity sensor DHT11 is used with Arduino uno to develop this Celsius scale thermometer and percentage scale humidity measurement project.
This project consists of three sections - one senses the humidity and temperature by using humidity and temperature sensor DHT11. The second section reads the DHT sensor module’s output and extracts temperature and humidity values into a suitable number in percentage and Celsius scale. And the third part of the system displays humidity and temperature on LCD
Applications:
It can be used for measuring humidity and temperature values in heating, ventilation and air conditioning systems. Weather stations also use these sensors to predict weather conditions. The humidity sensor is used as a preventive measure in homes where people are affected by humidity Offices, cars, museums, greenhouses and industries use this sensor for measuring humidity values and as a safety measure.
Hardware:
Complete Working:
first of all arduino sends a high to low start signal to DHT11 with 18µs delay to ensure DHT’s detection. And then arduino pull-up the data line and wait for 20-40µs for DHT’s response. OnceDHT detects starts signal, it will send a low voltage level response signal to arduino of time delay about 80µs. And then DHT controller pull up the data line and keeps it for 80µs for DHT’s arranging of sending data.
When data bus is at low voltage level it means that
DHT11 is sending response signal. Once it is done, DHT again makes data line pull-up for 80µs for preparing data transmission.Data format that is sending by DHT to arduino for every bit begins with 50µs low voltage level and length of high voltage level signal determines whether data bit is “0” or “1”.
One important thing is to make sure pull up resistor value because if we are placing DHT sensor at <20 meter distance, 5k pull up resistor is recommended. If placing DHT at longer the 20 meter then use appropriate value pull up resistor.
Conclusion :
Temperature and humidity sensor (or rh temp
sensor) is devices that can convert temperature and humidity into electrical signals that can easily measure temperature and humidity. Temperature humidity transmitters on the market generally measure the amount of temperature and relative humidity in the air, and convert it into electrical signals or other signal forms according to certain rules and output the device to the instrument or software to meet the environmental monitoring needs of users.
Input Diagram:
This project consists of three sections - one senses the humidity and temperature by using humidity and temperature sensor DHT11. The second section reads the DHTsensor module’s output and extracts temperature and humidity values into a suitable number in percentage and Celsius scale. And the third part of the system displays humidity and temperature on LCD.
Working of this project is based on single wire serial communication. First arduino send a start signal to DHT module and then DHT gives a response signal containing temperature and humidity data. Arduino collect and extract in two parts one is humidity and second is temperature and then send them to 16x2 LCD.
Circuit Diagram:
Flow chart :
Programing code:
code:
// firstly need to add i2c library
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
byte degree_symbol[8] =
{
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
int gate=11;
volatile unsigned long duration=0;
unsigned char i[5];
unsigned int j[40];
unsigned char value=0;
unsigned answer=0;
int z=0;
int b=1;
void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight();
lcd.print("Temp = ");
lcd.setCursor(0,1);
lcd.print("Humidity = ");
lcd.createChar(1, degree_symbol);
lcd.setCursor(9,0);
lcd.write(1);
lcd.print("C");
lcd.setCursor(13,1);
lcd.print("%");
}
void loop()
{
delay(1000);
while(1)
{
delay(1000);
pinMode(gate,OUTPUT);
digitalWrite(gate,LOW);
delay(20);
digitalWrite(gate,HIGH);
pinMode(gate,INPUT_PULLUP);//by default it will become high due to internal pull up
// delayMicroseconds(40);
duration=pulseIn(gate, LOW);
if(duration <= 84 && duration >= 72)
{
while(1)
{
duration=pulseIn(gate, HIGH);
if(duration <= 26 && duration >= 20){
value=0;}
else if(duration <= 74 && duration >= 65){
value=1;}
else if(z==40){
break;}
i[z/8]|=value<<(7- (z%8));
j[z]=value;
z++;
}
}
answer=i[0]+i[1]+i[2]+i[3];
if(answer==i[4] && answer!=0)
{
lcd.setCursor(7,0);
lcd.print(i[2]);
lcd.setCursor(11,1);
lcd.print(i[0]);
}
z=0;
i[0]=i[1]=i[2]=i[3]=i[4]=0;
}
}
Comments