Skip to main content

ENS160 Air Quality Sensor driver

Project description

ENS160

ENS160 Python library.

Datasheet

This code was tested on a Raspberry Pi 5 at 100kHz I2C clock.

The I2C code is abstracted from the sensor handling and other communication methods could be added.

Tested with Python 3.12

Documentation

The detailed API documentation can be found here.

Install

pip install ens160

Example

See example.py

import sys
from time import sleep

from ens160 import Driver, OpModes

from ens160.i2c import SMBusRetryingI2C
dev = Driver(SMBusRetryingI2C(0x53, 1))

dev.init()
part_id = dev.get_part_id()
if part_id != Driver.PART_ID:
    print(f"Part not found, expected {Driver.PART_ID} got {part_id}.")
    sys.exit(-1)

print(f"Part Id {part_id}")
print(f"Firmware version {dev.get_fw_version()}")

dev.set_rh_compensation(55.0)
dev.set_temp_compensation_fahrenheit(72.5)

print(dev.get_device_status())

dev.set_operating_mode(OpModes.STANDARD)
print("Operating Mode: ", dev.get_operating_mode())

while True:
    status = dev.get_device_status()
    print(status)
    if status.new_data:
        print(
            f"AQI={dev.get_aqi()}, eCO2={dev.get_eco2()}ppm, TVOC={dev.get_tvoc()}ppb"
        )
    else:
        sleep(0.1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ens160-0.0.2.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

ens160-0.0.2-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page