Documentation ¶
Overview ¶
Package sds011 implements a library to read the protocol of SDS011, an air quality sensor than can work with Raspberry Pi.
Index ¶
- type Point
- type Sensor
- func (sensor *Sensor) Awake() error
- func (sensor *Sensor) Close()
- func (sensor *Sensor) Cycle() (uint8, error)
- func (sensor *Sensor) DeviceID() (string, error)
- func (sensor *Sensor) Firmware() (string, error)
- func (sensor *Sensor) Get() (point *Point, err error)
- func (sensor *Sensor) IsAwake() (bool, error)
- func (sensor *Sensor) MakeActive() error
- func (sensor *Sensor) MakePassive() error
- func (sensor *Sensor) Query() (*Point, error)
- func (sensor *Sensor) ReportMode() (bool, error)
- func (sensor *Sensor) SetCycle(value uint8) error
- func (sensor *Sensor) Sleep() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sensor ¶
type Sensor struct {
// contains filtered or unexported fields
}
Sensor represents an SDS011 sensor.
func New ¶
New returns a sensor that will read data from serial port for which the path was provided. It is the responsibility of the caller to close the sensor.
func NewSensor ¶
func NewSensor(rwc io.ReadWriteCloser) *Sensor
NewSensor returns a sensor that will read its data from the provided read-write-closer.
func (*Sensor) Cycle ¶
Cycle returns the current cycle length in minutes. If it's 0 it means that cycle is not set, and the sensor is streaming data continuously.
func (*Sensor) Get ¶
Get will read one measurement. It will block until data is available. It only makes sense to call read if the sensor is in active mode.
func (*Sensor) MakeActive ¶
MakeActive makes the sensor actively report its measurements.
func (*Sensor) MakePassive ¶
MakePassive stop the sensor from actively reporting its measurements. You will need to send a Query command.
func (*Sensor) ReportMode ¶
ReportMode returns true if the device is in active mode, false if in query mode.