版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2027届浙江省温州市永嘉县化学九年级第一学期期中监测模拟试题含解析
- 2026年初级护师考试历年真题及答案
- 2026年秋季开学小学快乐阅读家长会课件
- 2026年秋季开学初中防暴力收心教育课件
- 2026年秋季开学小学遵守纪律法治教育课件
- 2026年秋季开学高中晨读效率收心备考课件
- 2026年秋季开学高一新生刷题技巧入学教育
- 2026年秋季开学美育启蒙家校共育讲座课件
- 班主任学年的述职报告范文(20篇)
- 小学信息技术第二册下册 第12课 添加附件教案 苏科版
- 2026年昆山经济技术开发区公开招聘社区编外工作人员18人考试备考题库及答案详解
- 抗耐药革兰阴性菌治疗指南2026
- 2026年四川德阳电子科技大学德阳研究院(德阳三星湖传感技术产业研究中心)面向社会公开招聘3人笔试备考试题及答案详解
- 2026CSCO结直肠癌诊疗指南解读课件
- 眼眶爆裂性骨折诊断与治疗
- 2025北京市事业单位就业援藏专项招聘21人备考试题含答案
- 2026国网新版SLVA低压开关柜标准解析
- 巨幼细胞性贫血诊疗指南(2025年版)
- 2026年留疆战士考试题库及答案含解析
- 2026湖南长沙雅礼中学高三高考模拟测试数学试题(含答案解析)
- 北京高盟新材料股份有限公司无溶剂型聚氨酯粘合剂生产线技术改造项目环境影响报告
评论
0/150
提交评论