以 M5StickCPlus 內建感測器實作溫度的精密量測與探討
Using M5StickCPlus Built-in Sensors to Realize Precise Measurement and Discussion of Temperature
作者: 王靖傑、陳宣翰、吳佳祐 系級: 精密二
學號:D1057693、D1057659、D1073856 開課老師:蔡鈺鼎
課程名稱:精密量測
開課系所:精密系統設計學士學位學程
開課學年:111學年度 第一學期
中文摘要
以精密量測之課程所學為整體,結合實作及理論,系統性的完成數據量測及分 析。透過 M5StickCPlus 硬件內設之各項感測器量測並收集數據而後配合 Matlab 工具完成數據之分析。
(1) 目的:說明此論文的目的或主要想解決的問題。
本團隊期望在這次研究計畫中,透過
M5StickC+以C++程式編寫認識ESP32
開發板、感測器規格與利用並完成對於數據收集及曲線擬合(基礎機
器學習)的認識。同時於過程中充分了解研究報告之撰寫、資料查詢等基本 能力。
(2) 過程及方法:說明主要工作過程及所用方法,使用的主要設備和儀12
器等。
M5 stickC+
對應溫度的時域量測訊號:
於同學租屋處中進行暖暖包升溫量測。
於同學租屋處中進行室溫量測。
量測時間:P.M.7:00-P.M.8:00 2023/01/04
(3) 結果:說明此研究過程最後得出的結果和結論,如有可能,可以提出該結論
和結果的應用範圍和情況。
M5
內建的溫度感測器會有極端嚴重的散熱失效問題,以致
M5運作時常達 一定長度後,其溫度感測數值會高常溫約
30至
40攝氏度的極端誤差。然 而依然可以在兩次測試中看出其感測器依然有量測升降溫的能力。不過在量 測室溫時量測溫度依然會呈現上升趨勢,而其趨勢都可以成功的以
Matlab擬合工具運算出其結果。
關鍵字: 趨勢擬合(Curve Fitting)、M5Stick、Matlab
1
Abstract
Based on the knowledge learned from the precision measurement course, this project combines theory and practical work to systematically complete data measurement and analysis. Through using various sensors within the
M5StickCPlus hardware to collect data and then analyzing the data with Matlab tools, the team aims to gain an understanding of the ESP32 evaluation board, sensor specifications, and basic machine learning techniques for data collection and curve fitting. At the same time, the team hopes to improve their basic abilities in writing research reports and conducting data searches.
The main work process and methods used, as well as the main equipment and instruments used, are explained. In this project, the M5 StickCPlus was used to measure temperature in real-time. The team conducted temperature
measurements on a warm pack and in a room at their classmates' rental house from 7:00 PM to 8:00 PM on January 4, 2023.
The study found that the built-in temperature sensor in the M5StickCPlus has a serious heat dissipation failure issue. As a result, after the M5 operates for a certain period of time, the temperature sensor reading can be off by as much as 30-40 degrees Celsius higher than the actual temperature. However, the sensor's ability to measure temperature changes can still be observed in both tests. Nonetheless, when measuring the room temperature, the temperature showed an upward trend, but the trend could be successfully fitted using Matlab tools.
Keyword:
Curve Fitting、M5Stick、Matlab目錄
壹、摘要 :... 4
貳、研究簡介: ... 4
一、技術與規格調查:... 4
二、方法調查: ... 5
三、總結: ... 5
參、方法論述: ... 6
一、M5 stickC+ 對應溫度的時域量測訊號: ... 6
二、數值方法: (Matlab) ... 6
肆、實驗結果與討論 ... 9
一、暖暖包升溫量測: ... 9
二、室溫量測: ... 9
伍、結果與討論 ... 10
參考資料 ... 11
壹、摘要 :
以精密量測之課程所學為整體,結合實作及理論,系統性的完成數據量測及 分析。透過 M5StickCPlus 硬件內設之各項感測器量測並收集數據而後配合 Matlab 工具完成數據之分析。
貳、研究簡介:
一、技術與規格調查:
透過與市面上的溫度感測器作比較來了解 M5StickC+內建的溫度感測器是否 具備良好的量測功能。而我們在市面上搜索到較為普及的溫度感測器是 DHT 系列的兩款產品。而 DHT22 在精確度上又略高於 DHT11。
內建的溫度感測器則是建置於
M5StickC+的六軸姿態傳感器
(6-Axis IMU Unit(MPU6886))上。
除此之外其公司官方也有推出一款溫度感測器(HAT ENVⅢ)。規格如下:
最大測溫範圍 -40~120℃
最高測量精度 0~60℃/±0.2℃
濕度測量範圍/誤差 10 ~ 90 %RH / ±2%
工作溫度 32°F 至 104°F(0°C 至 40°C)
而部分為 DHT11&DHT22 的資訊及規格:
DHT 數位溫濕度感測器是一款含有已校準數位信號輸出的溫濕度複合感測器。感測器包 括一個電阻式感濕元件和一個 NTC 測溫元件,並與一個高性能 8 位單片機相連接。因此
該產品具有超快回應、抗干擾能力強等優點。超小的體積、極低的功耗,信號傳輸距離 可達 20 米以上。
DHT11 DHT22
工作電壓:+5 V
溫度範圍:0-50 °C error of ± 2 °C
濕度範圍: 20-90% RH ± 5% RH error
工作電壓:+5V
溫度範圍:-40~80℃ ±0.5℃
濕度範圍:20~90%RH ±2%RH
雖然透過外接溫度感測器可以獲得更精準的數據,然而卻有無法方便 感測的問題。但若配合良好的程式碼及一定的散熱系統便可完成簡易 的溫度感測裝置。
二、方法調查:
網路上尋找到的方法多為外接 DHT11、DHT223或官方的 ENVⅢ配合各程 式庫完成溫度數據的收集。
而有文獻顯示官方的 ENVⅢ會有溫度測試的嚴重誤差。4 三、總結:
本團隊期望在這次研究計畫中,透過 M5StickC+以 C++程式編寫認識 ESP32 開發板、感測器規格與利用並完成對於數據收集及曲線擬合(基
3 References[4]
https://www.hackster.io/pradeeplogu0/iot-temperature-monitor-using-m5stick-and-qubitro-f7a548
4 References[5]
https://community.m5stack.com/topic/3929/incorrect-measurements-with-env-iii-hat-on-m5stickc
量測環境
礎機器學習)的認識。同時於過程中充分了解研究報告之撰寫、資料查 詢等基本能力。
參、方法論述:
一、M5 stickC+ 對應溫度的時域量測訊號:
於同學吳佳祐租屋處中進行暖暖包升溫量測。
於同學吳佳祐租屋處中進行室溫量測。
量測時間:P.M.7:00-P.M.8:00 2023/01/04 二、數值方法:(Matlab)
A. M5 stickC+程式碼:
#include <M5StickCPlus.h>
float SumT; //溫度總和 float AvT; //平均溫度 float temp; //溫度 int count; //計數器 int last;
boolean test = false;
void setup() { m5.begin();
Serial.begin(9600);
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK); //clean LCD & fill with black M5.Lcd.setTextSize(2);
M5.Lcd.setCursor(0, 0); //set text position M5.Imu.Init();
last=digitalRead(37);
//setting MPU6886
unsigned char set = 0x00;
I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_SMPLRT_DIV , 1, &set);
set = 0x07;
I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_CONFIG , 1, &set);
set = 0x08;
I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_ACCEL_CONFIG2 , 1, &set);
M5.Lcd.println("Not measuring");
count=0;
}
void loop() {
if (digitalRead(37) != last) { last = digitalRead(37);
if (last == 0) { test = !test;
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(0, 0);
if (test) {
M5.Lcd.println("Measuring");
} else {
M5.Lcd.println("Not measuring");
M5.Lcd.setCursor(0,45);
AvT=SumT/count;//資料加總除以計數器 M5.Lcd.printf("AvgTemp: %.2f *C",AvT);
count=0;//將數據歸零,避免使用到舊的資料 AvT=0;
SumT=0;
} } }
if (test) {
M5.Imu.getTempData(&temp);
count ++;//計數器加一 AvT=SumT/count;
M5.Lcd.setCursor(0,45);
M5.Lcd.printf("Temp: %.2f *C", AvT);//印出溫度 M5.Lcd.setCursor(0,60);
M5.Lcd.printf("data: %d\n", count);//印出資料筆數
SumT+=temp;//將這筆資料加總 Serial.println(AvT);
delayMicroseconds(500);
} }
void I2C_Write_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, u int8_t *write_Buffer) {
Wire1.beginTransmission(driver_Addr);
Wire1.write(start_Addr);
Wire1.write(*write_Buffer);
Wire1.endTransmission();
}
B. Matlab 程式碼:
暖暖包升溫測試 室溫測試
肆、實驗結果與討論
一、暖暖包升溫量測:
二、室溫量測:
伍、結果與討論
M5 內建的溫度感測器會有極端嚴重的散熱失效問題,以致 M5 運作時常達一 定長度後,其溫度感測數值會高常溫約 30 至 40 攝氏度的極端誤差。然而依 然可以在兩次測試中看出其感測器依然有量測升降溫的能力。不過在量測室 溫時量測溫度依然會呈現上升趨勢,而其趨勢都可以成功的以 Matlab 擬合 工具運算出其結果。
暖暖包升溫測試及其圖表(含趨勢擬合) 室溫測試及其圖表(含趨勢擬合)
參考資料
M5stack 官方網站,檢自https://shop.m5stack.com/products/6-axis-imu- unitmpu6886
阿德的 STEAM 教學網,檢自 https://itcgs.tcgs.tc.edu.tw/yute?cid=2295 https://itcgs.tcgs.tc.edu.tw/yute?cid=2296
Pradeep(2021)IoT Temperature Monitor using M5Stick and Qubitro from https://www.hackster.io/pradeeplogu0/iot-temperature-monitor-using- m5stick-and-qubitro-f7a548
m1cr0lab(2022)
Incorrect measurements with ENV III HAT on M5StickC+
fromhttps://community.m5stack.com/topic/3929/incorrect-measurements- with-env-iii-hat-on-m5stickc