资源简介
dht11 库文件 欢迎下载
代码片段和文件信息
/* DHT library
MIT license
written by Adafruit Industries
*/
#include “DHT.h“
#define MIN_INTERVAL 2000
#define TIMEOUT -1
DHT::DHT(uint8_t pin uint8_t type uint8_t count) {
_pin = pin;
_type = type;
#ifdef __AVR
_bit = digitalPinToBitMask(pin);
_port = digitalPinToPort(pin);
#endif
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
// reading pulses from DHT sensor.
// Note that count is now ignored as the DHT reading algorithm adjusts itself
// based on the speed of the processor.
}
// Optionally pass pull-up time (in microseconds) before DHT reading starts.
// Default is 55 (see function declaration in DHT.h).
void DHT::begin(uint8_t usec) {
// set up the pins!
pinMode(_pin INPUT_PULLUP);
// Using this value makes sure that millis() - lastreadtime will be
// >= MIN_INTERVAL right away. Note that this assignment wraps around
// but so will the subtraction.
_lastreadtime = millis() - MIN_INTERVAL;
DEBUG_PRINT(“DHT max clock cycles: “); DEBUG_PRINTLN(_maxcycles DEC);
pullTime = usec;
}
//boolean S == Scale. True == Fahrenheit; False == Celcius
float DHT::readTemperature(bool S bool force) {
float f = NAN;
if (read(force)) {
switch (_type) {
case DHT11:
f = data[2];
if (data[3] & 0x80) {
f = -1 - f ;
}
f += (data[3] & 0x0f) * 0.1;
if(S) {
f = convertCtoF(f);
}
break;
case DHT12:
f = data[2];
f += (data[3] & 0x0f) * 0.1;
if (data[2] & 0x80) {
f *= -1;
}
if(S) {
f = convertCtoF(f);
}
break;
case DHT22:
case DHT21:
f = ((word)(data[2] & 0x7F)) << 8 | data[3];
f *= 0.1;
if (data[2] & 0x80) {
f *= -1;
}
if(S) {
f = convertCtoF(f);
}
break;
}
}
return f;
}
float DHT::convertCtoF(float c) {
return c * 1.8 + 32;
}
float DHT::convertFtoC(float f) {
return (f - 32) * 0.55555;
}
float DHT::readHumidity(bool force) {
float f = NAN;
if (read(force)) {
switch (_type) {
case DHT11:
case DHT12:
f = data[0] + data[1] * 0.1;
break;
case DHT22:
case DHT21:
f = ((word)data[0]) << 8 | data[1];
f *= 0.1;
break;
}
}
return f;
}
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
float DHT::computeHeatIndex(bool isFahrenheit) {
float hi = computeHeatIndex(readTemperature(isFahrenheit) readHumidity()
isFahrenheit);
return isFahrenheit ? hi : convertFtoC(hi);
}
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
float DHT::computeHeatIndex(float temperature float percentHumidity
bool isFahrenheit) {
// Using both Rothfusz and Steadman‘s equations
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
float hi;
if (!isFahrenheit)
temperature = convertCtoF(temperature);
hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) *
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-18 18:20 DHT-sensor-library-master\
目录 0 2019-02-18 18:20 DHT-sensor-library-master\.github\
文件 2624 2019-02-18 18:20 DHT-sensor-library-master\.github\ISSUE_TEMPLATE.md
文件 1415 2019-02-18 18:20 DHT-sensor-library-master\.github\PULL_REQUEST_TEMPLATE.md
文件 9749 2019-02-18 18:20 DHT-sensor-library-master\DHT.cpp
文件 1804 2019-02-18 18:20 DHT-sensor-library-master\DHT.h
文件 6196 2019-02-18 18:20 DHT-sensor-library-master\DHT_U.cpp
文件 2297 2019-02-18 18:20 DHT-sensor-library-master\DHT_U.h
文件 942 2019-02-18 18:20 DHT-sensor-library-master\README.md
目录 0 2019-02-18 18:20 DHT-sensor-library-master\examples\
目录 0 2019-02-18 18:20 DHT-sensor-library-master\examples\DHT_Unified_Sensor\
文件 3294 2019-02-18 18:20 DHT-sensor-library-master\examples\DHT_Unified_Sensor\DHT_Unified_Sensor.ino
目录 0 2019-02-18 18:20 DHT-sensor-library-master\examples\DHTtester\
文件 2539 2019-02-18 18:20 DHT-sensor-library-master\examples\DHTtester\DHTtester.ino
文件 529 2019-02-18 18:20 DHT-sensor-library-master\keywords.txt
文件 321 2019-02-18 18:20 DHT-sensor-library-master\library.properties
相关资源
- Arduino nano 工程文件
- Arduino教程 Lesson 之--自制风扇
- 基于Arduino的智能环境监控系统设计
- 基于Arduino和Machtalk的温棚环境监测系
- arduino pca9685多舵机同时控制案例
- arduino技术内幕
- Arduino电子设计实战指南.零基础篇_超
- 物联网智能家居平台DIY:ARDUINO 物联网
- 实验1.zip arduino跑马灯led灯实验,串口
- opencat所有资料.zip
- arduino主机,stm8从机。I2C测试 。每次
- DS18B20_Serial_println.ino
- ps2手柄arduino库文件
- 基于手机蓝牙的arduino遥控小车
- arduino中的can库函数
- 密码+指纹锁资料包.rar
- 贝壳物联arduino esp8266 demo版本
- HMC5883L罗盘指南针模块库文件及中英文
- arduino 小贱钟源码及教程
- Atom-TMC2208Pilot在Arduino上运行的应用程
- 写字机制作方案
- PID-增量式PID和位置式PID算法实现和
- Building Wireless Sensor Networks Using Arduin
- vc控制Arduino,实现串口通信
- Arduino入门经典
- Arduino所有库.zip
- 基于STM32和arduino的MPU9250九轴传感器代
- GY-9960模块Keil 和Arduino驱动程序
- ILI9486 3.5TFT液晶屏Arduino驱动
- [高清文字版]Arduino开发从零开始学
评论
共有 条评论