1 #ifndef LIB_ADAFRUIT_CCS811_H 2 #define LIB_ADAFRUIT_CCS811_H 10 #include <Adafruit_I2CDevice.h> 15 #define CCS811_ADDRESS (0x5A) 23 CCS811_MEAS_MODE = 0x01,
24 CCS811_ALG_RESULT_DATA = 0x02,
25 CCS811_RAW_DATA = 0x03,
26 CCS811_ENV_DATA = 0x05,
28 CCS811_THRESHOLDS = 0x10,
29 CCS811_BASELINE = 0x11,
31 CCS811_HW_VERSION = 0x21,
32 CCS811_FW_BOOT_VERSION = 0x23,
33 CCS811_FW_APP_VERSION = 0x24,
34 CCS811_ERROR_ID = 0xE0,
35 CCS811_SW_RESET = 0xFF,
40 CCS811_BOOTLOADER_APP_ERASE = 0xF1,
41 CCS811_BOOTLOADER_APP_DATA = 0xF2,
42 CCS811_BOOTLOADER_APP_VERIFY = 0xF3,
43 CCS811_BOOTLOADER_APP_START = 0xF4
47 CCS811_DRIVE_MODE_IDLE = 0x00,
48 CCS811_DRIVE_MODE_1SEC = 0x01,
49 CCS811_DRIVE_MODE_10SEC = 0x02,
50 CCS811_DRIVE_MODE_60SEC = 0x03,
51 CCS811_DRIVE_MODE_250MS = 0x04,
56 #define CCS811_HW_ID_CODE 0x81 58 #define CCS811_REF_RESISTOR 100000 72 bool begin(uint8_t addr = CCS811_ADDRESS, TwoWire *theWire = &Wire);
83 uint8_t hysteresis = 50);
143 Adafruit_I2CDevice *i2c_dev = NULL;
149 uint16_t _currentSelected;
150 uint16_t _rawADCreading;
152 void write8(byte reg, byte value);
153 void write16(byte reg, uint16_t value);
154 uint8_t read8(byte reg);
156 void read(uint8_t reg, uint8_t *buf, uint8_t num);
157 void write(uint8_t reg, uint8_t *buf, uint8_t num);
175 uint8_t DATA_READY : 1;
176 uint8_t APP_VALID : 1;
185 void set(uint8_t data) {
187 DATA_READY = (data >> 3) & 0x01;
188 APP_VALID = (data >> 4) & 0x01;
189 FW_MODE = (data >> 7) & 0x01;
203 uint8_t INT_THRESH : 1;
210 uint8_t INT_DATARDY : 1;
212 uint8_t DRIVE_MODE : 3;
215 return (INT_THRESH << 2) | (INT_DATARDY << 3) | (DRIVE_MODE << 4);
218 meas_mode _meas_mode;
223 uint8_t WRITE_REG_INVALID : 1;
227 uint8_t READ_REG_INVALID : 1;
231 uint8_t MEASMODE_INVALID : 1;
235 uint8_t MAX_RESISTANCE : 1;
238 uint8_t HEATER_FAULT : 1;
241 uint8_t HEATER_SUPPLY : 1;
243 void set(uint8_t data) {
244 WRITE_REG_INVALID = data & 0x01;
245 READ_REG_INVALID = (data & 0x02) >> 1;
246 MEASMODE_INVALID = (data & 0x04) >> 2;
247 MAX_RESISTANCE = (data & 0x08) >> 3;
248 HEATER_FAULT = (data & 0x10) >> 4;
249 HEATER_SUPPLY = (data & 0x20) >> 5;
Class that stores state and functions for interacting with CCS811 gas sensor chips.
Definition: Adafruit_CCS811.h:66
void setTempOffset(float offset)
set the temperature compensation offset for the device. This is needed to offset errors in NTC measur...
Definition: Adafruit_CCS811.h:134
void enableInterrupt()
enable the data ready interrupt pin on the device.
Definition: Adafruit_CCS811.cpp:69
void SWReset()
trigger a software reset of the device
Definition: Adafruit_CCS811.cpp:239
void setEnvironmentalData(float humidity, float temperature)
set the humidity and temperature compensation for the sensor.
Definition: Adafruit_CCS811.cpp:134
uint16_t getRawADCreading()
returns the raw ADC reading. This does does not read the sensor. To do so, call readData() ...
Definition: Adafruit_CCS811.h:125
bool checkError()
read the status register and store any errors.
Definition: Adafruit_CCS811.cpp:251
void setBaseline(uint16_t baseline)
set the baseline for the sensor.
Definition: Adafruit_CCS811.cpp:181
void setDriveMode(uint8_t mode)
sample rate of the sensor.
Definition: Adafruit_CCS811.cpp:59
uint16_t getCurrentSelected()
returns the "Current Selected" in uA. This does does not read the sensor. To do so, call readData()
Definition: Adafruit_CCS811.h:116
void disableInterrupt()
disable the data ready interrupt pin on the device
Definition: Adafruit_CCS811.cpp:79
uint16_t getBaseline()
get the current baseline from the sensor.
Definition: Adafruit_CCS811.cpp:163
uint16_t geteCO2()
returns the stored estimated carbon dioxide measurement. This does does not read the sensor...
Definition: Adafruit_CCS811.h:107
bool begin(uint8_t addr=CCS811_ADDRESS, TwoWire *theWire=&Wire)
Setups the I2C interface and hardware and checks for communication.
Definition: Adafruit_CCS811.cpp:17
uint8_t readData()
read and store the sensor data. This data can be accessed with getTVOC(), geteCO2(), getCurrentSelected() and getRawADCreading()
Definition: Adafruit_CCS811.cpp:105
void setThresholds(uint16_t low_med, uint16_t med_high, uint8_t hysteresis=50)
set interrupt thresholds
Definition: Adafruit_CCS811.cpp:225
uint16_t getTVOC()
returns the stored total volatile organic compounds measurement. This does does not read the sensor...
Definition: Adafruit_CCS811.h:98
double calculateTemperature()
calculate the temperature using the onboard NTC resistor.
Definition: Adafruit_CCS811.cpp:198
bool available()
checks if data is available to be read.
Definition: Adafruit_CCS811.cpp:90