溫度感測器 - DS18B20
出自YFRobotwiki
產品簡介
溫度感測器 - DS18B20模塊是基於DS18B20數字溫度感測器設計的模塊,可用來對環境溫度進行檢測;DS18B20數字溫度感測器是美國 DALLAS 公司生產的一匯流排數字溫度感測器。
其測溫範圍-55℃~+125℃,固有測溫解析度 0.5℃,支持多點組網功能,多個DS18B20可以並聯在唯一的三線上,實現多點測溫,測量結果以 9~12位數字量方式串列傳送。
規格參數
- 供電電壓:DC3.3~5V
- 精度:±0.5℃
- 測量溫度範圍:-55℃ ~ 125℃
- 安裝孔徑:3MM
- 模塊尺寸:28*21*9.4MM (長*寬*高)
- 孔間距:15MM
- 模塊重量:2.2g
引腳說明
- 1. G -- Gnd(地)
- 2. V -- Vcc(電源+5V)
- 3. S -- Sign(信號)
應用示例
- 電路連接示意圖
- DS18B20模塊的 G、V、S分別連接 Arduino UNO的GND、VCC(+5V)、A0引腳。
- 示例代碼
//thermometer - Measuring temperature, record temperature fluctuations
int lm35Pin = A0;
int temp = 0;
int tempMin = 100;
int tempMax = -100;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i <= 9; i++) {
int signVal = analogRead(lm35Pin);
temp += (signVal * 5 * 100) / 1024;
signVal = 0;
delay(80);
}
temp = temp / 10;
if (temp > tempMax) {
tempMax = temp;
}
if (temp < tempMin) {
tempMin = temp;
}
Serial.print("Temp:");
Serial.print(temp);
Serial.print(" Cels,");
Serial.print(" Min:");
Serial.print(tempMin);
Serial.print(" Max:");
Serial.println(tempMax);
temp = 0;
delay(500);
}
程序下載地址:thermometer
- 串口監視結果
參考資料
更多建議和問題歡迎反饋至 YFRobot論壇
購買方式:YFRobot 電子工作室

