asairaht10

package module
v0.0.0-...-aeac5b7 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 10 Imported by: 0

README

go-sensors/asairaht10

Go library for interacting with the ASAIR AHT10 and AHT20 temperature and relative humidity sensors.

Quickstart

Take a look at rpi-sensor-exporter for an example implementation that makes use of this sensor (and others).

Sensor Details

The ASAIR AHT10 and AHT20 temperature and relative humidity sensors are used for temperature and relative humidity, per vendor specifications. This go-sensors implementation makes use of the sensor's I2C-based protocol for obtaining measurements on an interval defined by the vendor.

Building

This software doesn't have any compiled assets.

Code of Conduct

We are committed to fostering an open and welcoming environment. Please read our code of conduct before participating in or contributing to this project.

Contributing

We welcome contributions and collaboration on this project. Please read our contributor's guide to understand how best to work with us.

License and Authors

Daniel James logo Daniel James

license GitHub contributors

This software is made available by Daniel James under the MIT license.

Documentation

Overview

This package provides an implementation to read temperature and relative humidity measurements from an Asair AHT10 or AHT20 sensor.

This implementation is based on the Adafruit AHT20 CircuitPython implementation: https://github.com/adafruit/Adafruit_CircuitPython_AHTx0

Index

Constants

View Source
const (
	DefaultReconnectTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func GetDefaultI2CPortConfig

func GetDefaultI2CPortConfig() *i2c.I2CPortConfig

GetDefaultI2CPortConfig gets the manufacturer-specified defaults for connecting to the sensor

Types

type Option

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

Option is a configured option that may be applied to a Sensor

func WithReconnectTimeout

func WithReconnectTimeout(timeout time.Duration) *Option

WithReconnectTimeout specifies the duration to wait before reconnecting after a recoverable error

func WithRecoverableErrorHandler

func WithRecoverableErrorHandler(f ShouldTerminate) *Option

WithRecoverableErrorHandler registers a function that will be called when a recoverable error occurs

type Sensor

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

Sensor represents a configured Asair AHT10 temperature and relative humidity sensor

func NewSensor

func NewSensor(portFactory coreio.PortFactory, options ...*Option) *Sensor

NewSensor creates a Sensor with optional configuration

func (*Sensor) ReconnectTimeout

func (s *Sensor) ReconnectTimeout() time.Duration

ReconnectTimeout is the duration to wait before reconnecting after a recoverable error

func (*Sensor) RecoverableErrorHandler

func (s *Sensor) RecoverableErrorHandler() ShouldTerminate

RecoverableErrorHandler a function that will be called when a recoverable error occurs

func (*Sensor) RelativeHumidities

func (s *Sensor) RelativeHumidities() <-chan *units.RelativeHumidity

RelativeHumidities returns a channel of relative humidity readings as they become available from the sensor

func (*Sensor) RelativeHumiditySpecs

func (*Sensor) RelativeHumiditySpecs() []*humidity.RelativeHumiditySpec

HumiditySpecs returns a collection of specified measurement ranges supported by the sensor

func (*Sensor) Run

func (s *Sensor) Run(ctx context.Context) error

Run begins reading from the sensor and blocks until either an error occurs or the context is completed

func (*Sensor) TemperatureSpecs

func (*Sensor) TemperatureSpecs() []*temperature.TemperatureSpec

TemperatureSpecs returns a collection of specified measurement ranges supported by the sensor

func (*Sensor) Temperatures

func (s *Sensor) Temperatures() <-chan *units.Temperature

Temperatures returns a channel of temperature readings as they become available from the sensor

type ShouldTerminate

type ShouldTerminate func(error) bool

ShouldTerminate is a function that returns a result indicating whether the Sensor should terminate after a recoverable error

Jump to

Keyboard shortcuts

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