Adafruit Library
WipperSnapper_I2C_Driver_SI7021.h
Go to the documentation of this file.
1 
17 #ifndef WipperSnapper_I2C_Driver_SI7021_H
18 #define WipperSnapper_I2C_Driver_SI7021_H
19 
21 #include <Adafruit_Si7021.h>
22 #include <Wire.h>
23 
24 /**************************************************************************/
28 /**************************************************************************/
30 
31 public:
32  /*******************************************************************************/
40  /*******************************************************************************/
41  WipperSnapper_I2C_Driver_SI7021(TwoWire *i2c, uint16_t sensorAddress)
42  : WipperSnapper_I2C_Driver(i2c, sensorAddress) {
43  _i2c = i2c;
44  _sensorAddress = sensorAddress;
45  }
46 
47  /*******************************************************************************/
51  /*******************************************************************************/
53  // Called when a Si7021 component is deleted.
54  delete _si7021;
55  }
56 
57  /*******************************************************************************/
62  /*******************************************************************************/
63  bool begin() {
64  _si7021 = new Adafruit_Si7021(_i2c);
65  return _si7021->begin();
66  }
67 
68  /*******************************************************************************/
76  /*******************************************************************************/
77  bool getEventAmbientTemp(sensors_event_t *tempEvent) {
78  // check if sensor is enabled and data is available
79  tempEvent->temperature = _si7021->readTemperature();
80  return true;
81  }
82 
83  /*******************************************************************************/
91  /*******************************************************************************/
92  bool getEventRelativeHumidity(sensors_event_t *humidEvent) {
93  // check if sensor is enabled and data is available
94  humidEvent->relative_humidity = _si7021->readHumidity();
95  return true;
96  }
97 
98 protected:
99  Adafruit_Si7021 *_si7021;
100 };
101 
102 #endif // WipperSnapper_I2C_Driver_SI7021
bool getEventAmbientTemp(sensors_event_t *tempEvent)
Gets the SI7021&#39;s current temperature.
Definition: WipperSnapper_I2C_Driver_SI7021.h:77
Adafruit_Si7021 * _si7021
SI7021 driver object.
Definition: WipperSnapper_I2C_Driver_SI7021.h:99
bool getEventRelativeHumidity(sensors_event_t *humidEvent)
Gets the SI7021&#39;s current relative humidity reading.
Definition: WipperSnapper_I2C_Driver_SI7021.h:92
Base class for I2C Drivers.
Definition: WipperSnapper_I2C_Driver.h:30
WipperSnapper_I2C_Driver_SI7021(TwoWire *i2c, uint16_t sensorAddress)
Constructor for a SI7021 sensor.
Definition: WipperSnapper_I2C_Driver_SI7021.h:41
uint16_t _sensorAddress
The I2C driver&#39;s unique I2C address.
Definition: WipperSnapper_I2C_Driver.h:1322
bool begin()
Initializes the SI7021 sensor and begins I2C.
Definition: WipperSnapper_I2C_Driver_SI7021.h:63
Class that provides a driver interface for the SI7021 sensor.
Definition: WipperSnapper_I2C_Driver_SI7021.h:29
~WipperSnapper_I2C_Driver_SI7021()
Destructor for an SI7021 sensor.
Definition: WipperSnapper_I2C_Driver_SI7021.h:52
TwoWire * _i2c
Pointer to the I2C driver&#39;s Wire object.
Definition: WipperSnapper_I2C_Driver.h:1321