基于stm32单片机的环境监测系统
科技驱动的环保监测系统实时监控环境污染 #生活知识# #科技生活# #科技改变生活# #科技环保#
功能介绍 stm32单片机为控制核心采用温湿度传感器检测当前温度湿度采用pm2.5传感器检测空气中pm2.5数值当数字超过设定阈值蜂鸣器报警采用二氧化碳传感器检测空气中二氧化碳浓度当二氧化碳浓度超过设定阈值蜂鸣器报警。按键设置参数阈值采用烟雾传感器检测室内烟雾浓度当烟雾浓度超过设定阈值风扇开启通风
采用无线通信模块进行远程监测控制蓝牙5V电压供电实物可做
电路图PCB
源代码
u8 Temperature_High;
u8 Temperature_Low;
u8 Humidity_High;
u8 Humidity_Low ;
u8 SoilHumidity_High;
u8 SoilHumidity_Low;
u8 Air_High;
u16 LightLux_High;
u16 LightLux_Low ;
double Humidity;
double Temperature;
double SoilHumidity;
double Lightlux;
double SoilTemperature;
double Air;
u8 Auto;
u8 flag=0;
u8 flag0=0;
u8 flag1=0;
u8 flag2=0;
u8 flag3=0;
u8 flag4=0;
u8 channel;
u8 AirAlarm=0;
u8 Airflag=0;
int main(void)
{
unsigned char temp[256];
System_Init();
u1_printf("系统初始化成功\r\n");
while(WiFi_ConnectServer())
{
delay_ms(2000);
}
WiFi_RxCounter=0;
memset(WiFi_RX_BUF,0,WiFi_RXBUFF_SIZE);
Connect_flag = 1;
WiFi_Send("{\"state\":1}",strlen("{\"state\":1}"),500);
OLED_ShowCHinese(12,2,26);
OLED_ShowCHinese(28,2,27);
OLED_ShowCHinese(44,2,28);
OLED_ShowCHinese(60,2,29);
OLED_ShowChar(76,2,':',16);
OLED_ShowCHinese(4,4,33);
OLED_ShowCHinese(20,4,34);
OLED_ShowCHinese(36,4,35);
OLED_ShowCHinese(52,4,36);
OLED_ShowChar(68,4,':',16);
OLED_ShowChar(108,4,'%',16);
OLED_ShowCHinese(8,6,22);
OLED_ShowCHinese(24,6,23);
OLED_ShowChar(40,6,':',16);
OLED_ShowString(96,6,"Lux",16);
if(Auto)
{
OLED_ShowCHinese(84,2,32);
OLED_ShowCHinese(100,2,31);
}
else
{
OLED_ShowCHinese(84,2,30);
OLED_ShowCHinese(100,2,31);
}
memset(temp,0,256);
sprintf((char*)temp,"{\"AirAlarm\":%d}",AirAlarm);
WiFi_Send(temp,strlen((char*)temp),500);
TIM3_ENABLE_1S();
TIM1_ENABLE_2ms();
while(1)
{
if(flag0)
{
tim3_OK();
}
KeyDriver1();
WifiDataHandle();
AutoPattern();
if(Air>Air_High)
{
AirAlarm=1;
}
else
{
AirAlarm=0;
}
if(Airflag!=AirAlarm)
{
memset(temp,0,256);
sprintf((char*)temp,"{\"AirAlarm\":%d}",AirAlarm);
WiFi_Send(temp,strlen((char*)temp),500);
}
Airflag=AirAlarm;
}
}
void tim3_OK(void)
{
u8 temp1[256];
TempHumi_State();
SoilHumidity_State();
SoilTemperature_State();
Light_State();
MQ_State();
if(flag)
{
memset(temp1,0,256);
sprintf((char*)temp1,"%2.1f",Temperature);
OLED_ShowString(76,0,temp1,16);
memset(temp1,0,256);
sprintf((char*)temp1,"%2.1f",Humidity);
OLED_ShowString(72,2,temp1,16);
memset(temp1,0,256);
sprintf((char*)temp1,"%2.1f",SoilTemperature);
OLED_ShowString(76,4,temp1,16);
memset(temp1,0,256);
sprintf((char*)temp1,"%2.1f",SoilHumidity);
OLED_ShowString(72,6,temp1,16);
}
else
{
memset(temp1,0,256);
sprintf((char*)temp1,"%.2f",Lightlux);
OLED_ShowString(48,6,temp1,16);
memset(temp1,0,256);
sprintf((char*)temp1,"%.2f",Air);
OLED_ShowString(76,4,temp1,16);
}
flag0=0;
}
void AutoPattern(void)
{
if(Auto==1)
{
if(SoilHumidity_High<SoilHumidity)
{
if(flag1==0)
{
WATER_OFF;
WATER_State();
flag1=1;
}
}
else if(SoilHumidity_Low>SoilHumidity)
{
if(flag1==0)
{
WATER_ON;
WATER_State();
flag1=1;
}
}
else
{
flag1=0;
}
if(LightLux_High<Lightlux)
{
if(flag2==0)
{
LED_OFF;
LED_State();
flag2=1;
}
}
else if(LightLux_Low>Lightlux)
{
if(flag2==0)
{
LED_ON;
LED_State();
flag2=2;
}
}
else
{
flag2=0;
}
if(Humidity_High<Humidity)
{
if(flag3==0)
{
FAN_ON;
FAN_State();
flag3=1;
}
}
else if(Humidity_Low>Humidity)
{
if(flag3==0)
{
FAN_OFF;
FAN_State();
flag3=2;
}
}
else
{
flag3=0;
}
if(Temperature_High<Temperature)
{
if(flag4==0)
{
flag4=1;
StepMotor_CCW();
WiFi_Send("{\"RiShSt\":1}",strlen("{\"RiShSt\":1}"),500);
}
}
else if(Temperature_Low>Temperature)
{
if(flag4==0)
{
flag4=2;
StepMotor_CW();
WiFi_Send("{\"RiShSt\":0}",strlen("{\"RiShSt\":0}"),500);
}
}
else
{
flag4=0;
}
}
}
void System_Init(void)
{
IIC_Init();
Out_Init();
delay_init();
OLED_Init();
OLED_Clear();
OLED_ShowCHinese(0,0,39);
OLED_ShowCHinese(16,0,40);
OLED_ShowCHinese(32,0,4);
OLED_ShowCHinese(48,0,5);
OLED_ShowCHinese(64,0,41);
OLED_ShowCHinese(80,0,37);
OLED_ShowCHinese(96,0,2);
OLED_ShowCHinese(112,0,3);
Adc_Init();
Usart1_Init(115200);
Usart2_Init(115200);
TIM4_Init(1000,7200);
KEY_Init();
StepMotor_Init();
ReadBackup();
TempHumi_State();
SoilHumidity_State();
Light_State();
SoilTemperature_State();
MQ_State();
WiFi_ResetIO_Init();
RxBuff_Init();
}
元器件清单 基于stm32单片机的环境监测系统名称型号数量单片机STC89C521晶振11.0592M1电解电容10uF1电解电容1000uf1瓷片电容22pF2电阻10K3电阻1K4电阻2K1蜂鸣器有源1三极管S90121按键5显示屏LCD16021排针16P1排母16P1人体红外模块HC-SR5011排母3P1温度传感器DS18B201烟雾传感器MQ-21模数转换器ADC08321IC座8P1GSM模块SIM800c1电源座5MM1电源线5V2A1自锁开关1继电器1小水泵1导线若干焊锡丝若干 参考文献参考文献
[1]王德保.GPS在城市控制网中的应用研究[D].山东:山东科技大学,2005.
[2]何立民.从现代计算机视角看嵌入式系统(4)嵌入式系统40年发展史[J].单片机与嵌入式系统应用,2016,16(04):77-79.
[3]康桂霞,刘达.FPGA应用技术教程[M].北京:人民邮电出版社:201306.229.
[4]朴德慧,衣英刚.液晶显示器驱动板MCU电路介绍(上)[J].家电检修技术,2012(11):53.
[5]段廷魁.全球卫星定位系统(GNSS)在工程测量中的实践运用探索0[J].科技创新与应用,2021(05):182-184.
[6]宋戈,黄鹤松.51单片机应用开发范例大全[M].北京:人民邮电出版社:国家信息技术紧缺人才培养工程系列丛书,201206.558.
[7]罗小青.单片机原理及应用教程[M].北京:人民邮电出版社,201409.180.
[8]沈庆阳.单片机实践与应用[M].北京:清华大学出版社,2002.
[9]杜深慧.温湿度检测装置的设计与实现[M].北京:机械工业出版社,2004.
[10]林嘉.基于89S52的LCD1602程序设计[J].电脑知识与技术,2012(26):6376-6378.
[11]刘光伟.基于单片机的温室温湿度监测系统设计与实现[D].秦皇岛市:燕山大学,2012.
[12]褚福强,董学仁.单片机的网络接入技术研究[J].仪器仪表用户,2006(05):4-5.
[13]陈英俊.基于单片机的温湿度监测和报警系统设计[J].广东石油化工学院学报,2013(04):42-46.
[14]廖丽媛.基于应变式扭矩传感器的测量系统的设计[D].上海市:东华大学,2013.
[15]刘九庆.温室环境工程技术[M].吉林:东北林业大学出版社,2002.
[16]王明喜,崔世茂.大棚型日光温室光照、温度及湿度等性能的初步研究[J].农业工程技术(温室园艺),2008(05):19-21.
[17]张迎辉.单片微型计算机键盘接口设计[J].信息技术,2004(07):68-69+91.
[18]张友德,赵志英.单片微型机原理应用与实验[M].上海市:复旦大学出版社,2003.
[19]赵芝芸.温室智能监控系统[D].江苏:江苏科技大学,2010.
[20]张宏伟.基于STM32的智能环境监测系统设计与实现[J].大庆师范学院学报,2020(05):32-35.
[21]王世伟,杨越.基于STM32的多型号舵机调试器设计[J].九江学院学报(自然科学版),2020,35(02):33-36.
[22]Pengcheng Zhao,Meijun Ni,Chao Chen,Chenxi Wang,PingpingYang,Xiahui Wang,Chunyan Li,Yixi Xie,Junjie Fei. A Novel Self-protection Hydroquinone Electrochemical Sensor Based on Thermo -sensitive Triblock Polymer PS-PNIPAm-PS[J].
[23]Jian Wang,Jing Chen,Xiaofu Xiong,Xiaofeng Lu,ZhengLiao,Xiaobo Chen.Temperature safety analysis and backup protectionscheme improvement for overhead transmission line in poweroscillation condition[T].Electric Power Systems Research,2019,166.
[24]Fuji Electric Co.Ltd.;Patent Issued for SeiconductorDevice And Method Of Outputting Temperature Alarm (USPTO10,164,626)[J].Electronics Newsweekly,2019.
[25]VERSID,INC;Patent Issued for Refrigeration UnitTemperature Alarm Using Thermal Properties of Food to Eliminate FalseAlarms (USPTO 9752810)[J].Computers,Networks &Communications,2017.
[26]Fuji Electric Co.Ltd;Patent Application Titled"Semiconductor Device and Method of Outputting Teperature Alarm"Published Online (USPTO 20170077919)[J]. Technology & BusinessJournal,2017.
[27]su Yuanping,Xu Lihong,Goodman Erik D.Multi-layerhierarchical optimisation of greenhouse climate setpoints for energyconservation and improvement of crop yield[J].Biosystems
[28]黄松茂.基于STM32的家庭环境监测系统的设计与实现[D].甘肃兰州.西北师范大学,2018.:23-30.
[29]李大琳.智能车内温度监测系统设计[J].山东工业技术,2014(12):80-81.
[30]郭雯,王海涛. 智能输液系统的发展与应用.医疗卫生装备,shiwu
实物可做,资料齐全,其他功能也可做~可供学习和参考使用!
网址:基于stm32单片机的环境监测系统 https://www.yuejiaxmz.com/news/view/407922
相关内容
基于STM32单片机的室内环境监测系统设计基于STM32单片机的智能家居环境监测与控制系统设计
基于STM32单片机的室内环境监测系统:打造智能生活新体验
基于单片机的森林环境监测系统设计
基于STM32的户外环境监测系统(五)
基于STM32的室内环境监测系统
基于STM32单片机的室内温湿度及PM2.5浓度监测报警系统
[T3242310M]基于单片机的车内环境及胎压监测系统
基于STM32及LabVIEW的厨房环境监测系统
基于STM32的仓库环境监测系统的毕业设计