Arduino使用TEMP 18B20模块

本文介绍37款传感器套件中的18B20模块,一开始搞不懂这个模块用来做什么,因为卖家给的图片介绍中就只有TEMP 18B20这几个字,示例代码中也没有相关的资料,只能自己找这个到底是做什么的。
首先是看芯片上有没有什么信息,图片如下,
Arduino使用TEMP 18B20模块 - gc_2299 - gc_2299的博客
芯片上有7Q-Tek 18B20 1523C01这几个字,于是在百度上直接搜索这些信息,搜到的都是关于DS18B20的信息,其中参考文献1中有详细的介绍。通过查看资料,可以确定本模块应该是测量温度的。传感器的实物图如下:
Arduino使用TEMP 18B20模块 - gc_2299 - gc_2299的博客
  各引脚的意义,最下面的引脚接电源负极,中间的引脚接电源正极,最上面的引脚是信号输出引脚 。测试代码使用的是参考文献2中的代码,代码如下:

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 9 on the Arduino
#define ONE_WIRE_BUS 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");

// Start up the library
sensors.begin();
}

void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");

Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(sensors.getTempCByIndex(0));

delay(500);
}

实物连接图如下:
Arduino使用TEMP 18B20模块 - gc_2299 - gc_2299的博客
 
代码运行结果如下:

Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 16.50




参考文献
[1]http://baike.baidu.com/link?url=-jkgfXFeWtcilH3IvJ9WZOXuC6Jxl1-Cvp_h-HDYTRvM3gb95Ph4e6PuVRriD7O8b3wsFVAsGdrpdFpmXX1X2x-JmMBcO17lzT01V8CJxXy
[2]http://qiita.com/hnw/items/315fad0d4b60ada10d00
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值