mirror of
https://github.com/adafruit/DHT-sensor-library.git
synced 2023-10-23 22:20:38 +03:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
edcd0e06e6 | |||
15020aa891 | |||
572347f137 | |||
e9daf69083 |
2
DHT.cpp
2
DHT.cpp
@ -11,8 +11,10 @@ written by Adafruit Industries
|
|||||||
DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
|
DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
|
||||||
_pin = pin;
|
_pin = pin;
|
||||||
_type = type;
|
_type = type;
|
||||||
|
#ifdef __AVR
|
||||||
_bit = digitalPinToBitMask(pin);
|
_bit = digitalPinToBitMask(pin);
|
||||||
_port = digitalPinToPort(pin);
|
_port = digitalPinToPort(pin);
|
||||||
|
#endif
|
||||||
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
|
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
|
||||||
// reading pulses from DHT sensor.
|
// reading pulses from DHT sensor.
|
||||||
// Note that count is now ignored as the DHT reading algorithm adjusts itself
|
// Note that count is now ignored as the DHT reading algorithm adjusts itself
|
||||||
|
7
DHT.h
7
DHT.h
@ -48,7 +48,12 @@ class DHT {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t data[5];
|
uint8_t data[5];
|
||||||
uint8_t _pin, _type, _bit, _port;
|
uint8_t _pin, _type;
|
||||||
|
#ifdef __AVR
|
||||||
|
// Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask
|
||||||
|
// for the digital pin connected to the DHT. Other platforms will use digitalRead.
|
||||||
|
uint8_t _bit, _port;
|
||||||
|
#endif
|
||||||
uint32_t _lastreadtime, _maxcycles;
|
uint32_t _lastreadtime, _maxcycles;
|
||||||
bool _lastresult;
|
bool _lastresult;
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
This is an Arduino library for the DHT series of low cost temperature/humidity sensors.
|
This is an Arduino library for the DHT series of low cost temperature/humidity sensors.
|
||||||
|
|
||||||
|
Tutorial: https://learn.adafruit.com/dht
|
||||||
|
|
||||||
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT. Check that the DHT folder contains DHT.cpp and DHT.h. Place the DHT library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT. Check that the DHT folder contains DHT.cpp and DHT.h. Place the DHT library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include "DHT.h"
|
#include "DHT.h"
|
||||||
|
|
||||||
#define DHTPIN 2 // what pin we're connected to
|
#define DHTPIN 2 // what digital pin we're connected to
|
||||||
|
|
||||||
// Uncomment whatever type you're using!
|
// Uncomment whatever type you're using!
|
||||||
//#define DHTTYPE DHT11 // DHT 11
|
//#define DHTTYPE DHT11 // DHT 11
|
||||||
#define DHTTYPE DHT22 // DHT 22 (AM2302)
|
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
|
||||||
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
||||||
|
|
||||||
// Connect pin 1 (on the left) of the sensor to +5V
|
// Connect pin 1 (on the left) of the sensor to +5V
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=DHT sensor library
|
name=DHT sensor library
|
||||||
version=1.2.2
|
version=1.2.3
|
||||||
author=Adafruit
|
author=Adafruit
|
||||||
maintainer=Adafruit <info@adafruit.com>
|
maintainer=Adafruit <info@adafruit.com>
|
||||||
sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors
|
sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors
|
||||||
|
Reference in New Issue
Block a user