Skip to main content

sgp30-driver

Easy-to-use python driver for the Sensirion SGP30 multi gas sensor

GitHub Workflow Status PyPI PyPI - License PyPI - Downloads

Installation

The package is available on PyPI. Installation is can be done with your favourite package manager. For example:

pip install sgp30-driver

Usage

In order to initialise the device we need an open SMBus object. Depending on the machine that you are running on you may need to provide another bus number or path:

from sgp30 import SGP30
from smbus2 import SMBus


with SMBus(1) as bus:
    device = SGP30(bus=bus)

The address of the SGP30 defaults to 0x58. This is the (fixed) address of the SGP30 devices, so you should never have to change it. If you do want to change it, you can provide it like SGP30(bus=bus, address=0x59).

Initialisation

After every restart the SGP30 has to be initialised:

device.initialise()

This process can take up to 20 seconds.

This process can be sped up by passing recent values of the baseline compensation algorithm: store the result of device.baseline somewhere in non-volatile memory, and restore it with:

device.initialise(baseline)

Measuring

After initialisation the device is ready for taking measurements. The measure() method returns an SGP30Measurement object which has two attributes: equivalent_co2 which represents the CO2 concentration in ppm (parts-per-million) and tvoc which represents the TVOC (total volatile organic compounds) in ppb (parts-per-billion).

measurement = device.measure()
print(f"{measurement.equivalent_co2} ppm CO2, {measurement.tvoc} ppb TVOC")

In order to ensure the proper working of the baseline compensation algorithm one should call the measure() method in regular intervals of 1 second.

Humidity compensation

The SGP30 has on-chip humidity compensation. In order to enable the compensation, you will need to get a humidity measurement from another sensor, and then set the humidity using set_humidity():

device.set_humidity(15.2)

The accepted humidity value is the absolute humidity in g/m3.

Alternatively, if only the relative humidity is available:

device.set_relative_humidity(
    humidity=0.5,  # 50 %RH
    temperature=20,  # 20°C
)

Release files for sgp30-driver 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sgp30-driver 0.2.2
File Size Uploaded
sgp30-driver-0.2.2.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sgp30-driver 0.2.2
File Interpreter ABI Platform
sgp30_driver-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / sgp30-driver-0.2.2.tar.gz

Download URL sgp30-driver-0.2.2.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7becd5b1d43c3f2a02cd5b74e15693d24505dfacd1970c4bb5f5de65c4304677
BLAKE2b-256 checksum
How to use checksums
28589fffcdad5c88335fbd888e72acc59cbbf0283972d99f32b1afb0085d421e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / sgp30_driver-0.2.2-py3-none-any.whl

Download URL sgp30_driver-0.2.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02b50048d4ac8de8ef3006372aadcf468f4cae1fa90a2242e7a3a7742f5ed422
BLAKE2b-256 checksum
How to use checksums
bbdac451a1d633adcd1e3bd8395e5f31e90837ad88ab43fae5d33368a066b8f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page