備忘錄_20160105(定位) 修改 回首頁

程式 2020-03-24 01:00:37 1584982837 100
Arduino UNO R3 練習-用 MLX90614 檢測溫度

Arduino UNO R3 練習-用 MLX90614 檢測溫度
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

#include <LiquidCrystal_I2C.h> // LCD 1602 I2C 顯示模組(用I2C)
// LCD 1602 I2C 顯示模組(用I2C)
// Set the pins on the I2C chip used for LCD connections: addr,en,rw,rs,d4,d5,d6,d7,bl,blpol
long lTimeCurrent=0, lTimeLastClockShown=0, lTimeGap4Clock;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 設定 LCD I2C 位址

void setup() 
{
  Serial.begin(9600);
  Serial.println("Adafruit MLX90614 test");
  mlx.begin();

  // LCD 1602 I2C 顯示模組(用I2C)
  Serial.println("LCD Init");
  lcd.begin(16, 2);      // 初始化 LCD,一行 16 個字元,共 2 行
  lcd.clear();
  lcd.backlight();       // 開啟背光
  //lcd.noBacklight();   // 關閉背光
  //lcd.setCursor(0, 0);   // 設定游標位置在第 1 行行首 (x,y)
  //lcd.print("Hello, world!");
}

void loop() 
{
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  lcd.setCursor(0, 0); 
  lcd.print(mlx.readAmbientTempC());  
  lcd.setCursor(0, 1); 
  lcd.print(mlx.readObjectTempC());  
  delay(100);
}

發燒是指核心體溫超過38度c,平均體溫的共識是1868年用腋下的溫度計測量的37度c,目前對正常體溫的範圍共識是


腋溫:34.7度c~37.3度c,

口溫:35.5度c~37.5度c,

肛溫:36.6度c~37.9度c,

耳溫:35.7度c~37.5度c。


沒有額溫的資料,不同地方量到的溫度,不能推測另一個地方的溫度。


--------------------------------------------


彰基護理部督導長黃怡真指出:「利用額溫槍去測量,它的落差會差了3到4度左右,如果他體溫是36度5,我們測量出來就會變成32度5,就會有一點落差情形。」

醫院出入人數多,廣泛使用「額溫槍」,對著額頭照射,測的是表面溫度,如果拿太遠,或是戶外氣溫低,量出來的落差會很大。

黃怡真說:「目前有寒流情形,氣溫可能到10度、12度,我們監測到的體溫就會偏低,所以應該要在室內去作監測。」

擔心防疫漏洞,彰化基督教醫院,甚至出動「紅外線體溫偵測儀」,就連車子經過時,輪胎溫度過高,或是有人拿著熱食、熱飲料,螢幕上,就會顯示出溫度偏高的黃色、紅色。

只要有人的頭頂出現危險警戒,院方人員就會合併測量耳溫,一個都不能漏掉。

(民視新聞/李文華、張士政 彰化報導)


若以 30 度C為界線,作一個簡易、不嚴謹的檢測方案,則可參考下面程式。
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

#include <LiquidCrystal_I2C.h> // LCD 1602 I2C 顯示模組(用I2C)
// LCD 1602 I2C 顯示模組(用I2C)
// Set the pins on the I2C chip used for LCD connections: addr,en,rw,rs,d4,d5,d6,d7,bl,blpol
long lTimeCurrent=0, lTimeLastClockShown=0, lTimeGap4Clock;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 設定 LCD I2C 位址

// 無源揚聲器
byte bTonePin=8;

double da1[50]={};
int iIdx=0;

void setup() 
{
  Serial.begin(9600);
  Serial.println("Adafruit MLX90614 test");
  mlx.begin();

  // LCD 1602 I2C 顯示模組(用I2C)
  Serial.println("LCD Init");
  lcd.begin(16, 2);      // 初始化 LCD,一行 16 個字元,共 2 行
  lcd.clear();
  lcd.backlight();       // 開啟背光
  //lcd.noBacklight();   // 關閉背光
  //lcd.setCursor(0, 0);   // 設定游標位置在第 1 行行首 (x,y)
  //lcd.print("Hello, world!");

  pinMode(bTonePin, OUTPUT);
}

void makeSoundCore(float fFrequency, int iDuration)
{
  tone(bTonePin, fFrequency);
  delay(iDuration);
}

void makeSoundWithTrouble()
{
  Serial.println("makeSoundWithTrouble");
  
  // 若有狀況,發出聲音!
  int iD=200;
  makeSoundCore(987.77,iD*2);
  makeSoundCore(698.46,iD/2);
  makeSoundCore(987.77,iD*2);
  makeSoundCore(698.46,iD/2);
  noTone(bTonePin);
}

void makeSoundWithOkay()
{
  Serial.println("makeSoundWithOkay");
  
  // 若有狀況,發出聲音!
  int iD=200;
  makeSoundCore(1200,iD);
  noTone(bTonePin);
}

void clearData()
{
  int i;
  for(i=0; i<50; i++)
  {
    da1[i]=0;
  }
  iIdx=0;
}

void loop() 
{
  lcd.setCursor(0, 0); 
  lcd.print(mlx.readAmbientTempC());  
  lcd.setCursor(0, 1); 
  lcd.print(mlx.readObjectTempC());  
  delay(5);

  da1[iIdx]=mlx.readObjectTempC();
  iIdx=(iIdx+1) % 50;

  int i=0, iCountUp=0;
  double dMax=0;
  for(i=0; i<50; i++) 
  {
    if(da1[i]>=30)
    {
      iCountUp++; 
      if(da1[i]>dMax) { dMax=da1[i]; }
    }
  }
  
  if(iCountUp>=40 && dMax!=0)
  {
    lcd.clear();
    
    lcd.setCursor(7, 0);
    lcd.print(dMax);
    
    lcd.setCursor(7, 1);
    lcd.print("EST:");
    lcd.print(dMax+3.0);

    if((dMax+3)>=37.5)
    {
      clearData();
      makeSoundWithTrouble();
    }
    else if(dMax>0)
    {
      clearData();
      makeSoundWithOkay();
    }
  }
}