Documentation ¶
Overview ¶
This package provides an implementation to read gas concentration measurements from a Sensiron SGP30 sensor.
Index ¶
- Constants
- func GetDefaultI2CPortConfig() *i2c.I2CPortConfig
- type Option
- type Sensor
- func (*Sensor) ConcentrationSpecs() []*gas.ConcentrationSpec
- func (s *Sensor) Concentrations() <-chan *gas.Concentration
- func (s *Sensor) HandleRelativeHumidity(ctx context.Context, relativeHumidity *units.RelativeHumidity) error
- func (s *Sensor) ReconnectTimeout() time.Duration
- func (s *Sensor) RecoverableErrorHandler() ShouldTerminate
- func (s *Sensor) Run(ctx context.Context) error
- type ShouldTerminate
Constants ¶
const ( TotalVolatileOrganicCompounds string = "TVOC" CarbonDioxideEquivalent string = "CO2eq" )
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 Sensiron SGP30 gas sensor
func NewSensor ¶
func NewSensor(portFactory coreio.PortFactory, options ...*Option) *Sensor
NewSensor creates a Sensor with optional configuration
func (*Sensor) ConcentrationSpecs ¶
func (*Sensor) ConcentrationSpecs() []*gas.ConcentrationSpec
ConcentrationSpecs returns a collection of specified measurement ranges supported by the sensor
func (*Sensor) Concentrations ¶
func (s *Sensor) Concentrations() <-chan *gas.Concentration
Concentrations returns a channel of concentration readings as they become available from the sensor
func (*Sensor) HandleRelativeHumidity ¶
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
type ShouldTerminate ¶
ShouldTerminate is a function that returns a result indicating whether the Sensor should terminate after a recoverable error