Documentation ¶
Overview ¶
Measures relative humidity.
See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/Humidity_Bricklet_Go.html.
Index ¶
- Constants
- type Function
- type HumidityBricklet
- func (device *HumidityBricklet) DeregisterAnalogValueCallback(registrationId uint64)
- func (device *HumidityBricklet) DeregisterAnalogValueReachedCallback(registrationId uint64)
- func (device *HumidityBricklet) DeregisterHumidityCallback(registrationId uint64)
- func (device *HumidityBricklet) DeregisterHumidityReachedCallback(registrationId uint64)
- func (device *HumidityBricklet) GetAPIVersion() [3]uint8
- func (device *HumidityBricklet) GetAnalogValue() (value uint16, err error)
- func (device *HumidityBricklet) GetAnalogValueCallbackPeriod() (period uint32, err error)
- func (device *HumidityBricklet) GetAnalogValueCallbackThreshold() (option ThresholdOption, min uint16, max uint16, err error)
- func (device *HumidityBricklet) GetDebouncePeriod() (debounce uint32, err error)
- func (device *HumidityBricklet) GetHumidity() (humidity uint16, err error)
- func (device *HumidityBricklet) GetHumidityCallbackPeriod() (period uint32, err error)
- func (device *HumidityBricklet) GetHumidityCallbackThreshold() (option ThresholdOption, min uint16, max uint16, err error)
- func (device *HumidityBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (device *HumidityBricklet) GetResponseExpected(functionID Function) (bool, error)
- func (device *HumidityBricklet) RegisterAnalogValueCallback(fn func(uint16)) uint64
- func (device *HumidityBricklet) RegisterAnalogValueReachedCallback(fn func(uint16)) uint64
- func (device *HumidityBricklet) RegisterHumidityCallback(fn func(uint16)) uint64
- func (device *HumidityBricklet) RegisterHumidityReachedCallback(fn func(uint16)) uint64
- func (device *HumidityBricklet) SetAnalogValueCallbackPeriod(period uint32) (err error)
- func (device *HumidityBricklet) SetAnalogValueCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error)
- func (device *HumidityBricklet) SetDebouncePeriod(debounce uint32) (err error)
- func (device *HumidityBricklet) SetHumidityCallbackPeriod(period uint32) (err error)
- func (device *HumidityBricklet) SetHumidityCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error)
- func (device *HumidityBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
- func (device *HumidityBricklet) SetResponseExpectedAll(responseExpected bool)
- type ThresholdOption
Constants ¶
const DeviceDisplayName = "Humidity Bricklet"
const DeviceIdentifier = 27
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Function ¶
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 ¶
type HumidityBricklet struct {
// contains filtered or unexported fields
}
func New ¶
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 ¶
func (device *HumidityBricklet) DeregisterAnalogValueCallback(registrationId uint64)
Remove a registered Analog Value callback.
func (*HumidityBricklet) DeregisterAnalogValueReachedCallback ¶
func (device *HumidityBricklet) DeregisterAnalogValueReachedCallback(registrationId uint64)
Remove a registered Analog Value Reached callback.
func (*HumidityBricklet) DeregisterHumidityCallback ¶
func (device *HumidityBricklet) DeregisterHumidityCallback(registrationId uint64)
Remove a registered Humidity callback.
func (*HumidityBricklet) DeregisterHumidityReachedCallback ¶
func (device *HumidityBricklet) DeregisterHumidityReachedCallback(registrationId uint64)
Remove a registered Humidity Reached callback.
func (*HumidityBricklet) GetAPIVersion ¶
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 ¶
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 ¶
func (device *HumidityBricklet) GetAnalogValueCallbackPeriod() (period uint32, err error)
Returns the period as set by SetAnalogValueCallbackPeriod.
func (*HumidityBricklet) GetAnalogValueCallbackThreshold ¶
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 ¶
func (device *HumidityBricklet) GetDebouncePeriod() (debounce uint32, err error)
Returns the debounce period as set by SetDebouncePeriod.
func (*HumidityBricklet) GetHumidity ¶
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 ¶
func (device *HumidityBricklet) GetHumidityCallbackPeriod() (period uint32, err error)
Returns the period as set by SetHumidityCallbackPeriod.
func (*HumidityBricklet) GetHumidityCallbackThreshold ¶
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 ¶
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', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an `Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|
func (*HumidityBricklet) GetResponseExpected ¶
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 sent 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 sent and errors are silently ignored, because they cannot be detected.
func (*HumidityBricklet) SetResponseExpectedAll ¶
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 ¶
type ThresholdOption = rune
const ( ThresholdOptionOff ThresholdOption = 'x' ThresholdOptionOutside ThresholdOption = 'o' ThresholdOptionInside ThresholdOption = 'i' ThresholdOptionSmaller ThresholdOption = '<' ThresholdOptionGreater ThresholdOption = '>' )