Simple test

Ensure your device works with this simple test.

examples/sgp41_simpletest.py
 1# SPDX-FileCopyrightText: 2026 Liz Clark for Adafruit Industries
 2#
 3# SPDX-License-Identifier: MIT
 4
 5"""Simple test for the SGP41 sensor"""
 6
 7import time
 8
 9import board
10
11from adafruit_sgp41.sgp41 import SGP41
12
13i2c = board.I2C()
14sensor = SGP41(i2c)
15
16# set ambient temperature and relative humidity
17# for more accurate readings from the sensor
18# can be used in conjunction with an external
19# temp and humidity sensor
20# sensor.temperature = 22.2 # Celsius
21# sensor.relative_humidity = 30.9
22
23for i in range(10):
24    condition = sensor.conditioning()
25    print(f"Conditioning the sensor, {(i + 1)} of 10 times: {condition}")
26    time.sleep(1)
27
28print("Sensor ready! Starting the loop..")
29print()
30
31while True:
32    print(f"Raw VOC: {sensor.raw_voc}")
33    print(f"Raw NOx: {sensor.raw_nox}")
34    print()
35    time.sleep(1)