2017-12-12 16:04:06 -05:00
|
|
|
#ifndef DHT12_H
|
|
|
|
#define DHT12_H
|
|
|
|
//
|
|
|
|
// FILE: DHT12.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: DHT_I2C library for Arduino .
|
2018-09-02 10:26:19 -04:00
|
|
|
// VERSION: 0.1.2
|
2017-12-12 16:04:06 -05:00
|
|
|
// HISTORY: See DHT12.cpp
|
|
|
|
// URL: https://github.com/RobTillaart/Arduino/tree/master/libraries/
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Wire.h"
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
2018-09-02 10:26:19 -04:00
|
|
|
#define DHT12_VERSION "0.1.2"
|
2017-12-12 16:04:06 -05:00
|
|
|
|
2017-12-21 07:05:45 -05:00
|
|
|
#define DHT12_OK 0
|
|
|
|
#define DHT12_ERROR_CHECKSUM -10
|
|
|
|
#define DHT12_ERROR_CONNECT -11
|
|
|
|
#define DHT12_MISSING_BYTES -12
|
2017-12-12 16:04:06 -05:00
|
|
|
|
|
|
|
class DHT12
|
|
|
|
{
|
|
|
|
public:
|
2017-12-21 07:05:45 -05:00
|
|
|
|
|
|
|
#ifdef ESP8266
|
|
|
|
void begin(uint8_t sda, uint8_t scl);
|
|
|
|
#endif
|
|
|
|
void begin();
|
2017-12-12 16:04:06 -05:00
|
|
|
|
|
|
|
int8_t read();
|
|
|
|
|
|
|
|
float humidity;
|
|
|
|
float temperature;
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t bits[5];
|
|
|
|
int _readSensor();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// END OF FILE
|