聚豐項目 > 床頭空氣質(zhì)量檢測儀
本項目基于IDT_ZMOD4410氣體傳感器套件開發(fā)的床頭空氣質(zhì)量檢測儀。項目開發(fā)理由:人們90%以上的時間呆在室內(nèi),其中以睡眠時間為最長,且處于同一個地方,睡覺時室內(nèi)的污染物含量會隨著時間變化而變化,對人體危害程度也不斷變化。高污染物含量將直接影響睡眠質(zhì)量,因而有必要檢測床頭空氣質(zhì)量。本裝置采用IDT_ZMOD4410傳感器檢測室內(nèi)空氣質(zhì)量,stm32f103系列開發(fā)板輔助,將采集到的數(shù)據(jù)傳輸至PC端進行處理,PC端將處理后的數(shù)據(jù)在上位機進行顯示,同時將該數(shù)據(jù)通過EDP協(xié)議上傳至云端儲存,可實現(xiàn)每日、周度、月度報告。
器新哈
分享器新哈
團隊成員
器新哈 電子發(fā)燒友
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函數(shù)部分,將全局變量里的數(shù)據(jù)在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);
/**
稍等