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

package humidity_bricklet

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

Measures relative humidity.

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

Index

Package Files

humidity_bricklet.go

Constants

const DeviceDisplayName = "Humidity Bricklet"
const DeviceIdentifier = 27

type Function Uses

type Function = uint8
const (
    FunctionGetHumidity                     Function = 1
    FunctionGetAnalogValue                  Function = 2
    FunctionSetHumidityCallbackPeriod       Function = 3
    FunctionGetHumidityCallbackPeriod       Function = 4
    FunctionSetAnalogValueCallbackPeriod    Function = 5
    FunctionGetAnalogValueCallbackPeriod    Function = 6
    FunctionSetHumidityCallbackThreshold    Function = 7
    FunctionGetHumidityCallbackThreshold    Function = 8
    FunctionSetAnalogValueCallbackThreshold Function = 9
    FunctionGetAnalogValueCallbackThreshold Function = 10
    FunctionSetDebouncePeriod               Function = 11
    FunctionGetDebouncePeriod               Function = 12
    FunctionGetIdentity                     Function = 255
    FunctionCallbackHumidity                Function = 13
    FunctionCallbackAnalogValue             Function = 14
    FunctionCallbackHumidityReached         Function = 15
    FunctionCallbackAnalogValueReached      Function = 16
)

type HumidityBricklet Uses

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

func New Uses

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

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

func (*HumidityBricklet) DeregisterAnalogValueCallback Uses

func (device *HumidityBricklet) DeregisterAnalogValueCallback(registrationId uint64)

Remove a registered Analog Value callback.

func (*HumidityBricklet) DeregisterAnalogValueReachedCallback Uses

func (device *HumidityBricklet) DeregisterAnalogValueReachedCallback(registrationId uint64)

Remove a registered Analog Value Reached callback.

func (*HumidityBricklet) DeregisterHumidityCallback Uses

func (device *HumidityBricklet) DeregisterHumidityCallback(registrationId uint64)

Remove a registered Humidity callback.

func (*HumidityBricklet) DeregisterHumidityReachedCallback Uses

func (device *HumidityBricklet) DeregisterHumidityReachedCallback(registrationId uint64)

Remove a registered Humidity Reached callback.

func (*HumidityBricklet) GetAPIVersion Uses

func (device *HumidityBricklet) 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 (*HumidityBricklet) GetAnalogValue Uses

func (device *HumidityBricklet) GetAnalogValue() (value uint16, err error)

Returns the value as read by a 12-bit analog-to-digital converter.

Note

The value returned by :func:https://github.com/Tinkerforge/humidity-bricklet/raw/master/datasheets/hih-5030.pdf.

If you want the analog value periodically, it is recommended to use the RegisterAnalogValueCallback callback and set the period with SetAnalogValueCallbackPeriod.

func (*HumidityBricklet) GetAnalogValueCallbackPeriod Uses

func (device *HumidityBricklet) GetAnalogValueCallbackPeriod() (period uint32, err error)

Returns the period as set by SetAnalogValueCallbackPeriod.

func (*HumidityBricklet) GetAnalogValueCallbackThreshold Uses

func (device *HumidityBricklet) GetAnalogValueCallbackThreshold() (option ThresholdOption, min uint16, max uint16, err error)

Returns the threshold as set by SetAnalogValueCallbackThreshold.

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*HumidityBricklet) GetDebouncePeriod Uses

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

Returns the debounce period as set by SetDebouncePeriod.

func (*HumidityBricklet) GetHumidity Uses

func (device *HumidityBricklet) GetHumidity() (humidity uint16, err error)

Returns the humidity of the sensor.

If you want to get the humidity periodically, it is recommended to use the RegisterHumidityCallback callback and set the period with SetHumidityCallbackPeriod.

func (*HumidityBricklet) GetHumidityCallbackPeriod Uses

func (device *HumidityBricklet) GetHumidityCallbackPeriod() (period uint32, err error)

Returns the period as set by SetHumidityCallbackPeriod.

func (*HumidityBricklet) GetHumidityCallbackThreshold Uses

func (device *HumidityBricklet) GetHumidityCallbackThreshold() (option ThresholdOption, min uint16, max uint16, err error)

Returns the threshold as set by SetHumidityCallbackThreshold.

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*HumidityBricklet) GetIdentity Uses

func (device *HumidityBricklet) 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 (*HumidityBricklet) GetResponseExpected Uses

func (device *HumidityBricklet) 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 (*HumidityBricklet) RegisterAnalogValueCallback Uses

func (device *HumidityBricklet) RegisterAnalogValueCallback(fn func(uint16)) uint64

This callback is triggered periodically with the period that is set by SetAnalogValueCallbackPeriod. The parameter is the analog value of the sensor.

The RegisterAnalogValueCallback callback is only triggered if the humidity has changed since the last triggering.

func (*HumidityBricklet) RegisterAnalogValueReachedCallback Uses

func (device *HumidityBricklet) RegisterAnalogValueReachedCallback(fn func(uint16)) uint64

This callback is triggered when the threshold as set by SetAnalogValueCallbackThreshold is reached. The parameter is the analog value of the sensor.

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

func (*HumidityBricklet) RegisterHumidityCallback Uses

func (device *HumidityBricklet) RegisterHumidityCallback(fn func(uint16)) uint64

This callback is triggered periodically with the period that is set by SetHumidityCallbackPeriod. The parameter is the humidity of the sensor.

The RegisterHumidityCallback callback is only triggered if the humidity has changed since the last triggering.

func (*HumidityBricklet) RegisterHumidityReachedCallback Uses

func (device *HumidityBricklet) RegisterHumidityReachedCallback(fn func(uint16)) uint64

This callback is triggered when the threshold as set by SetHumidityCallbackThreshold is reached. The parameter is the humidity of the sensor.

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

func (*HumidityBricklet) SetAnalogValueCallbackPeriod Uses

func (device *HumidityBricklet) SetAnalogValueCallbackPeriod(period uint32) (err error)

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

The RegisterAnalogValueCallback callback is only triggered if the analog value has changed since the last triggering.

func (*HumidityBricklet) SetAnalogValueCallbackThreshold Uses

func (device *HumidityBricklet) SetAnalogValueCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error)

Sets the thresholds for the RegisterAnalogValueReachedCallback callback.

The following options are possible:

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

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*HumidityBricklet) SetDebouncePeriod Uses

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

Sets the period with which the threshold callbacks

* RegisterHumidityReachedCallback, * RegisterAnalogValueReachedCallback

are triggered, if the thresholds

* SetHumidityCallbackThreshold, * SetAnalogValueCallbackThreshold

keep being reached.

func (*HumidityBricklet) SetHumidityCallbackPeriod Uses

func (device *HumidityBricklet) SetHumidityCallbackPeriod(period uint32) (err error)

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

The RegisterHumidityCallback callback is only triggered if the humidity has changed since the last triggering.

func (*HumidityBricklet) SetHumidityCallbackThreshold Uses

func (device *HumidityBricklet) SetHumidityCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error)

Sets the thresholds for the RegisterHumidityReachedCallback callback.

The following options are possible:

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

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*HumidityBricklet) SetResponseExpected Uses

func (device *HumidityBricklet) 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 (*HumidityBricklet) SetResponseExpectedAll Uses

func (device *HumidityBricklet) SetResponseExpectedAll(responseExpected bool)

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

type ThresholdOption Uses

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

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