API Reference

qwiic_sgp40

Python module for the SparkFun Air Quality Sensor - SGP40 (Qwiic).

This package is a port of the existing [SparkFun SGP40 Arduino Library](https://github.com/sparkfun/SparkFun_SGP40_Arduino_Library) and is heavily based on the driver written by [DFRobot](https://github.com/DFRobot/DFRobot_SGP40/tree/master/Python/raspberrypi).

This package can be used in conjunction with the overall [SparkFun Qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)

New to qwiic? Take a look at the entire [SparkFun Qwiic Ecosystem](https://www.sparkfun.com/qwiic).

class qwiic_sgp40.QwiicSGP40(address=None, i2c_driver=None)[source]
Parameters
  • address – The I2C address to use for the device. If not provided, the default address is used.

  • i2c_driver – An existing i2c driver object. If not provided a a driver object is created.

Returns

The GPIO device object.

Return type

Object

begin(warm_up_time=10)[source]

Initialize the operation of the Qwiic SGP40 and wait through warm- up time. Run is_connected() and measure_test().

Returns

Returns true if the intialization was successful, false otherwise.

Return type

bool

get_VOC_index(_QwiicSGP40__relative_humidity=50, _QwiicSGP40__temperature_c=25)[source]

Get VOC index

Parameters
  • __relative_humidity – float relative humidity between 0 and 100%.

  • __temperature_c – float temperature in celcius between -45 and 130 degrees.

Returns

VOC index

Return type

int

heater_off()[source]

Turns the hotplate off and puts sensor in idle mode.

Return type

void - returns nothing

is_connected()[source]

Determine if a Qwiic SGP40 device is connected to the system.

Returns

True if the device is connected, false otherwise.

Return type

bool

measure_raw(_QwiicSGP40__relative_humidity=50, _QwiicSGP40__temperature_c=25)[source]

Returns the raw data. See the SGP40 datasheet for more info.

Parameters
  • SRAW_ticks – variable to assign raw measurement to

  • __relative_humidity – float relative humidity between 0 and 100%.

  • __temperature_c – float temperature in celcius between -45 and 130 degrees.

Returns

0 if CRC checks out, -1 otherwise

Return type

int

measure_test()[source]

Sensor runs chip self test.

Returns

Returns 0 if the self-test succeeded and 1 if it failed.

Return type

int

soft_reset()[source]

Sensor reset

Return type

void - returns nothing