聚丰项目 > 床头空气质量检测仪
本项目基于IDT_ZMOD4410气体传感器套件开发的床头空气质量检测仪。项目开发理由:人们90%以上的时间呆在室内,其中以睡眠时间为最长,且处于同一个地方,睡觉时室内的污染物含量会随着时间变化而变化,对人体危害程度也不断变化。高污染物含量将直接影响睡眠质量,因而有必要检测床头空气质量。本装置采用IDT_ZMOD4410传感器检测室内空气质量,stm32f103系列开发板辅助,将采集到的数据传输至PC端进行处理,PC端将处理后的数据在上位机进行显示,同时将该数据通过EDP协议上传至云端储存,可实现每日、周度、月度报告。
器新哈
分享器新哈
团队成员
器新哈 电子发烧友
1、PCB板
2、stm32
使用keil
int fgetc(FILE *f)
{
while (USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET);
return (int)USART_ReceiveData(USART3);
}
unsigned char sensor_data[17];
unsigned char air_data[17];
unsigned char r_cnt;
unsigned char r_done;
unsigned char test;
void USART3_IRQHandler(void)
{
if(USART_GetFlagStatus(USART3,USART_FLAG_RXNE)!=RESET)
{
USART_ClearFlag(USART3,USART_FLAG_RXNE);
/*test = (USART3->DR & (uint16_t)0x01FF);
Usart_SendByte(USART3,test);*/
sensor_data[r_cnt] = (USART3->DR & (uint16_t)0x01FF);
/*if((r_cnt==0)&&(r_data[0]==0x01))
{
r_cnt=1;
// continue;
}
else if((r_cnt==1)&&(r_data[1]==0x03))
{
r_cnt=2;
}
else if((r_cnt==2)&&(r_data[1]==0x0C))
{
r_cnt=3;
}
else if(r_cnt>=3&&r_cnt<=16)
{
r_cnt++;
}
else
r_cnt=0;*/
/*if((r_cnt>=3)&&(r_cnt<=16))
{
r_cnt++;
// continue;
}
else if((r_cnt==2)&&(r_data[1]==0x0C))
{
r_cnt=3;
}
else if((r_cnt==1)&&(r_data[1]==0x03))
{
r_cnt=2;
}
else if((r_cnt==0)&&(r_data[0]==0x01))
{
r_cnt=1;
}
else
r_cnt=0;
if(r_cnt==17)
{
r_done = 1;
r_cnt = 0;
}*/
switch(r_cnt)
{
case 0: if(sensor_data[0]==0x01)
{
r_cnt = 1;
break;
}
else
{
r_cnt = 0;
break;
}
case 1: if(sensor_data[1]==0x03)
{
r_cnt = 2;
break;
}
else
{
r_cnt = 0;
break;
}
case 2: if(sensor_data[2]==0x0c)
{
r_cnt = 3;
break;
}
else
{
r_cnt = 0;
break;
}
case 3: r_cnt = 4;
break;
case 4: r_cnt = 5;
break;
case 5: r_cnt = 6;
break;
case 6: r_cnt = 7;
break;
case 7: r_cnt = 8;
break;
case 8: r_cnt = 9;
break;
case 9: r_cnt = 10;
break;
case 10: r_cnt = 11;
break;
case 11: r_cnt = 12;
break;
case 12: r_cnt = 13;
break;
case 13: r_cnt = 14;
break;
case 14: r_cnt = 15;
break;
case 15: r_cnt = 16;
break;
case 16: r_cnt = 17;
break;
default: r_cnt = 0;
break;
}
if(r_cnt==17)
{
memcpy(shuju,sensor_data,17);
//r_done = 1;
r_cnt = 0;
}
//Usart_SendByte(USART3,r_data);
}
}
2.mian函数部分,将全局变量里的数据在LCD上显示
#include "stm32f4xx.h"
#include "./led/bsp_led.h"
#include "./usart/bsp_debug_usart.h"
#include "./sdram/bsp_sdram.h"
extern unsigned char sensor_data[17];
extern unsigned char air_data[17];
extern unsigned char r_cnt;
extern unsigned char r_done;
unsigned char data[17];
int i,j;
int a;
int b1;
int b2;
float co2;
float tvoc;
float ch2o;
float pm25;
float humidity;
float temperature;
unsigned char shuju[17];
unsigned char w_num;
void Delay(__IO u32 nCount);
void LCD_Test(void);
/**
稍等