mirror of
https://github.com/dhrubasaha08/DHT11.git
synced 2023-10-23 22:17:45 +03:00
Update DHT11.h
Adds private class variables for temperature and humidity so that both humidity and temperature can be read simultaneously. Adds a lastPollTime variable to prevent polling the sensor too frequently Signed-off-by: DrJPK <91477569+DrJPK@users.noreply.github.com>
This commit is contained in:
parent
5bba4adae1
commit
f9ff3f4ec3
11
src/DHT11.h
11
src/DHT11.h
@ -6,6 +6,7 @@
|
||||
* Author: Dhruba Saha
|
||||
* Version: 2.0.0
|
||||
* License: MIT
|
||||
* Modified: John Kennedy
|
||||
*/
|
||||
|
||||
#ifndef DHT11_h
|
||||
@ -59,6 +60,16 @@ public:
|
||||
|
||||
private:
|
||||
int _pin; // Pin number used for communication with the DHT11 sensor.
|
||||
int _temperature; // Holds the last known value of the Temperature.
|
||||
int _humidity; // Holds the last known value of the Humidity.
|
||||
long _lastPollTime; //Value of millis() when sensor last polled. DHT11 cannot be polled faster than 1Hz
|
||||
static const int _pollTime = 1000;
|
||||
|
||||
/**
|
||||
* Reads the Temperature and Humidity data from the DHT11 and saves them to the private variables
|
||||
* _temperature and _humidity
|
||||
*/
|
||||
void readSensor();
|
||||
|
||||
/**
|
||||
* Reads a byte of data from the DHT11 sensor.
|
||||
|
Loading…
Reference in New Issue
Block a user