版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、DS18B20 Temperature SensorDS18B20温度传感器The DS18B20 temperature sensor is a 1-wire digital temperature sensor. This means that you can read the temperature with a very simple circuit setup. It communicates on common bus, which means that you can connect several devices and read their values using just
2、 one digital pin of the Arduino. DS18B20温度传感器是单线数字温度传感器。这意味着你可以使用非常简单的循环设置来读取温度。它在公共总线上进行通信,这意味着你可以连接多个设备并使用Arduino的一个数字引脚读取它们的值。The sensor has just three pins as you can see in the following figure:传感器只有三个引脚,如下图所示:The DS18B20 is also available in waterproof version:DS18B20在防水版中也是可利用的。Features特征Here
3、s some main features of the DS18B20 temperature sensor:下面是温度传感器的一些主要特征:Communicates over 1-wire bus communication通过单总线通信Operating range temperature: -55C to 125C温度工作范围:-55C到125CAccuracy +/-0.5 C (between the range -10C to 85C)精度+/-0.5 C(介于-10C到85C之间)Where to buy?去哪买?Click the link below to compare t
4、he sensor at different stores and find the best price点击下方链接比较一下不同商店中的传感器并选一个最好的价格。:DS18B20 digital temperature sensorDS18B20 temperature sensor with the Arduino使用Arduino的DS18B20温度传感器In this example, youll read the temperature using theDS18B20 sensor and the Arduino. The readings will be displayed on
5、 the Arduino Serial Monitor.在这个示例中,你将使用DS18B20传感器和Arduino来读取温度,读数将显示在Arduino系列监视器上。For this example, youll need the following parts:对于这个示例,你需要以下部分:Figure图形Name名字Check Price价格Arduino UNOFind best price onMaker AdvisorDS18B20 temperature sensorDS18B20温度传感器Find best price onMaker AdvisorBreadboard面包板Fi
6、nd best price onMaker Advisor4.7k Resistor4.7 k欧电阻Find best price onMaker AdvisorJumper Wires传感器连接线Find best price onMaker AdvisorSchematic示意图The sensor can operate in two different modes:传感器可以以两种不同的模式工作:Normal mode: 3-wire connection is needed. Heres the schematic you need to follow:正常模式:需要3线连接。这里是
7、你需要遵循的示意图。Parasite mode: only 2 wires required, the data and ground. The sensor derives its power from the data line. In this case, heres the schematic you need to follow:寄生模式:只需要2根导线,数据和地面。传感器从数据线导出其功率。在这种情况下,下面是你需要遵循的示意图:You can read the temperature of more than one sensor at the same time using j
8、ust one digital Arduino pin. For that, you just need to connect all the DQ pinsto any digital Arduino pin.你可以只用一个数字Arduino引脚同时读取多个传感器的温度。为此,你只需要将所有DQ引脚连接到任何数字Arduino引脚。Code代码Youll need to install the OneWire Library and DallasTemperature Library.你需要安装OneWire Library和DallasTemperature LibraryInstalli
9、ng the OneWire Library安装单线图书馆1.Click here to download the OneWire library.You should have a .zip folder in your Downloads1.点击这里下载OneWire Library。你应该有一个.zip文件夹在你的下载中。2.Unzip the.zip folder and you should get OneWire-master folder2.解压缩.zip文件夹,你会看到单线主控器文件夹。3.Rename your folder from OneWire-master To On
10、eWire3.将你的文件夹从OneWire-master重命名为OneWire4.Move the OneWire folder to your Arduino IDE installation libraries folder4.将OneWire文件夹移动到你的Arduino IDE安装库文件夹中。5.Finally, re-open your Arduino IDE5.最后,重新打开你的Arduino IDEInstalling the DallasTemperature Library安装温度场库1.Click here to download the DallasTemperature
11、 library.You should have a .zip folder in your Downloads1.点击这里下载DallasTemperature library。在你的下载里会有一个.zip文件夹2. Unzip the.zip folder and you should get OneWire-master folder.2.解压缩.zip文件夹,你会得到OneWire-master文件夹3.Rename your folder from OneWire-master to OneWire3.将你的文件夹从OneWire-master重命名为OneWire4.Move th
12、e OneWire folder to your Arduino IDE installation libraries folder4.将OneWire文件夹移动到你的Arduino IDE安装库文件夹中5.Finally, re-open your Arduino IDE5.最后,重新打开你的Arduino IDEAfter installing the needed libraries, upload the following code to your Arduino board.在安装所需的库之后,将下面的代码上传到你的Arduino板。/*Rui SantosComplete pro
13、ject details at Based on the Dallas Temperature Library example*/#include#include/ Data wire is connected to the Arduino digital pin 2/数据线连接到Arduino数字引脚2#define ONE_WIRE_BUS 2/ Setup a oneWire instance to communicate with any OneWire devices/设置任何一个有限设备的通信OneWire oneWire
14、(ONE_WIRE_BUS);/ Pass our oneWire reference to Dallas Temperature sensor/将单线参考信号传递到达拉斯温度传感器 DallasTemperature sensors(&oneWire);void setup(void)/ Start serial communication for debugging purposes/为调试目的启动串行通信Serial.begin(9600);/ Start up the library/启动库sensors.begin();Void loop(void) / Call sensors.r
15、equestTemperatures() to issue a global temperature and Requests to all devices on the bus/调用传感器,请求温度()在总线上发出全局温度和请求所有设备sensors.requestTemperatures(); Serial.print(Celsius temperature: );/ Why byIndex? You can have more than one IC on the same bus. 0 refers to the first IC on the wire/为什么“索引”?你可以在同一总
16、线有不止一个集成电路,0指一个集成电路Serial.print(sensors.getTempCByIndex(0); Serial.print( -Fahrenheit temperature: );Serial.println(sensors.getTempFByIndex(0);delay(1000);SOURCE CODE源代码/RuiSantosdotme/Random-Nerd-Tutorials/blob/master/Projects/DS18B20_Temperature_Sensor_Arduino.inoFinally, you should open the Arduino IDE serial monitor at a 9600 baud rateand youll see the temperature displayed in both Celsius and Fahrenheit最后,你应该以9600波特率打开Arduino IDE串行监视器,你将看到在摄氏度和华氏度中显示的温度。Wrapping up总结The DS18B2 temperature sensor is a very useful one. It allows you to
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 地理信息建库员安全生产规范知识考核试卷含答案
- 2026中国呼吸道传染病快速检测产品市场培育策略
- 2026云计算数据中心能效优化与可持续发展报告
- 2026中国液体化工物流供应链优化与协同发展分析报告
- 2026中国液体化学品物流外包决策模型与实施策略
- 2026中国老年保健饮料功能宣称规范与市场教育策略报告
- 2026乳制品质量安全追溯系统建设与应用分析报告
- 2026中国海水淡化核心材料国产化进程与市场壁垒分析报告
- 2026中国港口物流效率提升与转型升级分析报告
- 2026金融科技行业监管政策动态跟踪分析及区块链技术落地应用场景前景调查报告
- DB51-T 3387-2026 四川盆地城市工业有机废气活性炭治理技术规范
- 2026年机关事业单位工勤技能岗位等级考试《三级汽车驾驶与维修员》汽车驾驶3
- 淡水水产养殖项目水资源论证报告书
- 2026河北机关事业单位工人技能等级考试(汽车驾驶员·高级)历年参考题库含答案详解2卷
- 风电项目节能评估报告
- 聘请住家保姆协议书
- 第二届重庆市市场监管系统执法办案电子数据取证技能大竞赛赛完整试题
- 测绘安全作业培训内容
- 中外合作办学审计制度
- 2025年华电集团机械笔试及答案
- 中考物理电路设计与电路故障分析三年2023-2025中考真题分类汇编解析版
评论
0/150
提交评论