聚豐項目 > 基于AB32VG1的空氣質(zhì)量檢測設(shè)計
該項目是基于AB32VG1作為主板,通過串口通訊獲取CO2、CH2O、TVOC三合一的空氣質(zhì)量檢測,并將檢測結(jié)果實時用OLED屏進行顯示。
jf_88110289
jf_88110289
團隊成員
葉俊杰 架構(gòu)師
硬件:
1)主板AB32VG1, 作為主控端。
2)SSD1306 OLED屏,用于顯示當前空氣質(zhì)量相關(guān)的值以及當前日期以及時間。
3)空氣質(zhì)量檢測傳感器(CO2、CH2O、TVOC三合一),這款傳感器通過串口給主控傳輸相關(guān)數(shù)據(jù)。
軟件上創(chuàng)建了四個靜態(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)先級 LED_TimeSlices); //線程時間片 // 創(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)先級 OLED_TimeSlices); //線程時間片 // 創(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)先級 KEY_TimeSlices); //線程時間片 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)先級 10); //線程時間片
演示效果如附件中圖片
OLED屏?xí)目諝赓|(zhì)量檢測傳感器中獲取的數(shù)據(jù)顯示在OLED屏上,方便用戶快速的了解到當前所處環(huán)境的空氣質(zhì)量情況。
(0.14 MB)下載