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, TwoWire *theWire=&Wire)
 Setups the I2C interface and hardware and checks for communication. More...
 
void setEnvironmentalData (float humidity, float temperature)
 set the humidity and temperature compensation for the sensor. More...
 
uint16_t getBaseline ()
 get the current baseline from the sensor. More...
 
void setBaseline (uint16_t baseline)
 set the baseline 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...
 
uint16_t getCurrentSelected ()
 returns the "Current Selected" in uA. This does does not read the sensor. To do so, call readData() More...
 
uint16_t getRawADCreading ()
 returns the raw ADC reading. 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(), geteCO2(), getCurrentSelected() and getRawADCreading() 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,
TwoWire *  theWire = &Wire 
)

Setups the I2C interface and hardware and checks for communication.

Parameters
addrOptional I2C address the sensor can be found on. Default is 0x5A
theWireOptional pointer to I2C interface, &Wire is used by default
Returns
True if device is set up, false on any failure

◆ setEnvironmentalData()

void Adafruit_CCS811::setEnvironmentalData ( float  humidity,
float  temperature 
)

set the humidity and temperature compensation for the sensor.

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

◆ getBaseline()

uint16_t Adafruit_CCS811::getBaseline ( )

get the current baseline from the sensor.

Returns
the baseline as 16 bit integer. This value is not human readable.

◆ setBaseline()

void Adafruit_CCS811::setBaseline ( uint16_t  baseline)

set the baseline for the sensor.

Parameters
baselinethe baseline to be set. Has to be a value retrieved by getBaseline().

◆ calculateTemperature()

double Adafruit_CCS811::calculateTemperature ( )

calculate the temperature using the onboard NTC resistor.

Deprecated:
hardware support removed by vendor
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

◆ getCurrentSelected()

uint16_t Adafruit_CCS811::getCurrentSelected ( )
inline

returns the "Current Selected" in uA. This does does not read the sensor. To do so, call readData()

Returns
"Current Selected" in uA as 16 bit integer

◆ getRawADCreading()

uint16_t Adafruit_CCS811::getRawADCreading ( )
inline

returns the raw ADC reading. This does does not read the sensor. To do so, call readData()

Returns
raw ADC reading 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(), geteCO2(), getCurrentSelected() and getRawADCreading()

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: