14
14
#include " Arduino_SensorKit_BMP280.h" // Pressure
15
15
#include " Arduino_SensorKit_LIS3DHTR.h" // Accel
16
16
#include " Grove_Temperature_And_Humidity_Sensor/DHT.h" // Temp & Humidity
17
+ #undef DHT20
18
+ #include < DHT20.h> // Temp & Humidity
17
19
#include " U8g2/src/U8x8lib.h" // OLED Display
18
20
19
21
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) || defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI)
28
30
#error "This board is not supported by Arduino_SensorKit"
29
31
#endif
30
32
31
- class SensorKit_DHT ;
32
-
33
33
// The upstream U8X8 library provides two variants, one for hardware I2C (using
34
34
// the Wire object provided by Arduino) and one for software I2C. The latter
35
35
// doesn't seem to work. However it seems that when breaking the sensors from
@@ -54,18 +54,31 @@ class SensorKit_Oled : public _Oled_class {
54
54
};
55
55
extern SensorKit_Oled Oled;
56
56
57
+ class SensorKit_DHT11 ;
58
+ class SensorKit_DHT20 ;
57
59
extern SensorKit_LIS3DHTR Accelerometer;
58
60
extern SensorKit_BMP280 Pressure;
59
- extern SensorKit_DHT Environment;
60
- extern DHT Environment_I2C;
61
+ extern SensorKit_DHT11 Environment;
62
+ extern SensorKit_DHT20 Environment_I2C;
61
63
62
- // Subclass DHT
63
- class SensorKit_DHT : public DHT {
64
+ // Subclass DHT
65
+ class SensorKit_DHT11 : public DHT {
64
66
public:
65
- SensorKit_DHT (uint8_t pin, uint8_t type) : DHT(pin, type) {};
67
+ SensorKit_DHT11 (uint8_t pin, uint8_t type) : DHT(pin, type) {};
66
68
void setPin (uint8_t pin) {
67
- Environment = SensorKit_DHT (pin, DHT11);
69
+ Environment = SensorKit_DHT11 (pin, DHT11);
70
+ };
71
+ };
72
+
73
+ class SensorKit_DHT20 : public DHT20 {
74
+ public:
75
+ SensorKit_DHT20 () : DHT20(&_WIRE) {};
76
+ bool begin (void ) {
77
+ _WIRE.begin ();
78
+ return DHT20::begin ();
68
79
};
80
+ float readHumidity () { read (); return getHumidity (); };
81
+ float readTemperature () { read (); return getTemperature (); };
69
82
};
70
83
71
84
#endif
0 commit comments