Arduino-湿度传感器._第1页
Arduino-湿度传感器._第2页
Arduino-湿度传感器._第3页
Arduino-湿度传感器._第4页
Arduino-湿度传感器._第5页
已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论