A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.circuitpython.org/projects/ccs811/en/latest/examples.html below:

Website Navigation


Simple test — Adafruit's CCS811 Library 1.0 documentation

Simple test

Ensure your device works with this simple test.

examples/ccs811_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5
 6import board
 7
 8import adafruit_ccs811
 9
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12ccs811 = adafruit_ccs811.CCS811(i2c)
13
14# Wait for the sensor to be ready
15while not ccs811.data_ready:
16    pass
17
18while True:
19    print(f"CO2: {ccs811.eco2} PPM, TVOC: {ccs811.tvoc} PPB")
20    time.sleep(0.5)
DisplayIO Simpletest

This is a simple test for boards with built-in display.

examples/ccs811_displayio_simpletest.py
 1# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
 2# SPDX-FileCopyrightText: 2024 Jose D. Montoya
 3#
 4# SPDX-License-Identifier: MIT
 5
 6import time
 7
 8import board
 9from adafruit_display_text.bitmap_label import Label
10from displayio import Group
11from terminalio import FONT
12
13import adafruit_ccs811
14
15# Simple demo of using the built-in display.
16# create a main_group to hold anything we want to show on the display.
17main_group = Group()
18# Initialize I2C bus and sensor.
19i2c = board.I2C()  # uses board.SCL and board.SDA
20ccs811 = adafruit_ccs811.CCS811(i2c)
21
22# Wait for the sensor to be ready
23while not ccs811.data_ready:
24    pass
25
26# Create Label(s) to show the readings. If you have a very small
27# display you may need to change to scale=1.
28display_output_label = Label(FONT, text="", scale=2)
29
30# place the label(s) in the middle of the screen with anchored positioning
31display_output_label.anchor_point = (0, 0)
32display_output_label.anchored_position = (
33    4,
34    board.DISPLAY.height // 2 - 60,
35)
36
37# add the label(s) to the main_group
38main_group.append(display_output_label)
39
40# set the main_group as the root_group of the built-in DISPLAY
41board.DISPLAY.root_group = main_group
42
43# begin main loop
44while True:
45    # update the text of the label(s) to show the sensor readings
46    display_output_label.text = f"CO2: {ccs811.eco2} PPM\nTVOC: {ccs811.tvoc} PPB"
47    # wait for a bit
48    time.sleep(0.5)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4