-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,25 +22,57 @@ | |
SOFTWARE. | ||
*/ | ||
|
||
#ifndef SIMPLE_DHT_H | ||
#define SIMPLE_DHT_H | ||
|
||
// Arduino only. | ||
#if ARDUINO >= 100 | ||
#include "Arduino.h" | ||
#else | ||
#include "WProgram.h" | ||
#endif | ||
#ifndef __SIMPLE_DHT_H | ||
#define __SIMPLE_DHT_H | ||
|
||
#include <Arduino.h> | ||
|
||
/* | ||
Simple DHT11 | ||
Simple, Stable and Fast DHT11 library. | ||
The circuit: | ||
* VCC: 5V or 3V | ||
* GND: GND | ||
* DATA: Digital ping, for example, 2. | ||
23 Jan 2016 By winlin <[email protected]> | ||
// to read from dht11. | ||
// @param pin the DHT11 pin. | ||
// @param ptemperature output, NULL to igore. | ||
// @param phumidity output, NULL to ignore. | ||
// @param pdata output 40bits sample, NULL to ignore. | ||
// @remark the min delay for this method is 200ms. | ||
extern int simple_dht11_read(int pin, byte* ptemperature, byte* phumidity, byte pdata[40]); | ||
https://github.com/winlinvip/SimpleDHT#usage | ||
// print the raw data of dht11, 5bytes(40bits). | ||
extern void simple_dht11_serial_print(byte data[40]); | ||
*/ | ||
class SimpleDHT11 { | ||
public: | ||
// to read from dht11. | ||
// @param pin the DHT11 pin. | ||
// @param ptemperature output, NULL to igore. | ||
// @param phumidity output, NULL to ignore. | ||
// @param pdata output 40bits sample, NULL to ignore. | ||
// @remark the min delay for this method is 1s. | ||
int read(int pin, byte* ptemperature, byte* phumidity, byte pdata[40]); | ||
private: | ||
// confirm the OUTPUT is level in us, | ||
// for example, when DHT11 start sample, it will | ||
// 1. PULL LOW 80us, call confirm(pin, 80, LOW) | ||
// 2. PULL HIGH 80us, call confirm(pin, 80, HIGH) | ||
// @return 0 success; oterwise, error. | ||
// @remark should never used to read bits, | ||
// for function call use more time, maybe never got bit0. | ||
// @remark please use simple_dht11_read(). | ||
int confirm(int pin, int us, byte level); | ||
// @data the bits of a byte. | ||
// @remark please use simple_dht11_read(). | ||
byte bits2byte(byte data[8]); | ||
// read temperature and humidity from dht11. | ||
// @param pin the pin for DHT11, for example, 2. | ||
// @param data a byte[40] to read bits to 5bytes. | ||
// @return 0 success; otherwise, error. | ||
// @remark please use simple_dht11_read(). | ||
int sample(int pin, byte data[40]); | ||
// parse the 40bits data to temperature and humidity. | ||
// @remark please use simple_dht11_read(). | ||
int parse(byte data[40], byte* ptemperature, byte* phumidity); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
########################################### | ||
# Syntax Coloring Map For simple-dht | ||
# Syntax Coloring Map For SimpleDHT | ||
########################################### | ||
|
||
########################################### | ||
# Datatypes (KEYWORD1) | ||
########################################### | ||
|
||
DHT KEYWORD1 | ||
SimpleDHT11 KEYWORD1 | ||
|
||
########################################### | ||
# Methods and Functions (KEYWORD2) | ||
########################################### | ||
|
||
begin KEYWORD2 | ||
readTemperature KEYWORD2 | ||
convertCtoF KEYWORD2 | ||
convertFtoC KEYWORD2 | ||
computeHeatIndex KEYWORD2 | ||
readHumidity KEYWORD2 | ||
read KEYWORD2 | ||
|
||
########################################### | ||
# Constants (LITERAL1) | ||
########################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=Simple DHT sensor library | ||
version=1.0.0 | ||
name=SimpleDHT | ||
version=1.0.1 | ||
author=Winlin <[email protected]> | ||
maintainer=Winlin <[email protected]> | ||
sentence=Arduino Temp & Humidity Sensors for DHT11 etc. | ||
paragraph=Simple pure C code with lots of comments, strictly follow the standard DHT protocol, supports 0.5HZ or 1HZ sampling rate. | ||
paragraph=Simple C++ code with lots of comments, strictly follow the standard DHT protocol, supports 0.5HZ or 1HZ sampling rate. | ||
category=Sensors | ||
url=https://github.com/winlinvip/simple-dht | ||
architectures=* |