Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: Copyright (c) 2022 ladyada for Adafruit Industries
2#
3# SPDX-License-Identifier: Unlicense
4
5import time
6import board
7import adafruit_ens160
8
9i2c = board.I2C() # uses board.SCL and board.SDA
10# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
11
12ens = adafruit_ens160.ENS160(i2c)
13
14# Set the temperature compensation variable to the ambient temp
15# for best sensor calibration
16ens.temperature_compensation = 25
17# Same for ambient relative humidity
18ens.humidity_compensation = 50
19
20
21while True:
22 print("AQI (1-5):", ens.AQI)
23 print("TVOC (ppb):", ens.TVOC)
24 print("eCO2 (ppm):", ens.eCO2)
25 print()
26
27 # new data shows up every second or so
28 time.sleep(1)