1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #ifndef DHT_H
- #define DHT_H
- #include "Arduino.h"
- #define DEBUG_PRINTER Serial
- #ifdef DHT_DEBUG
- #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
- #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
- #else
- #define DEBUG_PRINT(...) {}
- #define DEBUG_PRINTLN(...) {}
- #endif
- #define DHT11 11
- #define DHT12 12
- #define DHT22 22
- #define DHT21 21
- #define AM2301 21
- class DHT {
- public:
- DHT(uint8_t pin, uint8_t type, uint8_t count=6);
- void begin(uint8_t usec=55);
- float readTemperature(bool S=false, bool force=false);
- float convertCtoF(float);
- float convertFtoC(float);
- float computeHeatIndex(bool isFahrenheit=true);
- float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true);
- float readHumidity(bool force=false);
- bool read(bool force=false);
- private:
- uint8_t data[5];
- uint8_t _pin, _type;
- #ifdef __AVR
-
-
- uint8_t _bit, _port;
- #endif
- uint32_t _lastreadtime, _maxcycles;
- bool _lastresult;
- uint8_t pullTime;
- uint32_t expectPulse(bool level);
- };
- class InterruptLock {
- public:
- InterruptLock() {
- #if !defined(ARDUINO_ARCH_NRF52)
- noInterrupts();
- #endif
- }
- ~InterruptLock() {
- #if !defined(ARDUINO_ARCH_NRF52)
- interrupts();
- #endif
- }
- };
- #endif
|