聚豐項(xiàng)目 > 基于AB32VG1的空氣質(zhì)量檢測(cè)設(shè)計(jì)
該項(xiàng)目是基于AB32VG1作為主板,通過(guò)串口通訊獲取CO2、CH2O、TVOC三合一的空氣質(zhì)量檢測(cè),并將檢測(cè)結(jié)果實(shí)時(shí)用OLED屏進(jìn)行顯示。
jf_88110289
jf_88110289
團(tuán)隊(duì)成員
葉俊杰 架構(gòu)師
硬件:
1)主板AB32VG1, 作為主控端。
2)SSD1306 OLED屏,用于顯示當(dāng)前空氣質(zhì)量相關(guān)的值以及當(dāng)前日期以及時(shí)間。
3)空氣質(zhì)量檢測(cè)傳感器(CO2、CH2O、TVOC三合一),這款傳感器通過(guò)串口給主控傳輸相關(guān)數(shù)據(jù)。
軟件上創(chuàng)建了四個(gè)靜態(tài)線程,led燈線程、按鍵線程、OLED屏顯示線程以及串口獲取傳感器數(shù)據(jù)線程。
// 創(chuàng)建LED靜態(tài)線程 tmp_result1 = rt_thread_init(&led_thread, //線程控制塊 "led_blink", //線程名字,在shell里面可以看到 Led_ThreadEntry, //線程入口函數(shù) RT_NULL, //線程入口函數(shù)參數(shù) &rt_led_thread_stack[0], //線程棧起始地址 sizeof(rt_led_thread_stack), //線程棧大小 LED_Priority, //線程的優(yōu)先級(jí) LED_TimeSlices); //線程時(shí)間片 // 創(chuàng)建OLED靜態(tài)線程 tmp_result2 = rt_thread_init(&oled_thread, //線程控制塊 "oled_display", //線程名字,在shell里面可以看到 OLED_ThreadEntry, //線程入口函數(shù) RT_NULL, //線程入口函數(shù)參數(shù) &rt_oled_thread_stack[0], //線程棧起始地址 sizeof(rt_oled_thread_stack), //線程棧大小 OLED_Priority, //線程的優(yōu)先級(jí) OLED_TimeSlices); //線程時(shí)間片 // 創(chuàng)建KEY靜態(tài)線程 tmp_result3 = rt_thread_init(&key_thread, //線程控制塊 "key_control", //線程名字,在shell里面可以看到 Key_ThreadEntry, //線程入口函數(shù) RT_NULL, //線程入口函數(shù)參數(shù) &rt_key_thread_stack[0], //線程棧起始地址 sizeof(rt_key_thread_stack), //線程棧大小 KEY_Priority, //線程的優(yōu)先級(jí) KEY_TimeSlices); //線程時(shí)間片 tmp_result4 = rt_thread_init(&uart_thread, //線程控制塊 "usart1_task", //線程名字,在shell里面可以看到 usart1_task_entry, //線程入口函數(shù) RT_NULL, //線程入口函數(shù)參數(shù) &rt_uart_thread_stack[0], //線程棧起始地址 sizeof(rt_uart_thread_stack), //線程棧大小 10, //線程的優(yōu)先級(jí) 10); //線程時(shí)間片
演示效果如附件中圖片
OLED屏?xí)目諝赓|(zhì)量檢測(cè)傳感器中獲取的數(shù)據(jù)顯示在OLED屏上,方便用戶快速的了解到當(dāng)前所處環(huán)境的空氣質(zhì)量情況。
(0.14 MB)下載