Adafruit SGP-40 Library
Public Member Functions | Public Attributes | List of all members
Adafruit_SGP40 Class Reference

Class that stores state and functions for interacting with SGP40 Gas Sensor. More...

#include <Adafruit_SGP40.h>

Public Member Functions

 Adafruit_SGP40 ()
 Instantiates a new SGP40 class.
 
bool begin (TwoWire *theWire=&Wire)
 Setups the hardware and detects a valid SGP40. Initializes I2C then reads the serialnumber and checks that we are talking to an SGP40. More...
 
bool selfTest (void)
 Request the sensor to perform a self-test, returning the result. More...
 
bool softReset ()
 Commands the sensor to perform a soft reset using the "General Call" mode. Take note that this is not sensor specific and all devices that support the General Call mode on the on the same I2C bus will perform this. More...
 
bool heaterOff ()
 Request the sensor to turn off heater to lower curent consumption. Launching a measurement automatically wakes up the sensor again. More...
 
uint16_t measureRaw (float temperature=25, float humidity=50)
 Return the raw gas measurement. More...
 
int32_t measureVocIndex (float temperature=25, float humidity=50)
 Combined the measured gasses, temperature, and humidity to calculate the VOC Index. More...
 

Public Attributes

uint16_t serialnumber [3]
 

Detailed Description

Class that stores state and functions for interacting with SGP40 Gas Sensor.

Member Function Documentation

◆ begin()

boolean Adafruit_SGP40::begin ( TwoWire *  theWire = &Wire)

Setups the hardware and detects a valid SGP40. Initializes I2C then reads the serialnumber and checks that we are talking to an SGP40.

Parameters
theWireOptional pointer to I2C interface, otherwise use Wire
Returns
True if SGP40 found on I2C, False if something went wrong!

◆ selfTest()

bool Adafruit_SGP40::selfTest ( void  )

Request the sensor to perform a self-test, returning the result.

Returns
true: success false:failure

◆ softReset()

boolean Adafruit_SGP40::softReset ( void  )

Commands the sensor to perform a soft reset using the "General Call" mode. Take note that this is not sensor specific and all devices that support the General Call mode on the on the same I2C bus will perform this.

Returns
True if command completed successfully, false if something went wrong!

◆ heaterOff()

bool Adafruit_SGP40::heaterOff ( void  )

Request the sensor to turn off heater to lower curent consumption. Launching a measurement automatically wakes up the sensor again.

Returns
true: success false: failure

◆ measureRaw()

uint16_t Adafruit_SGP40::measureRaw ( float  temperature = 25,
float  humidity = 50 
)

Return the raw gas measurement.

Parameters
temperatureThe measured temperature in degrees C
humidityThe measured relative humidity in % rH
Returns
uint16_t The current raw gas measurement

◆ measureVocIndex()

int32_t Adafruit_SGP40::measureVocIndex ( float  temperature = 25,
float  humidity = 50 
)

Combined the measured gasses, temperature, and humidity to calculate the VOC Index.

Parameters
temperatureThe measured temperature in degrees C
humidityThe measured relative humidity in % rH
Returns
int32_t The VOC Index

Member Data Documentation

◆ serialnumber

uint16_t Adafruit_SGP40::serialnumber[3]

The 48-bit serial number, this value is set when you call begin()


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