pre-commit, clean up

This commit is contained in:
Liz 2025-05-27 17:36:56 -04:00
parent bf49a53856
commit a66e4d1aa0
6 changed files with 627 additions and 471 deletions

View file

@ -30,7 +30,6 @@ This driver depends on:
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
* `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
@ -94,8 +93,19 @@ Usage Example
.. code-block:: python
import time
import board
import adafruit_sen6x
i2c = board.I2C()
sensor = adafruit_sen6x.SEN66(i2c)
sensor.start_measurement()
time.sleep(2)
if sensor.data_ready:
data = sensor.all_measurements()
print(data)
time.sleep(2)
Documentation
=============
API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/sen6x/en/latest/>`_.

File diff suppressed because it is too large Load diff

View file

@ -25,14 +25,13 @@ extensions = [
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio", "busio"]
autodoc_mock_imports = ["digitalio", "busio"]
autodoc_preserve_defaults = True
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"BusDevice": ("https://docs.circuitpython.org/projects/busdevice/en/latest/", None),
"Register": ("https://docs.circuitpython.org/projects/register/en/latest/", None),
"CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
}

View file

@ -24,14 +24,12 @@ Table of Contents
.. toctree::
:caption: Tutorials
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
the toctree above for use later.
Learn Guide <https://learn.adafruit.com/adafruit-sen6x-breakout>
.. toctree::
:caption: Related Products
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
the toctree above for use later.
Adafruit SEN6x Breakout for Sensirion SEN66 - STEMMA QT / Qwiic <https://www.adafruit.com/product/6331>
.. toctree::
:caption: Other Links

View file

@ -4,7 +4,9 @@
# Example usage:
import time
import board
import adafruit_sen6x
# Initialize I2C
@ -22,8 +24,9 @@ status = sensor.device_status
print(f"Device {status}")
# Optional: Configure sensor before starting
# sensor.set_temperature_offset(offset=-2.0, slot=0) # Apply -2°C offset
# sensor.set_voc_algorithm_tuning(index_offset=100) # Adjust VOC baseline
# sensor.temperature_offset(offset=-2.0, slot=0) # Apply -2°C offset
# sensor.voc_algorithm_tuning(index_offset=100) # Adjust VOC baseline
# print(sensor.voc_algorithm) # Print VOC baseline
# CO2 configuration examples:
# sensor.co2_automatic_self_calibration = False # Disable ASC for greenhouses
@ -36,48 +39,39 @@ sensor.start_measurement()
# Wait for first measurement to be ready
print("Waiting for first measurement...")
time.sleep(2)
# Optional: Save VOC state periodically for power loss recovery
voc_state = None
state_save_time = time.monotonic()
print("-" * 40)
# Read data continuously
while True:
if sensor.data_ready:
try:
# Check for errors before reading
sensor.check_sensor_errors()
# Read all measurements
data = sensor.read_measurement()
data = sensor.all_measurements()
# Display values (None = sensor still initializing)
print(f"Temperature: {data['temperature']:.1f}°C" if data['temperature'] else "Temperature: initializing...")
print(f"Humidity: {data['humidity']:.1f}%" if data['humidity'] else "Humidity: initializing...")
print(f"PM2.5: {data['pm2_5']:.1f} µg/m³" if data['pm2_5'] else "PM2.5: initializing...")
print(f"VOC Index: {data['voc_index']:.1f}" if data['voc_index'] else "VOC Index: initializing...")
print(f"NOx Index: {data['nox_index']:.1f}" if data['nox_index'] else "NOx Index: initializing...")
print(f"CO2: {data['co2']} ppm" if data['co2'] else "CO2: initializing...")
# Save VOC state every 60 seconds
if time.monotonic() - state_save_time > 10:
voc_state = sensor.voc_algorithm_state
state_save_time = time.monotonic()
print("VOC state saved")
# Optional: Read number concentrations
# nc_data = sensor.read_number_concentration()
# print(f"PM0.5 count: {nc_data['nc_pm0_5']:.1f} #/cm³")
except RuntimeError as e:
print(f"Error: {e}")
# Get detailed error information
errors = sensor.error_status_description
for error_type, description in errors.items():
print(f" - {error_type}: {description}")
# Optionally clear errors and try again
# sensor.clear_device_status()
print(
f"Temperature: {data["temperature"]:.1f}°C"
if data["temperature"]
else "Temperature: initializing..."
)
print(
f"Humidity: {data["humidity"]:.1f}%"
if data["humidity"]
else "Humidity: initializing..."
)
print(f"PM2.5: {data["pm2_5"]:.1f} µg/m³" if data["pm2_5"] else "PM2.5: initializing...")
print(
f"VOC Index: {data["voc_index"]:.1f}"
if data["voc_index"]
else "VOC Index: initializing..."
)
print(
f"NOx Index: {data["nox_index"]:.1f}"
if data["nox_index"]
else "NOx Index: initializing..."
)
print(f"CO2: {data["co2"]} ppm" if data["co2"] else "CO2: initializing...")
print("-" * 40)
time.sleep(1)
time.sleep(2)

View file

@ -5,4 +5,3 @@
Adafruit-Blinka
adafruit-circuitpython-busdevice
adafruit-circuitpython-register