Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ccs811.h File Reference

Extended public API for CCS811 Indoor Air Quality Sensor. More...

Go to the source code of this file.

Data Structures

struct  ccs811_result_type
 Information collected from the sensor on each fetch. More...
 
struct  ccs811_configver_type
 Get information about static CCS811 state. More...
 

Macros

#define CCS811_STATUS_ERROR   BIT(0)
 
#define CCS811_STATUS_DATA_READY   BIT(3)
 
#define CCS811_STATUS_APP_VALID   BIT(4)
 
#define CCS811_STATUS_FW_MODE   BIT(7)
 
#define CCS811_ERROR_WRITE_REG_INVALID   BIT(0)
 
#define CCS811_ERROR_READ_REG_INVALID   BIT(1)
 
#define CCS811_ERROR_MEASMODE_INVALID   BIT(2)
 
#define CCS811_ERROR_MAX_RESISTANCE   BIT(3)
 
#define CCS811_ERROR_HEATER_FAULT   BIT(4)
 
#define CCS811_ERROR_HEATER_SUPPLY   BIT(5)
 
#define CCS811_MODE_IDLE   0x00
 
#define CCS811_MODE_IAQ_1SEC   0x10
 
#define CCS811_MODE_IAQ_10SEC   0x20
 
#define CCS811_MODE_IAQ_60SEC   0x30
 
#define CCS811_MODE_IAQ_250MSEC   0x40
 
#define CCS811_MODE_MSK   0x70
 

Functions

const struct ccs811_result_typeccs811_result (const struct device *dev)
 Access storage for the most recent data read from the sensor.
 
int ccs811_configver_fetch (const struct device *dev, struct ccs811_configver_type *ptr)
 Fetch operating mode and version information.
 
int ccs811_baseline_fetch (const struct device *dev)
 Fetch the current value of the BASELINE register.
 
int ccs811_baseline_update (const struct device *dev, uint16_t baseline)
 Update the BASELINE register.
 
int ccs811_envdata_update (const struct device *dev, const struct sensor_value *temperature, const struct sensor_value *humidity)
 Update the ENV_DATA register.
 

Detailed Description

Extended public API for CCS811 Indoor Air Quality Sensor.

Some capabilities and operational requirements for this sensor cannot be expressed within the sensor driver abstraction.

Macro Definition Documentation

◆ CCS811_ERROR_HEATER_FAULT

#define CCS811_ERROR_HEATER_FAULT   BIT(4)

◆ CCS811_ERROR_HEATER_SUPPLY

#define CCS811_ERROR_HEATER_SUPPLY   BIT(5)

◆ CCS811_ERROR_MAX_RESISTANCE

#define CCS811_ERROR_MAX_RESISTANCE   BIT(3)

◆ CCS811_ERROR_MEASMODE_INVALID

#define CCS811_ERROR_MEASMODE_INVALID   BIT(2)

◆ CCS811_ERROR_READ_REG_INVALID

#define CCS811_ERROR_READ_REG_INVALID   BIT(1)

◆ CCS811_ERROR_WRITE_REG_INVALID

#define CCS811_ERROR_WRITE_REG_INVALID   BIT(0)

◆ CCS811_MODE_IAQ_10SEC

#define CCS811_MODE_IAQ_10SEC   0x20

◆ CCS811_MODE_IAQ_1SEC

#define CCS811_MODE_IAQ_1SEC   0x10

◆ CCS811_MODE_IAQ_250MSEC

#define CCS811_MODE_IAQ_250MSEC   0x40

◆ CCS811_MODE_IAQ_60SEC

#define CCS811_MODE_IAQ_60SEC   0x30

◆ CCS811_MODE_IDLE

#define CCS811_MODE_IDLE   0x00

◆ CCS811_MODE_MSK

#define CCS811_MODE_MSK   0x70

◆ CCS811_STATUS_APP_VALID

#define CCS811_STATUS_APP_VALID   BIT(4)

◆ CCS811_STATUS_DATA_READY

#define CCS811_STATUS_DATA_READY   BIT(3)

◆ CCS811_STATUS_ERROR

#define CCS811_STATUS_ERROR   BIT(0)

◆ CCS811_STATUS_FW_MODE

#define CCS811_STATUS_FW_MODE   BIT(7)

Function Documentation

◆ ccs811_baseline_fetch()

int ccs811_baseline_fetch ( const struct device * dev)

Fetch the current value of the BASELINE register.

The BASELINE register encodes data used to correct sensor readings based on individual device configuration and variation over time.

For proper management of the BASELINE register see AN000370 "Baseline Save and Restore on CCS811".

Parameters
devPointer to the sensor device
Returns
a non-negative 16-bit register value, or a negative errno code on failure.

◆ ccs811_baseline_update()

int ccs811_baseline_update ( const struct device * dev,
uint16_t baseline )

Update the BASELINE register.

For proper management of the BASELINE register see AN000370 "Baseline Save and Restore on CCS811".

Parameters
devPointer to the sensor device
baselinethe value to be stored in the BASELINE register.
Returns
0 if successful, negative errno code if failure.

◆ ccs811_configver_fetch()

int ccs811_configver_fetch ( const struct device * dev,
struct ccs811_configver_type * ptr )

Fetch operating mode and version information.

Parameters
devPointer to the sensor device
ptrPointer to where the returned information should be stored
Returns
0 on success, or a negative errno code on failure.

◆ ccs811_envdata_update()

int ccs811_envdata_update ( const struct device * dev,
const struct sensor_value * temperature,
const struct sensor_value * humidity )

Update the ENV_DATA register.

Accurate calculation of gas levels requires accurate environment data. Measurements are only accurate to 0.5 Cel and 0.5 RH.

Parameters
devPointer to the sensor device
temperaturethe current temperature at the sensor
humiditythe current humidity at the sensor
Returns
0 if successful, negative errno code if failure.

◆ ccs811_result()

const struct ccs811_result_type * ccs811_result ( const struct device * dev)

Access storage for the most recent data read from the sensor.

This content of the object referenced is updated by sensor_fetch_sample(), except for ccs811_result_type::mode which is set on driver initialization.

Parameters
devPointer to the sensor device
Returns
a pointer to the result information.