SSブログ

Arduinoで温度を測る [Arduino]

Arduinoで温度を測ります!
使うのは、温度センサの「LM61BIZ」です。

これです↓
高精度IC温度センサLM61BIZ
高精度IC温度センサ(LM61).JPG
※以前に秋月電子で購入したのですが、メーカ都合により現在では販売されていないようです。
TI社の半導体製品が生産終了でないのに在庫限りです。どうしてですか?/TIのIC単体を購入できませんがどうしてですか?
"https://akizukidenshi.com/catalog/faq/goodsfaq.aspx?goods=I-09691"

【配線図】
Arduino_温度センサ_ブレッドボード.jpg

【スケッチ】
データシートを見ると
 Vo = (+10mV/℃ × T℃)+ 600mV
とありますので、温度T℃を求めるためには、
 T℃ = (Vo - 0.6[V]) / 0.01[V]
で求まります。

スケッチは以前に赤外線測距センサで作成したものを少し修正すればOKです。
/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
/*******************************************************************************
温度センサ(LM61BIZ) サンプルプログラム
++++++ note ++++++
・温度センサ LM61BIZ
・測定した温度をコンソール画面に表示するプログラム
・測定範囲:-25℃~+85℃

*******************************************************************************/
const float Vcc = 3.3;                   //電源電圧(定数)
float temp_volt;                         //出力電圧
float temp_data;                         //温度

// the setup routine runs once when you press reset:初期化(電源投入/リセット時1回のみ実行)
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);                    //9600bpsでシリアルポートを開く
}

// the loop routine runs over and over again forever: main loop
void loop() {
  int sensorValue = analogRead(A0);      //read the input on analog pin 0:
  temp_volt = Vcc * sensorValue / 1023;  //アナログピンから読み取った値を元の出力電圧値に戻す

// 出力電圧から温度データを作成
  temp_data = (temp_volt - 0.6) / 0.01;  //【データシート】T[℃] = (Vo - 0.6) / 0.01

// 温度データの表示 temp_dataの値をハード・シリアルへ出力する(Arduino→PCモニタ)
  Serial.print(temp_data);               //温度を表示
  Serial.println("[℃]");                //単位は℃
  delay(1000);                           //1秒単位(シリアルポートを溢れさせないように) ※delay():単位ms
}




profile_picture_40×40.JPG
nice!(0)  コメント(0) 

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。