资源简介
libraries.zip

代码片段和文件信息
//
// FILE: dht11.cpp
// VERSION: 0.4.1
// PURPOSE: DHT11 Temperature & Humidity Sensor library for Arduino
// LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
//
// DATASHEET: http://www.micro4you.com/files/sensor/DHT11.pdf
//
// HISTORY:
// George Hadjikyriacou - Original version (??)
// Mod by SimKard - Version 0.2 (24/11/2010)
// Mod by Rob Tillaart - Version 0.3 (28/03/2011)
// + added comments
// + removed all non DHT11 specific code
// + added references
// Mod by Rob Tillaart - Version 0.4 (17/03/2012)
// + added 1.0 support
// Mod by Rob Tillaart - Version 0.4.1 (19/05/2012)
// + added error codes
//
#include “dht11.h“
// Return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht11::read(int pin)
{
// BUFFER TO RECEIVE
uint8_t bits[5];
uint8_t cnt = 7;
uint8_t idx = 0;
// EMPTY BUFFER
for (int i=0; i< 5; i++) bits[i] = 0;
// REQUEST SAMPLE
pinMode(pin OUTPUT);
digitalWrite(pin LOW);
delay(18);
digitalWrite(pin HIGH);
delayMicroseconds(40);
pinMode(pin INPUT);
// ACKNOWLEDGE or TIMEOUT
unsigned int loopCnt = 10000;
while(digitalRead(pin) == LOW)
if (loopCnt-- == 0) return DHTLIB_ERROR_TIMEOUT;
loopCnt = 10000;
while(digitalRead(pin) == HIGH)
if (loopCnt-- == 0) return DHTLIB_ERROR_TIMEOUT;
// READ OUTPUT - 40 BITS => 5 BYTES or TIMEOUT
for (int i=0; i<40; i++)
{
loopCnt = 10000;
while(digitalRead(pin) == LOW)
if (loopCnt-- == 0) return DHTLIB_ERROR_TIMEOUT;
unsigned long t = micros();
loopCnt = 10000;
while(digitalRead(pin) == HIGH)
if (loopCnt-- == 0) return DHTLIB_ERROR_TIMEOUT;
if ((micros() - t) > 40) bits[idx] |= (1 << cnt);
if (cnt == 0) // next byte?
{
cnt = 7; // restart at MSB
idx++; // next byte!
}
else cnt--;
}
// WRITE TO RIGHT VARS
// as bits[1] and bits[3] are allways zero they are omitted in formulas.
humidity = bits[0];
temperature = bits[2];
uint8_t sum = bits[0] + bits[2];
if (bits[4] != sum) return DHTLIB_ERROR_CHECKSUM;
return DHTLIB_OK;
}
//
// END OF FILE
//
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-09-05 10:45 Dht11\
文件 2149 2012-09-04 14:09 Dht11\dht11.cpp
文件 392 2012-09-04 14:38 Dht11\dht11.h
目录 0 2012-09-05 10:45 Dht11\examples\
目录 0 2012-09-05 10:45 Dht11\examples\dht11\
文件 2474 2012-09-05 10:41 Dht11\examples\dht11\dht11.ino
目录 0 2014-07-05 22:10 U8glib\
文件 6225 2014-07-05 22:10 U8glib\ChangeLog
文件 733 2014-07-05 22:10 U8glib\INSTALL.TXT
文件 2764 2014-07-05 22:10 U8glib\U8glib.cpp
文件 53814 2014-07-05 22:10 U8glib\U8glib.h
目录 0 2014-07-05 22:10 U8glib\examples\
目录 0 2014-07-05 22:10 U8glib\examples\A2Printer\
文件 3751 2014-07-05 22:10 U8glib\examples\A2Printer\A2Printer.ino
目录 0 2014-07-05 22:10 U8glib\examples\Bitmap\
文件 11286 2014-07-05 22:10 U8glib\examples\Bitmap\Bitmap.ino
目录 0 2014-07-05 22:10 U8glib\examples\Chess\
文件 12859 2014-07-05 22:10 U8glib\examples\Chess\Chess.ino
目录 0 2014-07-05 22:10 U8glib\examples\Color\
文件 12122 2014-07-05 22:10 U8glib\examples\Color\Color.ino
目录 0 2014-07-05 22:10 U8glib\examples\Console\
文件 13705 2014-07-05 22:10 U8glib\examples\Console\Console.ino
目录 0 2014-07-05 22:10 U8glib\examples\F\
文件 11594 2014-07-05 22:10 U8glib\examples\F\F.ino
目录 0 2014-07-05 22:10 U8glib\examples\FPS\
文件 18888 2014-07-05 22:10 U8glib\examples\FPS\FPS.ino
目录 0 2014-07-05 22:10 U8glib\examples\GraphicsTest\
文件 14687 2014-07-05 22:10 U8glib\examples\GraphicsTest\GraphicsTest.ino
目录 0 2014-07-05 22:10 U8glib\examples\HelloWorld\
文件 11867 2014-07-05 22:10 U8glib\examples\HelloWorld\HelloWorld.ino
目录 0 2014-07-05 22:10 U8glib\examples\Menu\
............此处省略127个文件信息
相关资源
- PID_AutoTune_v0.rar
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
评论
共有 条评论