温度传感器 - 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 电子工作室

