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
- func GetDefaultI2CPortConfig() *i2c.I2CPortConfig
- type Option
- type Sensor
- func (s *Sensor) ReconnectTimeout() time.Duration
- func (s *Sensor) RecoverableErrorHandler() ShouldTerminate
- func (s *Sensor) RelativeHumidities() <-chan *units.RelativeHumidity
- func (*Sensor) RelativeHumiditySpecs() []*humidity.RelativeHumiditySpec
- func (s *Sensor) Run(ctx context.Context) error
- func (*Sensor) TemperatureSpecs() []*temperature.TemperatureSpec
- func (s *Sensor) Temperatures() <-chan *units.Temperature
- type ShouldTerminate
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
ShouldTerminate is a function that returns a result indicating whether the Sensor should terminate after a recoverable error