ptc_bricklet

package
v0.0.0-...-8a98e63 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: CC0-1.0 Imports: 5 Imported by: 0

Documentation

Overview

Reads temperatures from Pt100 und Pt1000 sensors.

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

Index

Constants

View Source
const DeviceDisplayName = "PTC Bricklet"
View Source
const DeviceIdentifier = 226

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterOption

type FilterOption = uint8
const (
	FilterOption50Hz FilterOption = 0
	FilterOption60Hz FilterOption = 1
)

type Function

type Function = uint8
const (
	FunctionGetTemperature                          Function = 1
	FunctionGetResistance                           Function = 2
	FunctionSetTemperatureCallbackPeriod            Function = 3
	FunctionGetTemperatureCallbackPeriod            Function = 4
	FunctionSetResistanceCallbackPeriod             Function = 5
	FunctionGetResistanceCallbackPeriod             Function = 6
	FunctionSetTemperatureCallbackThreshold         Function = 7
	FunctionGetTemperatureCallbackThreshold         Function = 8
	FunctionSetResistanceCallbackThreshold          Function = 9
	FunctionGetResistanceCallbackThreshold          Function = 10
	FunctionSetDebouncePeriod                       Function = 11
	FunctionGetDebouncePeriod                       Function = 12
	FunctionSetNoiseRejectionFilter                 Function = 17
	FunctionGetNoiseRejectionFilter                 Function = 18
	FunctionIsSensorConnected                       Function = 19
	FunctionSetWireMode                             Function = 20
	FunctionGetWireMode                             Function = 21
	FunctionSetSensorConnectedCallbackConfiguration Function = 22
	FunctionGetSensorConnectedCallbackConfiguration Function = 23
	FunctionGetIdentity                             Function = 255
	FunctionCallbackTemperature                     Function = 13
	FunctionCallbackTemperatureReached              Function = 14
	FunctionCallbackResistance                      Function = 15
	FunctionCallbackResistanceReached               Function = 16
	FunctionCallbackSensorConnected                 Function = 24
)

type PTCBricklet

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

func New

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

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

func (*PTCBricklet) DeregisterResistanceCallback

func (device *PTCBricklet) DeregisterResistanceCallback(registrationId uint64)

Remove a registered Resistance callback.

func (*PTCBricklet) DeregisterResistanceReachedCallback

func (device *PTCBricklet) DeregisterResistanceReachedCallback(registrationId uint64)

Remove a registered Resistance Reached callback.

func (*PTCBricklet) DeregisterSensorConnectedCallback

func (device *PTCBricklet) DeregisterSensorConnectedCallback(registrationId uint64)

Remove a registered Sensor Connected callback.

func (*PTCBricklet) DeregisterTemperatureCallback

func (device *PTCBricklet) DeregisterTemperatureCallback(registrationId uint64)

Remove a registered Temperature callback.

func (*PTCBricklet) DeregisterTemperatureReachedCallback

func (device *PTCBricklet) DeregisterTemperatureReachedCallback(registrationId uint64)

Remove a registered Temperature Reached callback.

func (*PTCBricklet) GetAPIVersion

func (device *PTCBricklet) 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 (*PTCBricklet) GetDebouncePeriod

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

Returns the debounce period as set by SetDebouncePeriod.

func (*PTCBricklet) GetIdentity

func (device *PTCBricklet) 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 (*PTCBricklet) GetNoiseRejectionFilter

func (device *PTCBricklet) GetNoiseRejectionFilter() (filter FilterOption, err error)

Returns the noise rejection filter option as set by SetNoiseRejectionFilter

Associated constants:

  • FilterOption50Hz
  • FilterOption60Hz

func (*PTCBricklet) GetResistance

func (device *PTCBricklet) GetResistance() (resistance int32, err error)

Returns the value as measured by the MAX31865 precision delta-sigma ADC.

The value can be converted with the following formulas:

* Pt100: resistance = (value * 390) / 32768 * Pt1000: resistance = (value * 3900) / 32768

If you want to get the resistance periodically, it is recommended to use the RegisterResistanceCallback callback and set the period with SetResistanceCallbackPeriod.

func (*PTCBricklet) GetResistanceCallbackPeriod

func (device *PTCBricklet) GetResistanceCallbackPeriod() (period uint32, err error)

Returns the period as set by SetResistanceCallbackPeriod.

func (*PTCBricklet) GetResistanceCallbackThreshold

func (device *PTCBricklet) GetResistanceCallbackThreshold() (option ThresholdOption, min int32, max int32, err error)

Returns the threshold as set by SetResistanceCallbackThreshold.

Associated constants:

  • ThresholdOptionOff
  • ThresholdOptionOutside
  • ThresholdOptionInside
  • ThresholdOptionSmaller
  • ThresholdOptionGreater

func (*PTCBricklet) GetResponseExpected

func (device *PTCBricklet) 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 (*PTCBricklet) GetSensorConnectedCallbackConfiguration

func (device *PTCBricklet) GetSensorConnectedCallbackConfiguration() (enabled bool, err error)

Returns the configuration as set by SetSensorConnectedCallbackConfiguration.

.. versionadded:: 2.0.2$nbsp;(Plugin)

func (*PTCBricklet) GetTemperature

func (device *PTCBricklet) GetTemperature() (temperature int32, err error)

Returns the temperature of connected sensor.

If you want to get the temperature periodically, it is recommended to use the RegisterTemperatureCallback callback and set the period with SetTemperatureCallbackPeriod.

func (*PTCBricklet) GetTemperatureCallbackPeriod

func (device *PTCBricklet) GetTemperatureCallbackPeriod() (period uint32, err error)

Returns the period as set by SetTemperatureCallbackPeriod.

func (*PTCBricklet) GetTemperatureCallbackThreshold

func (device *PTCBricklet) GetTemperatureCallbackThreshold() (option ThresholdOption, min int32, max int32, err error)

Returns the threshold as set by SetTemperatureCallbackThreshold.

Associated constants:

  • ThresholdOptionOff
  • ThresholdOptionOutside
  • ThresholdOptionInside
  • ThresholdOptionSmaller
  • ThresholdOptionGreater

func (*PTCBricklet) GetWireMode

func (device *PTCBricklet) GetWireMode() (mode WireMode, err error)

Returns the wire mode as set by SetWireMode

Associated constants:

  • WireMode2
  • WireMode3
  • WireMode4

func (*PTCBricklet) IsSensorConnected

func (device *PTCBricklet) IsSensorConnected() (connected bool, err error)

Returns *true* if the sensor is connected correctly.

If this function returns *false*, there is either no Pt100 or Pt1000 sensor connected, the sensor is connected incorrectly or the sensor itself is faulty.

func (*PTCBricklet) RegisterResistanceCallback

func (device *PTCBricklet) RegisterResistanceCallback(fn func(int32)) uint64

This callback is triggered periodically with the period that is set by SetResistanceCallbackPeriod. The parameter is the resistance of the connected sensor.

The RegisterResistanceCallback callback is only triggered if the resistance has changed since the last triggering.

func (*PTCBricklet) RegisterResistanceReachedCallback

func (device *PTCBricklet) RegisterResistanceReachedCallback(fn func(int32)) uint64

This callback is triggered when the threshold as set by SetResistanceCallbackThreshold is reached. The parameter is the resistance of the connected sensor.

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

func (*PTCBricklet) RegisterSensorConnectedCallback

func (device *PTCBricklet) RegisterSensorConnectedCallback(fn func(bool)) uint64

This callback is triggered periodically according to the configuration set by SetSensorConnectedCallbackConfiguration.

The parameter is the same as IsSensorConnected.

.. versionadded:: 2.0.2$nbsp;(Plugin)

func (*PTCBricklet) RegisterTemperatureCallback

func (device *PTCBricklet) RegisterTemperatureCallback(fn func(int32)) uint64

This callback is triggered periodically with the period that is set by SetTemperatureCallbackPeriod. The parameter is the temperature of the connected sensor.

The RegisterTemperatureCallback callback is only triggered if the temperature has changed since the last triggering.

func (*PTCBricklet) RegisterTemperatureReachedCallback

func (device *PTCBricklet) RegisterTemperatureReachedCallback(fn func(int32)) uint64

This callback is triggered when the threshold as set by SetTemperatureCallbackThreshold is reached. The parameter is the temperature of the connected sensor.

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

func (*PTCBricklet) SetDebouncePeriod

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

Sets the period with which the threshold callback

* RegisterTemperatureReachedCallback, * RegisterResistanceReachedCallback

is triggered, if the threshold

* SetTemperatureCallbackThreshold, * SetResistanceCallbackThreshold

keeps being reached.

func (*PTCBricklet) SetNoiseRejectionFilter

func (device *PTCBricklet) SetNoiseRejectionFilter(filter FilterOption) (err error)

Sets the noise rejection filter to either 50Hz (0) or 60Hz (1). Noise from 50Hz or 60Hz power sources (including harmonics of the AC power's fundamental frequency) is attenuated by 82dB.

Associated constants:

  • FilterOption50Hz
  • FilterOption60Hz

func (*PTCBricklet) SetResistanceCallbackPeriod

func (device *PTCBricklet) SetResistanceCallbackPeriod(period uint32) (err error)

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

The RegisterResistanceCallback callback is only triggered if the resistance has changed since the last triggering.

func (*PTCBricklet) SetResistanceCallbackThreshold

func (device *PTCBricklet) SetResistanceCallbackThreshold(option ThresholdOption, min int32, max int32) (err error)

Sets the thresholds for the RegisterResistanceReachedCallback callback.

The following options are possible:

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

Associated constants:

  • ThresholdOptionOff
  • ThresholdOptionOutside
  • ThresholdOptionInside
  • ThresholdOptionSmaller
  • ThresholdOptionGreater

func (*PTCBricklet) SetResponseExpected

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

func (device *PTCBricklet) SetResponseExpectedAll(responseExpected bool)

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

func (*PTCBricklet) SetSensorConnectedCallbackConfiguration

func (device *PTCBricklet) SetSensorConnectedCallbackConfiguration(enabled bool) (err error)

If you enable this callback, the RegisterSensorConnectedCallback callback is triggered every time a Pt sensor is connected/disconnected.

.. versionadded:: 2.0.2$nbsp;(Plugin)

func (*PTCBricklet) SetTemperatureCallbackPeriod

func (device *PTCBricklet) SetTemperatureCallbackPeriod(period uint32) (err error)

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

The RegisterTemperatureCallback callback is only triggered if the temperature has changed since the last triggering.

func (*PTCBricklet) SetTemperatureCallbackThreshold

func (device *PTCBricklet) SetTemperatureCallbackThreshold(option ThresholdOption, min int32, max int32) (err error)

Sets the thresholds for the RegisterTemperatureReachedCallback callback.

The following options are possible:

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

Associated constants:

  • ThresholdOptionOff
  • ThresholdOptionOutside
  • ThresholdOptionInside
  • ThresholdOptionSmaller
  • ThresholdOptionGreater

func (*PTCBricklet) SetWireMode

func (device *PTCBricklet) SetWireMode(mode WireMode) (err error)

Sets the wire mode of the sensor. Possible values are 2, 3 and 4 which correspond to 2-, 3- and 4-wire sensors. The value has to match the jumper configuration on the Bricklet.

Associated constants:

  • WireMode2
  • WireMode3
  • WireMode4

type ThresholdOption

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

type WireMode

type WireMode = uint8
const (
	WireMode2 WireMode = 2
	WireMode3 WireMode = 3
	WireMode4 WireMode = 4
)

Jump to

Keyboard shortcuts

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