当前位置:   article > 正文

基于Labview的空气质量监测系统设计_STM32F103C8T6(程序+原理图+PCB)_labview stm32 nrf

labview stm32 nrf

本设计:
基于Labview的空气质量监测系统设计_STM32F103C8T6(程序+原理图+PCB)
原理图:Altium Designer
程序编译器:keil 5
编程语言:C语言
编号C0028
C0028 网盘链接

本设计通过下位机和上位机结合来实现系统监测的各项功能。上位机软件使用Labview虚拟仪器进行设计,下位机采用STM32F103C8T6单片机控制。下位机主要有温湿度传感器、光照传感器、显示器、无线传输模块等组成。温湿度传感器可以采集室内温湿度,然后反馈给单片机,单片机处理后在显示器上显示相关参数。同时,光照传感器的工作原理与温湿度模块相同。
1.上位机实现功能
通信波特率设置为115200,上位机通过USB无线串口转NRF24L01模块来接受下位机传来的环境参数信息,实时显示当前温湿度和光照强度,当环境参数大于设定阈值时,上位机显示界面中的报警指示灯亮起,同时下位机的蜂鸣器报警模块会响起,启动降温模块。当环境参数回归正常时,报警自动取消,降温模块停止工作。
2.下位机实现功能
单片机STM32F103C8T6通过DHT11温湿度传感器和光敏二极管分别采集当前环境中的温湿度和光强信息,通过OLED屏进行实时显示,并且将采集到的环境数据通过NRF24L01无线通信模块实时发送至上位机端。当环境参数大于设定阈值时,蜂鸣器模块进行报警,雾化器模块进行降温处理。当环境参数回归正常时,报警自动取消,雾化器模块停止工作。

原理图(提供源文件):
在这里插入图片描述

PCB(提供源文件):
在这里插入图片描述

源程序(提供源文件):
在这里插入图片描述

https://docs.qq.com/sheet/DS0xIa0llTmtNakRW
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "oled.h"
#include "adc.h"
#include "24l01.h"
#include "dht11.h" 

#define beep PAout(11)// PA11
#define wet PAout(12)// PA12

#define set_jia PCin(13)// PC13温度阈值加
#define set_jian PCin(15)// PC15温度阈值减

uint16_t Light_adc,Light,Light_shi,Light_ge;
u8 temperature,Temp_shi,Temp_ge;  	    
u8 humidity,Humi_shi,Humi_ge;  
u8 Temp_set=26,Temp_set_shi,Temp_set_ge;

void System_Init(void);
void CHinese(u8 x,u8 y,u8 no,u8 z);

void beep_wet_init()
{
	 GPIO_InitTypeDef  GPIO_InitStructure;
	
	 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);	 //使能PA端口时钟	
	 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12;//端口配置
	 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 		 //推挽输出
	 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		 //IO口速度为50MHz
	 GPIO_Init(GPIOA, &GPIO_InitStructure);					 //根据设定参数初始化
}
void key_init()
{
//	+//PC13
//	-//PC15
	 GPIO_InitTypeDef  GPIO_InitStructure;
	
	 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);	 //使能PC端口时钟
	 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_15;//端口配置
	 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//设置成上拉输入
//	 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		 //IO口速度为50MHz
	 GPIO_Init(GPIOC, &GPIO_InitStructure);					 //根据设定参数初始化

}

int main(void)
{
		u8 tmp_buf[33];
		u8 TX_buf[32];
	  u8 RX_buf[32];
		System_Init();
	
		while(1)
		{
			if(set_jia==0)
			{
				Temp_set++;
				if(Temp_set>40) Temp_set=26;
				while(!set_jia);
			}
			if(set_jian==0)
			{
				Temp_set--;
				if(Temp_set<16) Temp_set=26;
				while(!set_jian);
			}
			
			DHT11_Read_Data(&temperature,&humidity);//读取温湿度值 	
			Temp_shi=temperature/10;
			Temp_ge=temperature%10;
			Humi_shi=humidity/10;
			Humi_ge=humidity%10;
			Temp_set_shi=Temp_set/10;
			Temp_set_ge=Temp_set%10;
			
		  Light_adc = Get_Adc_Average(ADC_Channel_1,10);//0.0244
			Light=100-Light_adc*0.0244;
			Light_shi=Light/10;
			Light_ge=Light%10;
			OLED_ShowString(2,0,"Index",16);
			OLED_ShowString(52,0,"Value",16);
			OLED_ShowString(100,0,"Set",16);
			CHinese(8,2,13,0);
			CHinese(24,2,14,0);
			OLED_ShowString(40,2,":",16);
			CHinese(8,4,15,0);
			CHinese(24,4,16,0);
			OLED_ShowString(40,4,":",16);
			CHinese(8,6,17,0);
			CHinese(24,6,18,0);
			OLED_ShowString(40,6,":",16);			
			OLED_ShowNum(62,2,Light,2,16);
			OLED_ShowString(78,2,"%",16);
			OLED_ShowNum(62,4,temperature,2,16);//显示温度
			OLED_ShowString(78,4,"C",16);
			OLED_ShowNum(100,4,Temp_set,2,16);//显示温度阈值
			OLED_ShowString(116,4,"C",16);
			OLED_ShowNum(62,6,humidity,2,16);//显示湿度
			OLED_ShowString(78,6,"%",16);
			NRF24L01_TX_Mode();
			if(NRF24L01_TxPacket(TX_buf)==TX_OK)
			{
				TX_buf[0]=8;//发送的总字节数	
				TX_buf[1]=Light_shi+'0';
				TX_buf[2]=Light_ge+'0';
				TX_buf[3]=Temp_shi+'0';
				TX_buf[4]=Temp_ge+'0';
				TX_buf[5]=Humi_shi+'0';
				TX_buf[6]=Humi_ge+'0';
				TX_buf[7]=Temp_set_shi+'0';
				TX_buf[8]=Temp_set_ge+'0';
				TX_buf[9]=0x0A;//换行
			}		
			if(temperature>Temp_set)
			{
				beep=1;
				wet=1;
			}
			else
			{
				beep=0;
				wet=0;
			}

 		}
} 	
void System_Init()
{
	  delay_init();	    	 //延时函数初始化	  
		NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
		uart_init(115200);	 	//串口初始化为115200

		beep_wet_init();
		Adc_Init();
		DHT11_Init();
		key_init();
		OLED_Init();			//初始化OLED  
 		OLED_Clear();		
		NRF24L01_Init();    		//初始化NRF24L01
		while(NRF24L01_Check())
		{
			OLED_ShowString(0,0,"NRF24L01 Error",16);
			delay_ms(200);
			OLED_Clear(); 
			delay_ms(200);
		}
		OLED_ShowString(0,0,"NRF24L01 OK",16);
		delay_ms(500);
		OLED_Clear(); 
		
		CHinese(0,1,0,0);//行0246
		CHinese(16,1,1,0);
		CHinese(32,1,2,0);
		CHinese(48,1,3,0);
		CHinese(64,1,4,0);
		CHinese(80,1,5,0);
		CHinese(96,1,6,0);
		CHinese(112,1,7,0);
		CHinese(48,3,8,0);
		CHinese(64,3,9,0);
	
		delay_ms(3000);
		OLED_Clear(); 
}

void CHinese(u8 x,u8 y,u8 no,u8 z)
{
	unsigned char Hzk1[][16]={

		{0x10,0x94,0x53,0x32,0x1E,0x32,0x52,0x10,0x00,0x7E,0x42,0x42,0x42,0x7E,0x00,0x00},
		{0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,0x00},//"智",0

		{0x08,0xCC,0x4A,0x49,0x48,0x4A,0xCC,0x18,0x00,0x7F,0x88,0x88,0x84,0x82,0xE0,0x00},
		{0x00,0xFF,0x12,0x12,0x52,0x92,0x7F,0x00,0x00,0x7E,0x88,0x88,0x84,0x82,0xE0,0x00},//"能",1

		{0x04,0x84,0x84,0xFC,0x84,0x84,0x00,0x04,0x04,0x84,0xE4,0x1C,0x84,0x04,0x04,0x00},
		{0x20,0x60,0x20,0x1F,0x10,0x10,0x04,0x02,0x01,0x00,0xFF,0x00,0x00,0x01,0x06,0x00},//"环",2

		{0x10,0x10,0xFF,0x10,0x10,0x20,0xA4,0xAC,0xB5,0xA6,0xB4,0xAC,0xA4,0x20,0x20,0x00},
		{0x10,0x30,0x1F,0x08,0x88,0x80,0x4F,0x3A,0x0A,0x0A,0x7A,0x8A,0x8F,0x80,0xE0,0x00},//"境",3

		{0x00,0x00,0x7E,0x00,0x00,0xFF,0x00,0x40,0x30,0x0F,0x04,0x14,0x64,0x04,0x00,0x00},
		{0x40,0x40,0x7E,0x42,0x42,0x7E,0x42,0x42,0x42,0x7E,0x42,0x42,0x7E,0x40,0x40,0x00},//"监",4

		{0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0xFF,0x00,0x00},
		{0x04,0x04,0x7E,0x01,0x80,0x47,0x30,0x0F,0x10,0x27,0x00,0x47,0x80,0x7F,0x00,0x00},//"测",5

		{0x10,0x10,0x10,0xFF,0x90,0x20,0x98,0x48,0x28,0x09,0x0E,0x28,0x48,0xA8,0x18,0x00},
		{0x02,0x42,0x81,0x7F,0x00,0x40,0x40,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x40,0x00},//"控",6

		{0x40,0x50,0x4E,0x48,0x48,0xFF,0x48,0x48,0x48,0x40,0xF8,0x00,0x00,0xFF,0x00,0x00},
		{0x00,0x00,0x3E,0x02,0x02,0xFF,0x12,0x22,0x1E,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00},//"制",7

		{0x00,0x00,0x22,0x32,0x2A,0xA6,0xA2,0x62,0x21,0x11,0x09,0x81,0x01,0x00,0x00,0x00},
		{0x00,0x42,0x22,0x13,0x0B,0x42,0x82,0x7E,0x02,0x02,0x0A,0x12,0x23,0x46,0x00,0x00},//"系",8

		{0x20,0x30,0xAC,0x63,0x30,0x00,0x88,0xC8,0xA8,0x99,0x8E,0x88,0xA8,0xC8,0x88,0x00},
		{0x22,0x67,0x22,0x12,0x12,0x80,0x40,0x30,0x0F,0x00,0x00,0x3F,0x40,0x40,0x71,0x00},//"统",9
	
		
		{0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F,0x40,0xC0,0x50,0x48,0x46,0x40,0x40,0x00},
		{0x80,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00},//"光",13

		{0x02,0xE2,0x22,0x22,0x3E,0x00,0x80,0x9E,0x92,0x92,0xF2,0x92,0x92,0x9E,0x80,0x00},
		{0x00,0x43,0x82,0x42,0x3E,0x40,0x47,0x44,0x44,0x44,0x7F,0x44,0x44,0x54,0xE7,0x00},//"强",14
		
		{0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00},
		{0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00},//"温",15

		{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00},
		{0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},//"度",16

		{0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00},
		{0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00},//"湿",17

		{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00},
		{0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},//"度",18

		
  };
	
		u8 t,adder=0;
	OLED_Set_Pos(x,y);	
    for(t=0;t<16;t++)
		{ 
			  if(z==0)
				OLED_WR_Byte(Hzk1[2*no][t],OLED_DATA);
				if(z==1)
				OLED_WR_Byte(~Hzk1[2*no][t],OLED_DATA);
				adder+=1;
       }	
		OLED_Set_Pos(x,++y);	
    for(t=0;t<16;t++)
			{	
				if(z==0)
	  		OLED_WR_Byte(Hzk1[2*no+1][t],OLED_DATA);
				if(z==1)
				OLED_WR_Byte(~Hzk1[2*no+1][t],OLED_DATA);
				adder+=1;
        }	
}	 	 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244

全部资料如下:
下载链接看文章开题
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/164381
推荐阅读
相关标签
  

闽ICP备14008679号