Try   HackMD

Arduino 教學 11:LM35 溫度感測器

作者:王一哲
日期:2020/11/20

元件基本資料

LM35 是一種相當便宜的溫度感測器,從資料表中可以看到它又細分為幾個不同的型號,基本上測量範圍是 2°C - 120°C,輸出訊號的電壓值是 10 mV/°C,室溫下測量精度為 ±0.25°C。每面對 LM35 有字的那一面,由左至右的接腳功能分別為電源訊號接地,分別將三者接到 Arduino 開發板上的 5V類比輸入GND

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
LM35 電路圖

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
LM35 裝置照片

測試用程式碼

#define SENSOR A0 float temp, val; void setup() { pinMode(SENSOR, INPUT); Serial.begin(9600); Serial.println("t (ms), T(°C)"); } void loop() { val = analogRead(SENSOR); temp = (val/1024.0*5.0)/0.01; Serial.print(millis()); Serial.print(", "); Serial.println(temp); delay(10000); }

若將 LM35 輸出接腳接到開發板上的 A0,由於使用 analogRead 讀取的數值為 0 - 1023,因此測量數值 val 與攝氏溫度 temp 的換算方法為

temp=(val/1024.05.0)/0.01

使用以上的程式碼可以每隔一段時間測量一次溫度,如果配合 putty 這類的軟體將輸出資料存成文字檔,就可以自動測量並記溫度隨時間變化的資料。

測量水溫

若將 LM35 溫度感測器用夾鏈袋包起來,放到熱水裡每隔10秒測量一次溫度,輸出的紀錄檔及測量結果如下。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
使用 LM35 測量水溫

t (ms), T(°C)
0, 71.29
10000, 71.29
20000, 71.29
30002, 70.80
40002, 70.80
50002, 70.31
60004, 69.82
70004, 69.82
80005, 69.82
90006, 69.34
100006, 69.34
...

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

水溫 T - 時間 t 關係圖

參考資料

LM35 資料表:https://www.ti.com/lit/ds/symlink/lm35.pdf


tags:PhysicsArduino