1414#include " Arduino_SensorKit_BMP280.h" // Pressure
1515#include " Arduino_SensorKit_LIS3DHTR.h" // Accel
1616#include " Grove_Temperature_And_Humidity_Sensor/DHT.h" // Temp & Humidity
17+ #undef DHT20
18+ #include < DHT20.h> // Temp & Humidity
1719#include " U8g2/src/U8x8lib.h" // OLED Display
1820
1921#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) || defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI)
2830 #error "This board is not supported by Arduino_SensorKit"
2931#endif
3032
31- class SensorKit_DHT ;
32-
3333// The upstream U8X8 library provides two variants, one for hardware I2C (using
3434// the Wire object provided by Arduino) and one for software I2C. The latter
3535// doesn't seem to work. However it seems that when breaking the sensors from
@@ -54,18 +54,31 @@ class SensorKit_Oled : public _Oled_class {
5454};
5555extern SensorKit_Oled Oled;
5656
57+ class SensorKit_DHT11 ;
58+ class SensorKit_DHT20 ;
5759extern SensorKit_LIS3DHTR Accelerometer;
5860extern SensorKit_BMP280 Pressure;
59- extern SensorKit_DHT Environment;
60- extern DHT Environment_I2C;
61+ extern SensorKit_DHT11 Environment;
62+ extern SensorKit_DHT20 Environment_I2C;
6163
62- // Subclass DHT
63- class SensorKit_DHT : public DHT {
64+ // Subclass DHT
65+ class SensorKit_DHT11 : public DHT {
6466 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) {};
6668 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 ();
6879 };
80+ float readHumidity () { read (); return getHumidity (); };
81+ float readTemperature () { read (); return getTemperature (); };
6982};
7083
7184#endif
0 commit comments