AskSin++
Si7021.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin++
3 // 2018-04-03 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 // 2018-09-13 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 //- -----------------------------------------------------------------------------------------------------------------------
6 
7 #ifndef __SENSORS_SI7021_h__
8 #define __SENSORS_SI7021_h__
9 
10 #include <Sensors.h>
11 #include <Wire.h>
12 #include <Si7021.h>
13 namespace as {
14 
15 //https://github.com/jayjayuk/Si7021-Humidity-And-Temperature-Sensor-Library
16 class Si7021 : public Temperature, public Humidity {
17  SI7021 _si7021;
18 public:
19  Si7021 () {}
20  void init () {
21  _si7021.begin();
22  DPRINT(F("SI7021 SENSOR "));
23  if (_si7021.getDeviceID() > 0 && _si7021.getDeviceID() != 255) {
24  _present = true;
25  DPRINTLN(F("OK"));
26  } else {
27  _present = false;
28  DPRINTLN(F("ERR"));
29  }
30  }
31 
32  bool measure (__attribute__((unused)) bool async=false) {
33  if( present() == true ) {
34  _temperature = _si7021.readTemp() * 10;
35  _humidity = _si7021.readHumidity();
36  return true;
37  }
38  return false;
39  }
40 };
41 
42 }
43 
44 #endif
as::Humidity
Definition: Sensors.h:39
as::Temperature
Definition: Sensors.h:30
as::Si7021
Definition: Si7021.h:16