Adafruit SHTC3 Library
Adafruit_SHTC3.h
Go to the documentation of this file.
1 
20 #ifndef ADAFRUIT_SHTC3_H
21 #define ADAFRUIT_SHTC3_H
22 
23 #include "Arduino.h"
24 #include <Adafruit_I2CDevice.h>
25 #include <Adafruit_Sensor.h>
26 
27 #define SHTC3_DEFAULT_ADDR 0x70
28 #define SHTC3_NORMAL_MEAS_TFIRST_STRETCH \
29  0x7CA2
30 #define SHTC3_LOWPOW_MEAS_TFIRST_STRETCH \
31  0x6458
32 #define SHTC3_NORMAL_MEAS_HFIRST_STRETCH \
33  0x5C24
34 #define SHTC3_LOWPOW_MEAS_HFIRST_STRETCH \
35  0x44DE
37 #define SHTC3_NORMAL_MEAS_TFIRST \
38  0x7866
39 #define SHTC3_LOWPOW_MEAS_TFIRST \
40  0x609C
41 #define SHTC3_NORMAL_MEAS_HFIRST \
42  0x58E0
43 #define SHTC3_LOWPOW_MEAS_HFIRST \
44  0x401A
46 #define SHTC3_READID 0xEFC8
47 #define SHTC3_SOFTRESET 0x805D
48 #define SHTC3_SLEEP 0xB098
49 #define SHTC3_WAKEUP 0x3517
51 class Adafruit_SHTC3;
52 
58 class Adafruit_SHTC3_Humidity : public Adafruit_Sensor {
59 public:
62  Adafruit_SHTC3_Humidity(Adafruit_SHTC3 *parent) { _theSHTC3 = parent; }
63  bool getEvent(sensors_event_t *);
64  void getSensor(sensor_t *);
65 
66 private:
67  int _sensorID = 0x03C1;
68  Adafruit_SHTC3 *_theSHTC3 = NULL;
69 };
70 
76 class Adafruit_SHTC3_Temp : public Adafruit_Sensor {
77 public:
80  Adafruit_SHTC3_Temp(Adafruit_SHTC3 *parent) { _theSHTC3 = parent; }
81 
82  bool getEvent(sensors_event_t *);
83  void getSensor(sensor_t *);
84 
85 private:
86  int _sensorID = 0x0C30;
87  Adafruit_SHTC3 *_theSHTC3 = NULL;
88 };
89 
94 public:
95  Adafruit_SHTC3(void);
96  ~Adafruit_SHTC3(void);
97 
98  bool begin(TwoWire *theWire = &Wire);
99  uint16_t readID(void);
100  void reset(void);
101  void sleep(bool sleepmode);
102  void lowPowerMode(bool readmode);
103 
104  bool getEvent(sensors_event_t *humidity, sensors_event_t *temp);
105  Adafruit_Sensor *getTemperatureSensor(void);
106  Adafruit_Sensor *getHumiditySensor(void);
107 
108 protected:
109  float _temperature,
110  _humidity;
111 
113  uint16_t _sensorid_temp;
114 
115  Adafruit_I2CDevice *i2c_dev = NULL;
116  Adafruit_SHTC3_Temp *temp_sensor = NULL;
117  Adafruit_SHTC3_Humidity *humidity_sensor =
118  NULL;
119 
120 private:
121  bool _lpMode = false;
122  bool writeCommand(uint16_t cmd);
123  bool readCommand(uint16_t command, uint8_t *buffer, uint8_t num_bytes);
124 
125  friend class Adafruit_SHTC3_Temp;
126  friend class Adafruit_SHTC3_Humidity;
128 
130  void fillTempEvent(sensors_event_t *temp, uint32_t timestamp);
131  void fillHumidityEvent(sensors_event_t *humidity, uint32_t timestamp);
132 };
133 
134 #endif
bool getEvent(sensors_event_t *)
Gets the humidity as a standard sensor event.
Definition: Adafruit_SHTC3.cpp:244
void getSensor(sensor_t *)
Gets the sensor_t object describing the SHTC3&#39;s humidity sensor.
Definition: Adafruit_SHTC3.cpp:224
Adafruit_SHTC3_Humidity(Adafruit_SHTC3 *parent)
Create an Adafruit_Sensor compatible object for the humidity sensor.
Definition: Adafruit_SHTC3.h:62
Adafruit Unified Sensor interface for the temperature sensor component of SHTC3.
Definition: Adafruit_SHTC3.h:76
uint16_t _sensorid_humidity
ID number for humidity.
Definition: Adafruit_SHTC3.h:112
Adafruit Unified Sensor interface for the humidity sensor component of SHTC3.
Definition: Adafruit_SHTC3.h:58
Definition: Adafruit_SHTC3.h:93
float _temperature
Last reading&#39;s temperature (C)
Definition: Adafruit_SHTC3.h:109
uint16_t _sensorid_temp
ID number for temperature.
Definition: Adafruit_SHTC3.h:113
Adafruit_SHTC3_Temp(Adafruit_SHTC3 *parent)
Create an Adafruit_Sensor compatible object for the temp sensor.
Definition: Adafruit_SHTC3.h:80