




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Arduino 湿度传感器 在本节中 我们将学习如何使 不同的传感器连接我们的 Arduino 板 我们将讨论以 下传感器 湿度传感器 DHT22 温度传感器 LM35 检测传感器 简单 触发 PIR 传感器 超声波传感器 GPS 湿度传感器 DHT22 DHT 22 也称为 AM2302 是 个数字输出 相对湿度和温度传感器 它使 电容式湿 度传感器和热敏电阻测量周围空 并在数据引脚上发送数字信号 在本例中 您将了解如何将此传感器与 Arduino UNO 起使 室温和湿度将打印到 串 监视器上 DHT 22 传感器 连接很简单 左边的第 个引脚为 3 5V 电源 第 个引脚连接到数据输 引脚 最右 边的引脚连接到地 技术细节 电源 3 5V 最 电流 2 5mA 湿度 0 100 精确度为 2 5 温度 40 80 C 精度为 0 5 C 必需的组件 您将需要以下组件 1 Breadboard 包板 1 Arduino Uno R3 1 DHT22 1 10K欧姆电阻 程序 按照电路图并挂接 包板上的组件 如下图所 草图 在计算机上打开 Arduino IDE软件 在 Arduino 语 编码将控制你的电路 通过单击新 建打开 个新的草图 件 Arduino 代码 Example testing sketch for various DHT humidity temperature sens include DHT h define DHTPIN 2 what digital pin we re connected to Uncomment whatever type you re using define DHTTYPE DHT11 DHT 11 define DHTTYPE DHT22 DHT 22 AM2302 AM2321 define DHTTYPE DHT21 DHT 21 AM2301 Connect pin 1 on the left of the sensor to 5V NOTE If using a board with 3 3V logic like an Arduino Due conne to 3 3V instead of 5V Connect pin 2 of the sensor to whatever your DHTPIN is Connect pin 4 on the right of the sensor to GROUND Connect a 10K resistor from pin 2 data to pin 1 power of the Initialize DHT sensor Note that older versions of this library took an optional third tweak the timings for faster processors This parameter is no lo as the current DHT reading algorithm adjusts itself to work on f DHT dht DHTPIN DHTTYPE void setup Serial begin 9600 Serial println DHTxx test dht begin void loop delay 2000 Wait a few seconds between measurements float h dht readHumidity Reading temperature or humidity takes about 250 milliseconds float t dht readTemperature Read temperature as Celsius the default float f dht readTemperature true Read temperature as Fahrenheit isFahrenheit true Check if any reads failed and exit early to try again if isnan h isnan t isnan f Serial println Failed to read from DHT sensor return Compute heat index in Fahrenheit the default float hif puteHeatIndex f h Compute heat index in Celsius isFahreheit false float hic puteHeatIndex t h false Serial print Humidity Serial print h Serial print t Serial print Temperature Serial print t Serial print C Serial print f Serial print F t Serial print Heat index Serial print hic Serial print C Serial print hif Serial println F 代码说明 DHT22传感器具有四个端 V cc DATA NC GND 它们连接到电路板 如下 DATA 引脚连接到 Arduino 引脚号 2 Vcc 引脚到 5伏的 Arduino 板 GND 引脚连接到 Arduino 板的地 我们需要在 DATA 和 Vcc 引脚之间连接 1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年果味啤酒行业当前竞争格局与未来发展趋势分析报告
- 2024年大数据应用及处理技术能力知识考试题库与答案
- 2025年保育员(初级)操作证考试试题及答案
- 2025年全民病毒感染防治基础知识试题与答案
- 2024年江苏省南京市保安员理论考试题库及答案
- (2025年)黑龙江省鸡西市中级会计职称经济法预测试题含答案
- (2025年)山西省晋城市中级会计职称经济法预测试题含答案
- 摔伤安全知识培训总结
- 陕西省汉中市2024-2025学年七年级下学期期末语文试题(解析版)
- 心复苏技术试题及答案
- GB/T 45460-2025钢丝绳在无轴向载荷条件下钢丝绳径向刚度的测定
- 社区健康教育知识讲座
- 2025-2030乐器产业规划专项研究报告
- 电视广播网络安全与数据保护技术考核试卷
- 防造假培训课件视频教程
- 2025届苏锡常镇高三语文一模作文解读及范文:我会洗碗呀
- 义务消防队组建方案
- 中邮保险笔试题型及答案
- 2025-2030中国ARM核心板行业市场现状分析及竞争格局与投资发展研究报告
- 脐灸技术操作流程图及考核标准
- 给药错误PDCA课件
评论
0/150
提交评论