ens160

package
v0.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package ens160 provides a driver for the ScioSense ENS160 digital gas sensor.

Datasheet: https://www.sciosense.com/wp-content/uploads/2023/12/ENS160-Datasheet.pdf

Index

Constants

View Source
const (
	ModeDeepSleep = 0x00
	ModeIdle      = 0x01
	ModeStandard  = 0x02
	ModeReset     = 0xF0
)

Operating modes

View Source
const (
	ValidityNormalOperation     = 0x00
	ValidityWarmUpPhase         = 0x01 // need ~3 minutes until valid data
	ValidityInitialStartUpPhase = 0x02 // need ~1 hour until valid data
	ValidityInvalidOutput       = 0x03
)

Validity flags

View Source
const (
	LowPartID  = 0x60
	HighPartID = 0x01
)

Part IDs

View Source
const DefaultAddress = 0x53

DefaultAddress is the default I2C address for the ENS160 when the ADDR pin is connected to high (3.3V). When connected to low (GND), the address is 0x52.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device wraps an I2C connection to an ENS160 device.

func New

func New(bus drivers.I2C, addr uint16) *Device

New returns a new ENS160 driver.

func (*Device) AQI

func (d *Device) AQI() uint8

AQI returns the last Air‑Quality Index according to UBA (1–5).

func (*Device) Configure

func (d *Device) Configure() error

Configure sets up the device for reading.

func (*Device) Connected

func (d *Device) Connected() bool

Connected returns whether a ENS160 has been found.

func (*Device) ECO2

func (d *Device) ECO2() uint16

ECO2 returns the last equivalent CO₂ concentration in parts‑per‑million.

func (*Device) SetEnvDataMilli

func (d *Device) SetEnvDataMilli(tempMilliC, rhMilliPct int32) error

SetEnvDataMilli sets the ambient temperature and humidity for compensation.

tempMilliC is the temperature in milli-degrees Celsius. rhMilliPct is the relative humidity in milli-percent.

func (*Device) TVOC

func (d *Device) TVOC() uint16

TVOC returns the last total‑VOC concentration in parts‑per‑billion.

func (*Device) Update

func (d *Device) Update(which drivers.Measurement) error

Update refreshes the concentration measurements.

func (*Device) Validity

func (d *Device) Validity() uint8

Validity returns the current operating state of the sensor.

func (*Device) ValidityString

func (d *Device) ValidityString() string

ValidityString returns a human-readable string describing the current validity status.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL