sensor

package
v0.0.0-...-baaaa93 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParseData = errors.New("Can not parse data")
View Source
var ErrReadSensor = errors.New("Can not read data from Sensor")

Functions

func Read

func Read(ctx context.Context, sensors []Sensor) ([]*types.MeasuredValue, error)

Read measured values from sensors

func ReadChannel

func ReadChannel(ctx context.Context, sensors []Sensor, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)

ReadChannel reads the measured values from sensors and writes them to a channel.

func ReadContinuously

func ReadContinuously(ctx context.Context, sensors []Sensor, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)

ReadContinuously reads the measured values continously from sensors and writes them to a channel.

Types

type BME280

type BME280 struct {
	*types.Sensor
}

BME280 is a sensor to measure humidity and temperature.

func (*BME280) GetSensorModel

func (s *BME280) GetSensorModel() types.SensorModel

GetSensorModel returns the sensor model

func (*BME280) Read

func (s *BME280) Read() ([]*types.MeasuredValue, error)

Read measured values

func (*BME280) ReadChannel

func (s *BME280) ReadChannel(measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error, wg *sync.WaitGroup)

ReadChannel reads the measured values from the sensor and writes them to a channel.

func (*BME280) ReadContinously

func (s *BME280) ReadContinously(ctx context.Context, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)

ReadContinously reads the measured values continously from the sensor and writes them to a channel.

type DHT11

type DHT11 struct {
	*types.Sensor
}

DHT11 is a sensor to measure humidity and temperature.

func (*DHT11) GetSensorModel

func (s *DHT11) GetSensorModel() types.SensorModel

GetSensorModel returns the sensor model

func (*DHT11) Read

func (s *DHT11) Read() ([]*types.MeasuredValue, error)

Read measured values

func (*DHT11) ReadChannel

func (s *DHT11) ReadChannel(measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error, wg *sync.WaitGroup)

ReadChannel reads the measured values from the sensor and writes them to a channel.

func (*DHT11) ReadContinously

func (s *DHT11) ReadContinously(ctx context.Context, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)

ReadContinously reads the measured values continously from the sensor and writes them to a channel.

type DHT22

type DHT22 struct {
	*types.Sensor
}

DHT22 is a sensor to measure humidity and temperature.

func (*DHT22) GetSensorModel

func (s *DHT22) GetSensorModel() types.SensorModel

GetSensorModel returns the sensor model

func (*DHT22) Read

func (s *DHT22) Read() ([]*types.MeasuredValue, error)

Read measured values

func (*DHT22) ReadChannel

func (s *DHT22) ReadChannel(measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error, wg *sync.WaitGroup)

ReadChannel reads the measured values from the sensor and writes them to a channel.

func (*DHT22) ReadContinously

func (s *DHT22) ReadContinously(ctx context.Context, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)

ReadContinously reads the measured values continously from the sensor and writes them to a channel.

type DS18B20

type DS18B20 struct {
	*types.Sensor
}

DS18B20 is a sensor to measure humidity and temperature.

func (*DS18B20) GetSensorModel

func (s *DS18B20) GetSensorModel() types.SensorModel

GetSensorModel returns the sensor model

func (*DS18B20) Read

func (s *DS18B20) Read() ([]*types.MeasuredValue, error)

Read measured values

func (*DS18B20) ReadChannel

func (s *DS18B20) ReadChannel(measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error, wg *sync.WaitGroup)

ReadChannel reads the measured values from the sensor and writes them to a channel.

func (*DS18B20) ReadContinously

func (s *DS18B20) ReadContinously(ctx context.Context, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)

ReadContinously reads the measured values continously from the sensor and writes them to a channel.

type Sensor

type Sensor interface {
	GetSensorModel() types.SensorModel
	Read() ([]*types.MeasuredValue, error)
	ReadChannel(measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error, wg *sync.WaitGroup)
	ReadContinously(ctx context.Context, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error)
}

Jump to

Keyboard shortcuts

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