程序編譯器:keil 5
編程語言:C語言
設(shè)計(jì)編號(hào):C0053
主要功能:
1.可以檢測(cè)環(huán)境中溫濕度,氣壓,一氧化碳,空氣質(zhì)量,煙霧濃度和光照強(qiáng)度;
2.將測(cè)量的值顯示在屏幕上,數(shù)據(jù)上報(bào)機(jī)智云平臺(tái)可以通過手機(jī)APP實(shí)時(shí)查看當(dāng)前的狀態(tài);
3.通過光敏傳感器檢測(cè)光照強(qiáng)度,當(dāng)光照強(qiáng)度小于閾值,表明此時(shí)天黑了,自動(dòng)點(diǎn)亮LED燈照明并且自動(dòng)關(guān)閉窗簾!反之!就會(huì)關(guān)閉燈!打開窗簾,可以實(shí)現(xiàn)手動(dòng)打開關(guān)閉;
4.可以通過過按鍵調(diào)節(jié)系統(tǒng)閾值,可以實(shí)現(xiàn)系統(tǒng)閾值掉電保存。
資料下載
實(shí)物圖
電路圖
程序
while(1)
{
Get_Data(0);
if(gz_value<=A_gz_value&&mode==0)
{
LED0=0;
curtain_flag=0;
}else if(gz_value>A_gz_value&&mode==0){
LED0=1;
curtain_flag=1;
}
if(last_curtain_flag!=curtain_flag&&mode==0)
{
BUJING_Cotrol(curtain_flag,3,270);
last_curtain_flag = curtain_flag;
}
if(last_curtain_flag!=currentDataPoint.valueCurtain&&mode==1)
{
BUJING_Cotrol(currentDataPoint.valueCurtain,3,270);
curtain_flag = currentDataPoint.valueCurtain;
last_curtain_flag = currentDataPoint.valueCurtain;
}
if(mode==1)
{
LED0=!currentDataPoint.valueLED;
}
if(DHT11_Temp>=A_DHT11_Temp||DHT11_Hum<=A_DHT11_Hum||Pre>=A_pre||m135_value<=A_m135_value||m2_value>=A_m2_value||m7_value>=A_m7_value)
{
BEEP=!BEEP;
}else BEEP = 0;
key_value = KEY_Scan(0);
if(key_value==2)
{
display_contrl++;
}
if(display_contrl%2==0&&t>=10)
{
OLED_ShowCHinese(0,0,0);
OLED_ShowCHinese(16,0,2);
sprintf((char*)buff,":%2dC",DHT11_Temp);
OLED_ShowString(32,0,buff,16); //顯示溫度
OLED_ShowCHinese(64,0,1);
OLED_ShowCHinese(82,0,2);
sprintf((char*)buff,":%2d%%",DHT11_Hum);
OLED_ShowString(96,0,buff,16);//顯示濕度
OLED_ShowCHinese(0,2,3);
OLED_ShowCHinese(16,2,4);
sprintf((char*)buff,":%2dhpa ",Pre);
OLED_ShowString(32,2,buff,16);//顯示氣壓
OLED_ShowCHinese(0,4,5);
OLED_ShowCHinese(16,4,6);
OLED_ShowCHinese(32,4,7);
OLED_ShowCHinese(48,4,8);
sprintf((char*)buff,":%4dppm",gz_value);
OLED_ShowString(64,4,buff,16);//顯示光照強(qiáng)度
OLED_ShowCHinese(0,6,9);
OLED_ShowCHinese(16,6,10);
OLED_ShowCHinese(32,6,11);
OLED_ShowCHinese(48,6,12);
sprintf((char*)buff,":%4dppm",m135_value);
OLED_ShowString(64,6,buff,16);//顯示空氣質(zhì)量
}else if(display_contrl%2==1&&t>=10)
{
OLED_ShowCHinese(0,0,13);
OLED_ShowCHinese(16,0,14);
OLED_ShowCHinese(32,0,15);
OLED_ShowCHinese(48,0,16);
sprintf((char*)buff,":%4dppm",m2_value);
OLED_ShowString(64,0,buff,16);//顯示M2數(shù)據(jù)
OLED_ShowCHinese(0,2,17);
OLED_ShowCHinese(16,2,18);
OLED_ShowCHinese(32,2,19);
OLED_ShowCHinese(48,2,20);
sprintf((char*)buff,":%4dppm",m7_value);
OLED_ShowString(64,2,buff,16);//顯示M7數(shù)據(jù)
OLED_ShowCHinese(0,4,5);
OLED_ShowCHinese(16,4,6);
OLED_ShowCHinese(32,4,7);
OLED_ShowCHinese(48,4,8);
sprintf((char*)buff,":%4dppm",gz_value);
OLED_ShowString(64,4,buff,16);//顯示光照強(qiáng)度
OLED_ShowCHinese(0,6,9);
OLED_ShowCHinese(16,6,10);
OLED_ShowCHinese(32,6,11);
OLED_ShowCHinese(48,6,12);
sprintf((char*)buff,":%4dppm",m135_value);
OLED_ShowString(64,6,buff,16);//顯示M135數(shù)據(jù)
}
userHandle(); //用戶數(shù)據(jù)采集
WIFI_Contection(key_value);//WiFi連接控制
gizwitsHandle((dataPoint_t *)¤tDataPoint);//機(jī)智云協(xié)議處理
Canshu_Change(key_value);
t++;
delay_ms(100);
}
}
void WIFI_Contection(u8 key)//WiFi連接控制
{
if(key==4)
{
printf("WIFI進(jìn)入AirLink連接模式rn");
gizwitsSetMode(WIFI_AIRLINK_MODE);//Air-link模式接入
}
if(key==3)
{
printf("WIFI復(fù)位,請(qǐng)重新配置連接rn");
gizwitsSetMode(WIFI_RESET_MODE);//WIFI復(fù)位
}
}