go-api-bindings: github.com/Tinkerforge/go-api-bindings/co2_bricklet Index | Files

package co2_bricklet

import "github.com/Tinkerforge/go-api-bindings/co2_bricklet"

Measures CO2 concentration in ppm.

See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/CO2_Bricklet_Go.html.

Index

Package Files

co2_bricklet.go

Constants

const DeviceDisplayName = "CO2 Bricklet"
const DeviceIdentifier = 262

type CO2Bricklet Uses

type CO2Bricklet struct {
    // contains filtered or unexported fields
}

func New Uses

func New(uid string, ipcon *ipconnection.IPConnection) (CO2Bricklet, error)

Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.

func (*CO2Bricklet) DeregisterCO2ConcentrationCallback Uses

func (device *CO2Bricklet) DeregisterCO2ConcentrationCallback(registrationID uint64)

Remove a registered CO2 Concentration callback.

func (*CO2Bricklet) DeregisterCO2ConcentrationReachedCallback Uses

func (device *CO2Bricklet) DeregisterCO2ConcentrationReachedCallback(registrationID uint64)

Remove a registered CO2 Concentration Reached callback.

func (*CO2Bricklet) GetAPIVersion Uses

func (device *CO2Bricklet) GetAPIVersion() [3]uint8

Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.

func (*CO2Bricklet) GetCO2Concentration Uses

func (device *CO2Bricklet) GetCO2Concentration() (co2Concentration uint16, err error)

Returns the measured CO2 concentration. The value is in https://en.wikipedia.org/wiki/Parts-per_notation and between 0 to 10000.

If you want to get the CO2 concentration periodically, it is recommended to use the RegisterCO2ConcentrationCallback callback and set the period with SetCO2ConcentrationCallbackPeriod.

func (*CO2Bricklet) GetCO2ConcentrationCallbackPeriod Uses

func (device *CO2Bricklet) GetCO2ConcentrationCallbackPeriod() (period uint32, err error)

Returns the period as set by SetCO2ConcentrationCallbackPeriod.

func (*CO2Bricklet) GetCO2ConcentrationCallbackThreshold Uses

func (device *CO2Bricklet) GetCO2ConcentrationCallbackThreshold() (option ThresholdOption, min uint16, max uint16, err error)

Returns the threshold as set by SetCO2ConcentrationCallbackThreshold.

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*CO2Bricklet) GetDebouncePeriod Uses

func (device *CO2Bricklet) GetDebouncePeriod() (debounce uint32, err error)

Returns the debounce period as set by SetDebouncePeriod.

func (*CO2Bricklet) GetIdentity Uses

func (device *CO2Bricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c' or 'd'.

The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|

func (*CO2Bricklet) GetResponseExpected Uses

func (device *CO2Bricklet) GetResponseExpected(functionID Function) (bool, error)

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.

See SetResponseExpected for the list of function ID constants available for this function.

func (*CO2Bricklet) RegisterCO2ConcentrationCallback Uses

func (device *CO2Bricklet) RegisterCO2ConcentrationCallback(fn func(uint16)) uint64

This callback is triggered periodically with the period that is set by SetCO2ConcentrationCallbackPeriod. The parameter is the CO2 concentration of the sensor.

The RegisterCO2ConcentrationCallback callback is only triggered if the CO2 concentration has changed since the last triggering.

func (*CO2Bricklet) RegisterCO2ConcentrationReachedCallback Uses

func (device *CO2Bricklet) RegisterCO2ConcentrationReachedCallback(fn func(uint16)) uint64

This callback is triggered when the threshold as set by SetCO2ConcentrationCallbackThreshold is reached. The parameter is the CO2 concentration.

If the threshold keeps being reached, the callback is triggered periodically with the period as set by SetDebouncePeriod.

func (*CO2Bricklet) SetCO2ConcentrationCallbackPeriod Uses

func (device *CO2Bricklet) SetCO2ConcentrationCallbackPeriod(period uint32) (err error)

Sets the period in ms with which the RegisterCO2ConcentrationCallback callback is triggered periodically. A value of 0 turns the callback off.

The RegisterCO2ConcentrationCallback callback is only triggered if the CO2 concentration has changed since the last triggering.

The default value is 0.

func (*CO2Bricklet) SetCO2ConcentrationCallbackThreshold Uses

func (device *CO2Bricklet) SetCO2ConcentrationCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error)

Sets the thresholds for the RegisterCO2ConcentrationReachedCallback callback.

The following options are possible:

Option| Description
--- | ---
'x'|    Callback is turned off
'o'|    Callback is triggered when the CO2 concentration is *outside* the min and max values
'i'|    Callback is triggered when the CO2 concentration is *inside* the min and max values
'<'|    Callback is triggered when the CO2 concentration is smaller than the min value (max is ignored)
'>'|    Callback is triggered when the CO2 concentration is greater than the min value (max is ignored)

The default value is ('x', 0, 0).

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*CO2Bricklet) SetDebouncePeriod Uses

func (device *CO2Bricklet) SetDebouncePeriod(debounce uint32) (err error)

Sets the period in ms with which the threshold callbacks

* RegisterCO2ConcentrationReachedCallback,

are triggered, if the thresholds

* SetCO2ConcentrationCallbackThreshold,

keep being reached.

The default value is 100.

func (*CO2Bricklet) SetResponseExpected Uses

func (device *CO2Bricklet) SetResponseExpected(functionID Function, responseExpected bool) error

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.

func (*CO2Bricklet) SetResponseExpectedAll Uses

func (device *CO2Bricklet) SetResponseExpectedAll(responseExpected bool)

Changes the response expected flag for all setter and callback configuration functions of this device at once.

type Function Uses

type Function uint8
const (
    FunctionGetCO2Concentration                  Function = 1
    FunctionSetCO2ConcentrationCallbackPeriod    Function = 2
    FunctionGetCO2ConcentrationCallbackPeriod    Function = 3
    FunctionSetCO2ConcentrationCallbackThreshold Function = 4
    FunctionGetCO2ConcentrationCallbackThreshold Function = 5
    FunctionSetDebouncePeriod                    Function = 6
    FunctionGetDebouncePeriod                    Function = 7
    FunctionGetIdentity                          Function = 255
    FunctionCallbackCO2Concentration             Function = 8
    FunctionCallbackCO2ConcentrationReached      Function = 9
)

type ThresholdOption Uses

type ThresholdOption rune
const (
    ThresholdOptionOff     ThresholdOption = 'x'
    ThresholdOptionOutside ThresholdOption = 'o'
    ThresholdOptionInside  ThresholdOption = 'i'
    ThresholdOptionSmaller ThresholdOption = '<'
    ThresholdOptionGreater ThresholdOption = '>'
)

Package co2_bricklet imports 4 packages (graph). Updated 2019-06-09. Refresh now. Tools for package owners.