【毕业设计】_基于STM32单片机的空气污染检测(原理图+源码)

一. 系统概述

系统利用STM32单片机作为主控单元,通过温湿度传感器和PM2.5传感器对环境进行监测。系统会实时显示温湿度及粉尘浓度,并在粉尘浓度超出预设阈值时触发报警。

在这里插入图片描述

二. 仿真概述

  1. DHT11传感器负责温湿度的检测,检测结果会在LCD1602显示屏上显示。PM2.5传感器的滑动变阻器可以用来调节,当粉尘浓度超出设定值时,系统会发出警报提示。

在这里插入图片描述

  1. 用户可以通过按键进行系统的复位操作,复位后系统的阈值将恢复到初始状态。通过加减按键可以对阈值进行调节。

在这里插入图片描述

三.程序设计

#include <stm32f10x.h>
#include <Lcd1602.h>
#include <key.h>
#include "dht11.h"
#include <Led.h>
#include "PCF8591.h" 

int main(void)
{	
	u8 s,t,h,m=1,smax=30; 
	
	Lcd1602_Init();//pa0-7	pb8-10
	DHT11_Init();//pa12
	Led_Init();//pc0-4
	Key_Init();//pb12-15
	PCF8591_Init();
	
	Lcd1602_Write_String(0x80,2,(u8*)"T:");
	Lcd1602_Write_String(0xc2,1,(u8*)"c");
	Lcd1602_Write_String(0x84,2,(u8*)"H:");
	Lcd1602_Write_String(0xc6,1,(u8*)"%");
	Lcd1602_Write_String(0x88,5,(u8*)"PM2.5");
	Lcd1602_Write_String(0xca,4,(u8*)"mg");
	Lcd1602_Write_String(0x8e,5,(u8*)"H");
	while(1)
	{
		s=PCF8591_ADC_Input(0x90,1);
		Lcd1602_Write_Num8(0xc8,s);	
		Lcd1602_Write_Num8(0xce,smax);

		DHT11_Read_Data(&t,&h);
		Lcd1602_Write_Num8(0xc0,t);
		Lcd1602_Write_Num8(0xc4,h);
		if(Key0==0)	smax++;
		else if(Key1==0)	smax--;

				
		if(Key2==0)	
		{
			m=~m;
		}

		if(s>smax&&m==1)
		{
			Led1_High;
		}
		else				Led1_Low;

		
	}	
}


24-32f-33

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值