Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ on:
jobs:
build_and_deploy:
uses: sensirion/.github/.github/workflows/driver.python.pypi_publish.yml@main
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

secrets: inherit
2 changes: 2 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ on:
jobs:
documentation:
uses: sensirion/.github/.github/workflows/driver.python.documentation.yml@main
with:
use-project-requirements: true
11 changes: 11 additions & 0 deletions .github/workflows/gh_workflow_metadata_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Driver Index Metadata Update

on:
push:
branches:
- main

jobs:
driver-index-metadata-update:
uses: sensirion/.github/.github/workflows/driver.common.di_metadata_update.yml@main
secrets: inherit
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ on:
- main

jobs:
dg-metadata-validation:
if: github.event_name == 'push' && github.ref != 'refs/head/main'
uses: sensirion/.github/.github/workflows/driver.generated.metadata_check.yml@main

test:
uses: sensirion/.github/.github/workflows/driver.python.test.yml@main
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2026-4-30

### Changed

- Updated busy-delay from 2ms to 1ms for `enter_sleep_mode` command.
- Add `check_self_test` to examples.
## [1.0.0] - 2025-6-20

### Added

- Initial support for STCC4.

[Unreleased]: https://github.com/Sensirion/python-i2c-stcc4/compare/1.0.0...HEAD
[Unreleased]: https://github.com/Sensirion/python-i2c-stcc4/compare/1.1.0...HEAD
[1.1.0]: https://github.com/Sensirion/python-i2c-stcc4/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/Sensirion/python-i2c-stcc4/releases/tag/1.0.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2025, Sensirion AG
Copyright (c) 2026, Sensirion AG
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ This repository contains the Python driver to communicate with a Sensirion STCC4
Click [here](https://sensirion.com/products/catalog/STCC4) to learn more about the Sensirion STCC4 sensor.


The STCC4 is Sensirion's next generation miniature CO2 sensor for indoor air quality applications.



The default I²C address of [STCC4](https://sensirion.com/products/catalog/STCC4) is **0x64**.

> [!NOTE]
> The SEK-STCC4 board from Sensirion includes a STCC4 and a SHT4x for temperature and humidity compensation, which is controlled by the STCC4 through the integrated I2C controller interface. The provided examples are designed considering this sensor configuration.


## Connect the sensor

Expand Down
11 changes: 6 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html


import os
import sys
from datetime import datetime

import pkg_resources
import importlib.metadata as metadata
import sphinx.ext.autodoc

import sensirion_i2c_stcc4
Expand All @@ -17,16 +18,16 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

# -- Project information -----------------------------------------------------
distribution = pkg_resources.get_distribution('sensirion_i2c_stcc4')
distribution = metadata.distribution("sensirion_i2c_stcc4")

project = u'sensirion_i2c_stcc4'
project = distribution.name
copyright = u'{} Sensirion AG, Switzerland'.format(datetime.now().year)
author = 'Sensirion AG'

# The short X.Y version
version = sensirion_i2c_stcc4.__version__
version = distribution.version
# The full version, including alpha/beta/rc tags
release = sensirion_i2c_stcc4.__version__
release = distribution.version

# -- General configuration ---------------------------------------------------

Expand Down
39 changes: 20 additions & 19 deletions examples/example_usage_linux_stcc4.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
# (c) Copyright 2026 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.2.0
# Generator: sensirion-driver-generator 1.6.1
# Product: stcc4
# Model-Version: 3.4.0
# Model-Version: 3.5.0
#

import argparse
Expand All @@ -26,24 +26,25 @@
crc=CrcCalculator(8, 0x31, 0xff, 0x0))
sensor = Stcc4Device(channel)
sensor.stop_continuous_measurement()
(product_id, serial_number) = sensor.get_product_id()
print(f"product_id: {product_id}; serial_number: {serial_number}; ")
(product_id, serial_number
) = sensor.get_product_id()
print(f"product_id: {product_id}; "
f"serial_number: {serial_number}; "
)
test_result = sensor.check_self_test()
print(f"test_result: {test_result}; "
)
sensor.start_continuous_measurement()
for i in range(50):
time.sleep(1.0)
try:
(co2_concentration, temperature, relative_humidity, sensor_status) = sensor.read_measurement()
time.sleep(1.0)
(co2_concentration, temperature, relative_humidity, sensor_status
) = sensor.read_measurement()
print(f"co2_concentration: {co2_concentration}; "
f"temperature: {temperature}; "
f"relative_humidity: {relative_humidity}; "
f"sensor_status: {sensor_status}; "
)
except BaseException:
# Read can fail in case of clock shift, datasheet suggests to retry after 150ms
time.sleep(0.15)
try:
(co2_concentration, temperature, relative_humidity, sensor_status) = sensor.read_measurement()
except BaseException:
continue

print(f"co2_concentration: {co2_concentration}; "
f"temperature: {temperature}; "
f"relative_humidity: {relative_humidity}; "
f"sensor_status: {sensor_status}; ")

continue
sensor.stop_continuous_measurement()
31 changes: 15 additions & 16 deletions examples/example_usage_sensorbridge_stcc4.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
# (c) Copyright 2026 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.2.0
# Generator: sensirion-driver-generator 1.6.1
# Product: stcc4
# Model-Version: 3.4.0
# Model-Version: 3.5.0
#

import argparse
Expand Down Expand Up @@ -40,21 +40,20 @@
print(f"product_id: {product_id}; "
f"serial_number: {serial_number}; "
)
test_result = sensor.check_self_test()
print(f"test_result: {test_result}; "
)
sensor.start_continuous_measurement()
for i in range(50):
time.sleep(1.0)
try:
(co2_concentration, temperature, relative_humidity, sensor_status) = sensor.read_measurement()
time.sleep(1.0)
(co2_concentration, temperature, relative_humidity, sensor_status
) = sensor.read_measurement()
print(f"co2_concentration: {co2_concentration}; "
f"temperature: {temperature}; "
f"relative_humidity: {relative_humidity}; "
f"sensor_status: {sensor_status}; "
)
except BaseException:
# Read can fail in case of clock shift, datasheet suggests to retry after 150ms
time.sleep(0.15)
try:
(co2_concentration, temperature, relative_humidity, sensor_status) = sensor.read_measurement()
except BaseException:
continue
print(f"co2_concentration: {co2_concentration}; "
f"temperature: {temperature}; "
f"relative_humidity: {relative_humidity}; "
f"sensor_status: {sensor_status}; "
)
continue
sensor.stop_continuous_measurement()
12 changes: 9 additions & 3 deletions examples/example_usage_single_shot_linux_stcc4.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
# (c) Copyright 2026 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.2.0
# Generator: sensirion-driver-generator 1.6.1
# Product: stcc4
# Model-Version: 3.4.0
# Model-Version: 3.5.0
#

import argparse
Expand All @@ -31,6 +31,12 @@
sensor.exit_sleep_mode()
sensor.stop_continuous_measurement()

# Perform self-test
self_test_result = sensor.check_self_test()
if not self_test_result:
print("Self-test failed!"
)

# Enter sleep mode
sensor.enter_sleep_mode()
for i in range(100):
Expand Down
12 changes: 9 additions & 3 deletions examples/example_usage_single_shot_sensorbridge_stcc4.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
# (c) Copyright 2026 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.2.0
# Generator: sensirion-driver-generator 1.6.1
# Product: stcc4
# Model-Version: 3.4.0
# Model-Version: 3.5.0
#

import argparse
Expand Down Expand Up @@ -40,6 +40,12 @@
sensor.exit_sleep_mode()
sensor.stop_continuous_measurement()

# Perform self-test
self_test_result = sensor.check_self_test()
if not self_test_result:
print("Self-test failed!"
)

# Enter sleep mode
sensor.enter_sleep_mode()
for i in range(100):
Expand Down
8 changes: 4 additions & 4 deletions metadata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# driver generation metadata
generator_version: 1.2.0
model_version: 3.4.0
generator_version: 1.6.1
model_version: 3.5.0
dg_status: released
is_manually_modified: true
is_manually_modified: false
first_generated: '2025-02-24 11:47'
last_generated: '2025-06-20 08:02'
last_generated: '2026-04-30 11:42'
66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[build-system]
requires = ["hatchling >= 1.26", "wheel >= 0.45.0"]
build-backend = "hatchling.build"

[project]
name = "sensirion_i2c_stcc4"
description = "I2C driver for the Sensirion STCC4 sensor family"

readme = "README.md"
version = "1.1.0"
requires-python = ">=3.8,<4.0"

authors = [
{ name = "Sensirion", email = "info@sensirion.com" },
]

license = "BSD-3-Clause"
license-files = ["LICENSE"]

keywords = [
"Sensirion STCC4",
"I2C",
"STCC4",
]

classifiers = [
"Intended Audience :: Developers",
"Topic :: System :: Hardware :: Hardware Drivers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

dependencies = [
"sensirion-driver-adapters>=2.3.0,<3.0",
"sensirion-driver-support-types>=1.2.0,<2.0",
"sensirion-i2c-driver>=1.0,<2.0",
"sensirion-shdlc-sensorbridge>=0.1.0,<2.0"
]

[project.optional-dependencies]

docs=[
"jinja2~=3.1.6",
"sphinx-rtd-theme==3.0.2",
"sphinx==8.2.3",
"lazy-object-proxy ~=1.7.1",
"sphinx-autoapi~=3.0.0",
]

test= [
"flake8>=7.1.0",
"mock~=5.2.0",
"pytest>=8.3.5",
"pytest-cov>=5.0.0",
"mypy~=1.13.0",
"setuptools>=73.2.0"
]

[project.urls]
Changelog = "https://github.com/Sensirion/python-i2c-stcc4/blob/master/CHANGELOG.md"
Repository = "https://github.com/Sensirion/python-i2c-stcc4"
Documentation = "https://sensirion.github.io/python-i2c-stcc4"

6 changes: 3 additions & 3 deletions sensirion_i2c_stcc4/commands.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
# (c) Copyright 2026 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.2.0
# Generator: sensirion-driver-generator 1.6.1
# Product: stcc4
# Model-Version: 3.4.0
# Model-Version: 3.5.0
#
"""
The transfer classes specify the data that is transferred between host and sensor. The generated transfer classes
Expand Down
Loading
Loading