Design of Agricultural Soil Moisture Monitoring and Automatic Irrigation System Based on 51 SCM

Design of Agricultural Soil Moisture Monitoring and Automatic Irrigation System Based on 51 SCM

1 development environment

Simulation diagram: proteus8.9 or above

Program code: KEIL4/KEIL5

Schematic/PCB:AD

Design number: A0002

(code+simulation+schematic+report+video explanation)

Explanation video

2 Function Description Introduction

Based on 51 single-chip soil moisture detection and potted automatic watering system design,
it is composed of STC89C52 single-chip microcomputer + ADC0832 + LCD1602 liquid crystal + yl-69 soil moisture sensor + 5V pumping motor + button + buzzer.

Specific functions:
1. The first line of the LCD displays the actual humidity, and the second line of the LCD displays the upper and lower limits of humidity;

2. Key description: minus key, plus key, setting key.

3. You can set the upper and lower limits of the humidity alarm range by pressing the button.

4. When the humidity is lower than the lower limit, the water pump will be turned on to pump water and the sound and light will alarm. When the humidity is higher than the upper limit, the water pump will be automatically turned off to stop pumping.

start simulation

1. Start the simulation, the first line displays the measured humidity, the second line shows the high threshold set by SH, the low threshold set by SL, the buzzer does not alarm, and the water pump does not work.

img

2. Change the measured humidity value through the sliding rheostat

img

3. Press the set button, the high threshold will flash, and the high threshold can be changed by adding or subtracting the buttons

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-V2Y6UKN4-1670140003310)(https://picturebed-1300424929.cos.ap-nanjing.myqcloud.com/typora /202212041533063.png)]img

4. When the humidity is lower than the low alarm threshold, the buzzer will alarm, turn on the water pump to pump water and sound and light alarm, and when the humidity is higher than the upper limit, the water pump will be automatically turned off to stop pumping.

img

3 programs

3.1 Engineering documents

img

3.2 Code

img

main function


/***************主函数*****************/

void main()

{

​	init_1602();			  //1602液晶初始化

​	time_init();				//初始化定时器 

​	while(1)

​	{

​		key();					//独立按键程序

​		if(key_can < 10)

​		{

​			key_with();			//按键按下要执行的程序

​		}

​		if(flag_300ms == 1)

​		{		

​			flag_300ms = 0;	 

​			clock_h_l();	 //报警函数 

​			if(beep == 1)

​			{

​				shidu = Adc0832(0);	//读出湿度

​				shidu = 99 - shidu * 99 / 255;

​			}

​			if(menu_1 == 0)

​			{

​				write_sfm2(1,9,shidu);		  //显示湿度等级

​			}

​		} 

​		delay_1ms(1);

​	}

}

The flow chart of the main program flow is after the hardware is initialized, the value is set, and then the humidity sample is collected, and after the humidity sample is passed to the MCU, the MCU system processes the humidity value to determine whether the humidity value is within the range of the set value. If the humidity is lower than the humidity value, stop irrigation. If it is lower than the humidity value, return to humidity sampling and judge the humidity value again until the humidity value is reached. The main program flow chart is shown in Figure 4-1.img

4 List of materials

img
For the download method, see the video at the beginning of the article

Guess you like

Origin blog.csdn.net/Jack_0220/article/details/128174847