Adafruit CCS811 Arduino Library
Classes | Public Member Functions | List of all members
Adafruit_CCS811 Class Reference

Class that stores state and functions for interacting with CCS811 gas sensor chips. More...

#include <Adafruit_CCS811.h>

Public Member Functions

bool begin (uint8_t addr=CCS811_ADDRESS)
 Setups the I2C interface and hardware and checks for communication. More...
 
void setEnvironmentalData (uint8_t humidity, double temperature)
 set the humidity and temperature compensation for the sensor. More...
 
double calculateTemperature ()
 calculate the temperature using the onboard NTC resistor. More...
 
void setThresholds (uint16_t low_med, uint16_t med_high, uint8_t hysteresis=50)
 set interrupt thresholds More...
 
void SWReset ()
 trigger a software reset of the device
 
void setDriveMode (uint8_t mode)
 sample rate of the sensor. More...
 
void enableInterrupt ()
 enable the data ready interrupt pin on the device.
 
void disableInterrupt ()
 disable the data ready interrupt pin on the device
 
uint16_t getTVOC ()
 returns the stored total volatile organic compounds measurement. This does does not read the sensor. To do so, call readData() More...
 
uint16_t geteCO2 ()
 returns the stored estimated carbon dioxide measurement. This does does not read the sensor. To do so, call readData() More...
 
void setTempOffset (float offset)
 set the temperature compensation offset for the device. This is needed to offset errors in NTC measurements. More...
 
bool available ()
 checks if data is available to be read. More...
 
uint8_t readData ()
 read and store the sensor data. This data can be accessed with getTVOC() and geteCO2() More...
 
bool checkError ()
 read the status register and store any errors. More...
 

Detailed Description

Class that stores state and functions for interacting with CCS811 gas sensor chips.

Member Function Documentation

◆ begin()

bool Adafruit_CCS811::begin ( uint8_t  addr = CCS811_ADDRESS)

Setups the I2C interface and hardware and checks for communication.

Parameters
addrOptional I2C address the sensor can be found on. Default is 0x5A
Returns
True if device is set up, false on any failure

◆ setEnvironmentalData()

void Adafruit_CCS811::setEnvironmentalData ( uint8_t  humidity,
double  temperature 
)

set the humidity and temperature compensation for the sensor.

Parameters
humiditythe humidity data as a percentage. For 55% humidity, pass in integer 55.
temperaturethe temperature in degrees C as a decimal number. For 25.5 degrees C, pass in 25.5

◆ calculateTemperature()

double Adafruit_CCS811::calculateTemperature ( )

calculate the temperature using the onboard NTC resistor.

Returns
temperature as a double.

◆ setThresholds()

void Adafruit_CCS811::setThresholds ( uint16_t  low_med,
uint16_t  med_high,
uint8_t  hysteresis = 50 
)

set interrupt thresholds

Parameters
low_medthe level below which an interrupt will be triggered.
med_highthe level above which the interrupt will ge triggered.
hysteresisoptional histeresis level. Defaults to 50

◆ setDriveMode()

void Adafruit_CCS811::setDriveMode ( uint8_t  mode)

sample rate of the sensor.

Parameters
modeone of CCS811_DRIVE_MODE_IDLE, CCS811_DRIVE_MODE_1SEC, CCS811_DRIVE_MODE_10SEC, CCS811_DRIVE_MODE_60SEC, CCS811_DRIVE_MODE_250MS.

◆ getTVOC()

uint16_t Adafruit_CCS811::getTVOC ( )
inline

returns the stored total volatile organic compounds measurement. This does does not read the sensor. To do so, call readData()

Returns
TVOC measurement as 16 bit integer

◆ geteCO2()

uint16_t Adafruit_CCS811::geteCO2 ( )
inline

returns the stored estimated carbon dioxide measurement. This does does not read the sensor. To do so, call readData()

Returns
eCO2 measurement as 16 bit integer

◆ setTempOffset()

void Adafruit_CCS811::setTempOffset ( float  offset)
inline

set the temperature compensation offset for the device. This is needed to offset errors in NTC measurements.

Parameters
offsetthe offset to be added to temperature measurements.

◆ available()

bool Adafruit_CCS811::available ( )

checks if data is available to be read.

Returns
True if data is ready, false otherwise.

◆ readData()

uint8_t Adafruit_CCS811::readData ( )

read and store the sensor data. This data can be accessed with getTVOC() and geteCO2()

Returns
0 if no error, error code otherwise.

◆ checkError()

bool Adafruit_CCS811::checkError ( )

read the status register and store any errors.

Returns
the error bits from the status register of the device.

The documentation for this class was generated from the following files: