sensironsgp30

package module
v0.0.0-...-115d48b Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 9 Imported by: 0

README

go-sensors/sensironsgp30

Go library for interacting with the Sensiron SGP30 gas sensor for detecting volatile organic compounds (VOC).

Quickstart

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

Sensor Details

The Sensiron SGP30 gas sensors are used for detecting volatile organic compound (VOC) concentrations, 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 gas concentration measurements from a Sensiron SGP30 sensor.

Index

Constants

View Source
const (
	TotalVolatileOrganicCompounds string = "TVOC"
	CarbonDioxideEquivalent       string = "CO2eq"
)
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 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 (s *Sensor) HandleRelativeHumidity(ctx context.Context, relativeHumidity *units.RelativeHumidity) error

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) 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

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