Simple test
Ensure your device works with this simple test.
examples/sgp40_simpletest.py
1# SPDX-FileCopyrightText: 2020 by Bryan Siepert for Adafruit Industries
2#
3# SPDX-License-Identifier: Unlicense
4import time
5
6import board
7
8import adafruit_sgp40
9
10# If you have a temperature sensor, like the bme280, import that here as well
11# import adafruit_bme280
12
13i2c = board.I2C() # uses board.SCL and board.SDA
14# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
15sgp = adafruit_sgp40.SGP40(i2c)
16# And if you have a temp/humidity sensor, define the sensor here as well
17# bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
18
19while True:
20 print("Raw Gas: ", sgp.raw)
21 # Lets quickly grab the humidity and temperature
22 # temperature = bme280.temperature
23 # humidity = bme280.relative_humidity
24 # compensated_raw_gas = sgp.measure_raw(temperature = temperature, relative_humidity = humidity)
25 print("")
26 time.sleep(1)