SHT11 temperature and humidity upper and lower limit LCD12864 display alarm simulation design based on 51 microcontroller (proteus simulation + program + schematic + report + explanation video)

51 microcontroller SHT11 temperature and humidity upper and lower limit LCD12864 display alarm simulation design (proteus simulation + program + schematic + report + explanation video)


51 microcontroller SHT11 temperature and humidity upper and lower limit LCD12864 display alarm simulation design (proteus simulation + program + schematic + report + explanation video)

Simulation diagram proteus7.8 and above

Program compiler: keil 4/keil 5

Programming language: C language

Design number: S0043

Explainer video

51 microcontroller SHT11 temperature and humidity upper and lower limits LCD12864 display alarm proteus simulation design

1. Main functions:

Use the knowledge you have learned to create a 51 microcontroller temperature and humidity upper and lower limit LCD12864 display alarm simulation

1. Measure the temperature and humidity of SHT11 and display it through 12864;

2. You can set the upper and lower limits of temperature and humidity through buttons, and alarm when the measured value of temperature and humidity exceeds the limit;

3. The greater the temperature and humidity deviate from the normal value, the higher the buzzer frequency will be.

4. The default lower temperature threshold is 10°C and the upper temperature limit is 40.00°C. The lower limit of humidity defaults to 30%, and the upper limit mode is 60%.

It should be noted that the 51 microcontroller chip in the simulation is universal. AT89C51 and AT89C52 are specific models of the 51 microcontroller, and the cores are compatible. Regardless of stc or at, the pin functions are the same and the program is the same. The chip can be replaced with 51 microcontroller chips such as STC89C52/STC89C51/AT89C52/AT89C51.

The following is a display diagram of this design information:

2. Simulation

Start simulation

Open the simulation project, double-click the microcontroller in proteus, select the hex file path, and then start simulation. After starting the simulation, LCD12864 displays the temperature and humidity.

img

During the simulation, adjust the value of the SHT11 temperature and humidity module by pressing the buttons to change the displayed value.

img

imgThe up and down arrows are used to change the temperature/humidity value. The down arrow decreases the value, and the up arrow increases the value. imgUse this arrow to change whether the adjusted value is temperature or humidity.

imgThe changed icon displays the values ​​of humidity and temperature. The humidity value is on the first line and the temperature value is on the second line.

After starting the simulation, press the Set/Switch button to adjust the upper and lower thresholds. The default lower temperature threshold is 10°C and the upper temperature limit is 40.00°C. The lower limit of humidity defaults to 30%, and the upper limit mode is 60%.

img

After starting the simulation, after adjusting the humidity to exceed 60% of the humidity upper limit threshold, the buzzer will alarm. The larger the value exceeds the humidity upper limit, the sharper the buzzer alarm will sound, and LCD12864 will display an over limit.

img

After starting the simulation, after adjusting the humidity to be lower than the humidity lower limit threshold by 30%, the buzzer will alarm. The greater the value below the humidity lower limit, the sharper the buzzer alarm sound will be, and LCD12864 will display an over limit.

img

After starting the simulation, when the adjusted temperature exceeds the temperature upper limit threshold of 40°C, the buzzer will alarm. The larger the value exceeds the temperature upper limit, the sharper the buzzer alarm sound will be, and LCD12864 will display an over limit. It should be noted that when adjusting the temperature, the humidity of SHT11 will be affected by temperature compensation, and the value will change. In actual application, the humidity parameter is corrected, which is not reflected in the simulation, so the humidity value in the simulation will appear the same as that of SHT11 The module displays a large error, which is normal.

img

After starting the simulation, after adjusting the temperature to be 10°C lower than the lower temperature limit threshold, the buzzer will alarm. The greater the value below the lower temperature limit, the sharper the buzzer alarm will sound, and LCD12864 will display an over limit.

img

3. Program code

Use keil4 or keil5 to compile, the code has comments, and you can understand the meaning of the code in conjunction with the report.

img

Main function code

void main()
{
    
    
    uchar i=0;
	lcd_init();                 // 初始化
    lcd_clear(0);               // 清屏
    lcd_set_line(0);             // 设置起始行为0

 	TMOD|=0X01;
	TH0=0X3C;
	TL0=0XB0;	
	ET0=1;//打开定时器0中断允许
	EA=1;//打开总中断
	TR0=1;//打开定时器
    while (1)
	{
    
    
		//按键检测
		if(!k1)//设置
		{
    
    
			if(mode<4)
				mode++;
			else
				mode=0;
			while(!k1);
		}
		if(mode==1)//设置温度下限
		{
    
    
			if(!k2)
			{
    
    
				if(wen_set1<wen_set2)
					wen_set1+=1;
				while(!k2);
			}
			if(!k4)
			{
    
    
				if(wen_set1<wen_set2)
					wen_set1+=0.1;
				while(!k4);
			}
			if(!k3)
			{
    
    
				if(wen_set1>-81.11)
					wen_set1-=1;
				while(!k3);
			}
			if(!k5)
			{
    
    
				if(wen_set1>-81.11)
					wen_set1-=0.1;
				while(!k5);
			}

		}
		if(mode==2)//设置温度上限
		{
    
    
			if(!k2)
			{
    
    
				if(wen_set2<81.11)
					wen_set2+=1;
				while(!k2);
			}
			if(!k4)
			{
    
    
				if(wen_set2<81.11)
					wen_set2+=0.1;
				while(!k4);
			}

			if(!k3)
			{
    
    
				if(wen_set2>wen_set1)
					wen_set2-=1;
				while(!k3);
			}
			if(!k5)
			{
    
    
				if(wen_set2>wen_set1)
					wen_set2-=0.1;
				while(!k5);
			}
		}
		if(mode==3)//设置湿度下限
		{
    
    
			if(!k2)
			{
    
    
				if(shi_set1<shi_set2)
					shi_set1+=1;
				while(!k2);
			}
			if(!k4)
			{
    
    
				if(shi_set1<shi_set2)
					shi_set1+=0.1;
				while(!k4);
			}

			if(!k3)
			{
    
    
				if(shi_set1>1.1)
					shi_set1-=1;
				while(!k3);
			}
			if(!k5)
			{
    
    
				if(shi_set1>1.1)
					shi_set1-=0.1;
				while(!k5);
			}

		}
		if(mode==4)//设置湿度上限
		{
    
    
			if(!k2)
			{
    
    
				if(shi_set2<81)
					shi_set2+=1;
				while(!k2);
			}
			if(!k4)
			{
    
    
				if(shi_set2<81)
					shi_set2+=0.1;
				while(!k4);
			}

			if(!k3)
			{
    
    
				if(shi_set2>shi_set1)
					shi_set2-=1;
				while(!k3);
			}
			if(!k5)
			{
    
    
				if(shi_set2>shi_set1)
					shi_set2-=0.1;
				while(!k5);
			}

		}
		//蜂鸣器
		if(beep_time>0)
		{
    
    
			if(sec<beep_time)
			{
    
    
			 	sec++;
				delay(15);
			}
			else
			{
    
    
				sec=0;
				beep=!beep;
			}
		}
	}
}

4. Schematic diagram

The schematic diagram is drawn using AD and can be used as a reference for linking to the physical object. Simulation is different from the physical object. If you are inexperienced, do not easily create the physical object. Novices will make many stupid mistakes when making physical objects, which will take a lot of time. This design does not provide answers to questions about physical objects.

The difference between Proteus simulation and physical works:

1. Running environment: Proteus simulation runs on the computer, while the real thing runs on the hardware circuit board.

2. Debugging method: In Proteus simulation, you can easily perform single-step debugging and observe changes in variable values, while in real objects, you need to debug through a debugger or serial port output.

Circuit connection method: In Proteus simulation, the circuit connection can be modified through software settings, but in the real thing, it needs to be modified through the hardware circuit board and connecting wires.

3. Running speed: Proteus simulation usually runs faster than the real thing, because the simulation is based on computer operation, while the real thing needs to consider factors such as the physical limitations of the circuit board and the response time of the device.

4. Function realization: In Proteus simulation, different functions can be realized through software settings, but in real objects, they need to be realized according to the circuit design and device performance.

img

The components list is as follows:

Number of component models

Microcontroller AT89C51 1

Capacitor 10uf 1

Capacitor 30pf 2

Crystal oscillator 12MHZ 1

Resistor 10k 1

Button 6

Temperature and humidity sensor SHT11 1

Potentiometer 1k 1

Resistor 1k 1

Transistor PNP 1

Buzzer passive 1

Display LCD12864 1

Exclusion 10k 1

5. Design report

7386-word design report, including design block diagram, introduction, hardware design introduction, software design introduction, simulation debugging, summary and references.

img

6. Design information content list & download link

Material design materials include simulation, program code, explanation videos, functional requirements, design reports, software and hardware design block diagrams, etc.

0. Common usage problems and solutions – a must-read! ! ! !

1. Simulation diagram

2. Program source code

3. Proposal report

4. Schematic diagram

5. Components list

6. Impression tools and their use

7. Software and hardware flow chart

8. Functional requirements

9. Design report

Altium Designer Software Information

KEIL software information

Proteus software information

Microcontroller learning materials

Defense skills

Common descriptions for design reports

Double-click the mouse to open and find more 51 STM32 Microcontroller Course Graduation Project.url

img

Data download link (clickable):

Guess you like

Origin blog.csdn.net/weixin_52733843/article/details/132634975