51 Microcontroller Temperature and Humidity Controller

AD Package Library Components Collection:Package Library

Resource Directory:

51 Microcontroller Temperature and Humidity Controller

This design

is based on the 51 microcontroller temperature and humidity controller system design (Proteus simulation + program + schematic + component list + simple report)

Schematic: Altium Designer

Simulation diagram Proteus 7.8/8.9 (theoretically can be opened with versions higher than 7.8)

Program compiler: Keil 4/Keil 5

Programming language: C language

NumberS0013

Basic functions:

1. This design is based on the STC89C51/52 (compatible with AT89C51/52, AT89S51/52, can choose any) microcontroller;

2. AT24C02 chip for power-off storage of upper and lower limits;

3. Four buttons for setting, increasing, decreasing, and confirming, achieving threshold adjustment;

4. LCD1602 liquid crystal display, the upper line shows the current temperature and humidity, the lower line shows the corresponding cold, hot, dry, wet;

5. Equipped with a fully digital temperature and humidity sensor DHT11, temperature measurement range 0℃–50℃, humidity measurement range 20%RH—90%RH, can meet general needs;

6. When exceeding the threshold, a buzzer flashes to alert. There is a switch to turn the alarm on or off;

7. When the temperature or humidity exceeds the limit, the alarm signal light lights up and the corresponding relay is engaged. The relay can drive external devices such as fans, dehumidifiers, heaters, coolers, humidifiers, alarms, etc.

Simulation diagram (source file provided):

51 Microcontroller Temperature and Humidity Controller

Program (source code provided):

51 Microcontroller Temperature and Humidity Controller

The following is part of the program, the complete program can be obtained from the download link:

void main(){    uint i, j, testnum;    EA = 0;    Timer0_Init();  // Timer 0 initialization    Data_Init();    EA = 1;    L1602_init();    L1602_string(1,1," ID:GO66666666 ");    L1602_string(2,1,"  Smalldi@2017");    for (i=0;i<1000;i++)       for (j=0;j<1000;j++)       {;}    // Clear screen    L1602_string(1,1,"                ");    L1602_string(2,1,"                ");    L1602_string(1,1,"Tem:   C Hum:  %");    L1602_string(2,1,"Smalldi@2017");    TH=rdeeprom(0);       Delay1(20);     // Add delay to stabilize    TL=rdeeprom(1);    Delay1(20);    HH=rdeeprom(2);    Delay1(20);    HL=rdeeprom(3);
    while(1)    {             if (FlagStartRH == 1)   // Temperature and humidity conversion flag check       {         TR0 = 0;         testnum = RH();         FlagStartRH = 0;         TR0 = 1;         humidity = U8RH_data_H;   // Read temperature and humidity, only take the integer part         temperature = U8T_data_H;               if(Mode==0)    // Temperature and humidity control         {           if (temperature > TH)          {            Led_jiangwen = 0;            hot=1;            Led_shengwen = 1;            cold=0;          }          else if(temperature<TL)          {            Led_shengwen = 0;            cold=1;            Led_jiangwen = 1;            hot=0;            buzz=0;          }                      else          {            Led_jiangwen=1;            Led_shengwen=1;            hot=0;            cold=0;            buzz=1;          }          if (humidity > HH)          {            Led_qushi = 0;            humid=1;            Led_jiashi = 1;            dry=0;          }          else if(humidity<HL)          {            Led_jiashi = 0;            dry=1;            Led_qushi = 1;            humid=0;          }              else          {            Led_qushi=1;            Led_jiashi=1;            humid=0;            dry=0;          }           }         else         {           Led_shengwen=1;          Led_jiangwen=1;          Led_jiashi=1;          Led_qushi=1;          hot=0;          cold=0;          humid=0;          dry=0;          BJ=0;         }        }    display();    KEY();  }  }

Schematic (source file provided):

51 Microcontroller Temperature and Humidity Controller

Data list:

51 Microcontroller Temperature and Humidity Controller

Download link for materials:

51 Microcontroller Temperature and Humidity Controller

Note: The simulation program and other source files need to be opened on a computer. Download to the computer and then use the extraction password to decompress! Do not use a mobile phone to decompress! For more resources, scan the QR code at the top of the article to search for related designs.

Leave a Comment