Class: Tinkerforge::BrickletTemperatureIR
- Defined in:
- lib/tinkerforge/bricklet_temperature_ir.rb
Overview
Measures contactless object temperature between -70°C and +380°C
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
217
- DEVICE_DISPLAY_NAME =
:nodoc:
'Temperature IR Bricklet'
- CALLBACK_AMBIENT_TEMPERATURE =
This callback is triggered periodically with the period that is set by BrickletTemperatureIR#set_ambient_temperature_callback_period. The parameter is the ambient temperature of the sensor.
The CALLBACK_AMBIENT_TEMPERATURE callback is only triggered if the ambient temperature has changed since the last triggering.
15
- CALLBACK_OBJECT_TEMPERATURE =
This callback is triggered periodically with the period that is set by BrickletTemperatureIR#set_object_temperature_callback_period. The parameter is the object temperature of the sensor.
The CALLBACK_OBJECT_TEMPERATURE callback is only triggered if the object temperature has changed since the last triggering.
16
- CALLBACK_AMBIENT_TEMPERATURE_REACHED =
This callback is triggered when the threshold as set by BrickletTemperatureIR#set_ambient_temperature_callback_threshold is reached. The parameter is the ambient temperature of the sensor.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickletTemperatureIR#set_debounce_period.
17
- CALLBACK_OBJECT_TEMPERATURE_REACHED =
This callback is triggered when the threshold as set by BrickletTemperatureIR#set_object_temperature_callback_threshold is reached. The parameter is the object temperature of the sensor.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickletTemperatureIR#set_debounce_period.
18
- FUNCTION_GET_AMBIENT_TEMPERATURE =
:nodoc:
1
- FUNCTION_GET_OBJECT_TEMPERATURE =
:nodoc:
2
- FUNCTION_SET_EMISSIVITY =
:nodoc:
3
- FUNCTION_GET_EMISSIVITY =
:nodoc:
4
- FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD =
:nodoc:
5
- FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD =
:nodoc:
6
- FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD =
:nodoc:
7
- FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD =
:nodoc:
8
- FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD =
:nodoc:
9
- FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD =
:nodoc:
10
- FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD =
:nodoc:
11
- FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD =
:nodoc:
12
- FUNCTION_SET_DEBOUNCE_PERIOD =
:nodoc:
13
- FUNCTION_GET_DEBOUNCE_PERIOD =
:nodoc:
14
- FUNCTION_GET_IDENTITY =
:nodoc:
255
- THRESHOLD_OPTION_OFF =
:nodoc:
'x'
- THRESHOLD_OPTION_OUTSIDE =
:nodoc:
'o'
- THRESHOLD_OPTION_INSIDE =
:nodoc:
'i'
- THRESHOLD_OPTION_SMALLER =
:nodoc:
'<'
- THRESHOLD_OPTION_GREATER =
:nodoc:
'>'
Constants inherited from Device
Device::DEVICE_IDENTIFIER_CHECK_MATCH, Device::DEVICE_IDENTIFIER_CHECK_MISMATCH, Device::DEVICE_IDENTIFIER_CHECK_PENDING, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #high_level_callbacks, #registered_callbacks, #replaced, #uid
Instance Method Summary collapse
-
#get_ambient_temperature ⇒ Object
Returns the ambient temperature of the sensor.
-
#get_ambient_temperature_callback_period ⇒ Object
Returns the period as set by BrickletTemperatureIR#set_ambient_temperature_callback_period.
-
#get_ambient_temperature_callback_threshold ⇒ Object
Returns the threshold as set by BrickletTemperatureIR#set_ambient_temperature_callback_threshold.
-
#get_debounce_period ⇒ Object
Returns the debounce period as set by BrickletTemperatureIR#set_debounce_period.
-
#get_emissivity ⇒ Object
Returns the emissivity as set by BrickletTemperatureIR#set_emissivity.
-
#get_identity ⇒ Object
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
-
#get_object_temperature ⇒ Object
Returns the object temperature of the sensor, i.e.
-
#get_object_temperature_callback_period ⇒ Object
Returns the period as set by BrickletTemperatureIR#set_object_temperature_callback_period.
-
#get_object_temperature_callback_threshold ⇒ Object
Returns the threshold as set by BrickletTemperatureIR#set_object_temperature_callback_threshold.
-
#initialize(uid, ipcon) ⇒ BrickletTemperatureIR
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. -
#register_callback(id, &block) ⇒ Object
Registers a callback with ID
id
to the blockblock
. -
#set_ambient_temperature_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_AMBIENT_TEMPERATURE callback is triggered periodically.
-
#set_ambient_temperature_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_AMBIENT_TEMPERATURE_REACHED callback.
-
#set_debounce_period(debounce) ⇒ Object
Sets the period with which the threshold callbacks.
-
#set_emissivity(emissivity) ⇒ Object
Sets the ‘emissivity <en.wikipedia.org/wiki/Emissivity>`__ that is used to calculate the surface temperature as returned by BrickletTemperatureIR#get_object_temperature.
-
#set_object_temperature_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_OBJECT_TEMPERATURE callback is triggered periodically.
-
#set_object_temperature_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_OBJECT_TEMPERATURE_REACHED callback.
Methods inherited from Device
#check_validity, #dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickletTemperatureIR
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
Instance Method Details
#get_ambient_temperature ⇒ Object
Returns the ambient temperature of the sensor.
If you want to get the ambient temperature periodically, it is recommended to use the CALLBACK_AMBIENT_TEMPERATURE callback and set the period with BrickletTemperatureIR#set_ambient_temperature_callback_period.
110 111 112 113 114 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 110 def get_ambient_temperature check_validity send_request FUNCTION_GET_AMBIENT_TEMPERATURE, [], '', 10, 's' end |
#get_ambient_temperature_callback_period ⇒ Object
Returns the period as set by BrickletTemperatureIR#set_ambient_temperature_callback_period.
174 175 176 177 178 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 174 def get_ambient_temperature_callback_period check_validity send_request FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD, [], '', 12, 'L' end |
#get_ambient_temperature_callback_threshold ⇒ Object
Returns the threshold as set by BrickletTemperatureIR#set_ambient_temperature_callback_threshold.
216 217 218 219 220 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 216 def get_ambient_temperature_callback_threshold check_validity send_request FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 13, 'k s s' end |
#get_debounce_period ⇒ Object
Returns the debounce period as set by BrickletTemperatureIR#set_debounce_period.
264 265 266 267 268 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 264 def get_debounce_period check_validity send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L' end |
#get_emissivity ⇒ Object
Returns the emissivity as set by BrickletTemperatureIR#set_emissivity.
156 157 158 159 160 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 156 def get_emissivity check_validity send_request FUNCTION_GET_EMISSIVITY, [], '', 10, 'S' end |
#get_identity ⇒ Object
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 :ref:‘Isolator Bricklet <isolator_bricklet>` is always at position ’z’.
The device identifier numbers can be found :ref:‘here <device_identifier>`. |device_identifier_constant|
280 281 282 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 280 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_object_temperature ⇒ Object
Returns the object temperature of the sensor, i.e. the temperature of the surface of the object the sensor is aimed at.
The temperature of different materials is dependent on their ‘emissivity <en.wikipedia.org/wiki/Emissivity>`__. The emissivity of the material can be set with BrickletTemperatureIR#set_emissivity.
If you want to get the object temperature periodically, it is recommended to use the CALLBACK_OBJECT_TEMPERATURE callback and set the period with BrickletTemperatureIR#set_object_temperature_callback_period.
126 127 128 129 130 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 126 def get_object_temperature check_validity send_request FUNCTION_GET_OBJECT_TEMPERATURE, [], '', 10, 's' end |
#get_object_temperature_callback_period ⇒ Object
Returns the period as set by BrickletTemperatureIR#set_object_temperature_callback_period.
192 193 194 195 196 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 192 def get_object_temperature_callback_period check_validity send_request FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, [], '', 12, 'L' end |
#get_object_temperature_callback_threshold ⇒ Object
Returns the threshold as set by BrickletTemperatureIR#set_object_temperature_callback_threshold.
240 241 242 243 244 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 240 def get_object_temperature_callback_threshold check_validity send_request FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 13, 'k s s' end |
#register_callback(id, &block) ⇒ Object
Registers a callback with ID id
to the block block
.
285 286 287 288 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 285 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end |
#set_ambient_temperature_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_AMBIENT_TEMPERATURE callback is triggered periodically. A value of 0 turns the callback off.
The CALLBACK_AMBIENT_TEMPERATURE callback is only triggered if the temperature has changed since the last triggering.
167 168 169 170 171 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 167 def set_ambient_temperature_callback_period(period) check_validity send_request FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 8, '' end |
#set_ambient_temperature_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_AMBIENT_TEMPERATURE_REACHED callback.
The following options are possible:
"Option", "Description"
"'x'", "Callback is turned off"
"'o'", "Callback is triggered when the ambient temperature is *outside* the min and max values"
"'i'", "Callback is triggered when the ambient temperature is *inside* the min and max values"
"'<'", "Callback is triggered when the ambient temperature is smaller than the min value (max is ignored)"
"'>'", "Callback is triggered when the ambient temperature is greater than the min value (max is ignored)"
209 210 211 212 213 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 209 def set_ambient_temperature_callback_threshold(option, min, max) check_validity send_request FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, '' end |
#set_debounce_period(debounce) ⇒ Object
Sets the period with which the threshold callbacks
-
CALLBACK_AMBIENT_TEMPERATURE_REACHED,
-
CALLBACK_OBJECT_TEMPERATURE_REACHED
are triggered, if the thresholds
-
BrickletTemperatureIR#set_ambient_temperature_callback_threshold,
-
BrickletTemperatureIR#set_object_temperature_callback_threshold
keep being reached.
257 258 259 260 261 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 257 def set_debounce_period(debounce) check_validity send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, '' end |
#set_emissivity(emissivity) ⇒ Object
Sets the ‘emissivity <en.wikipedia.org/wiki/Emissivity>`__ that is used to calculate the surface temperature as returned by BrickletTemperatureIR#get_object_temperature.
The emissivity is usually given as a value between 0.0 and 1.0. A list of emissivities of different materials can be found ‘here <www.infrared-thermography.com/material.htm>`__.
The parameter of BrickletTemperatureIR#set_emissivity has to be given with a factor of 65535 (16-bit). For example: An emissivity of 0.1 can be set with the value 6553, an emissivity of 0.5 with the value 32767 and so on.
- .. note
-
If you need a precise measurement for the object temperature, it is absolutely crucial that you also provide a precise emissivity.
The emissivity is stored in non-volatile memory and will still be used after a restart or power cycle of the Bricklet.
149 150 151 152 153 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 149 def set_emissivity(emissivity) check_validity send_request FUNCTION_SET_EMISSIVITY, [emissivity], 'S', 8, '' end |
#set_object_temperature_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_OBJECT_TEMPERATURE callback is triggered periodically. A value of 0 turns the callback off.
The CALLBACK_OBJECT_TEMPERATURE callback is only triggered if the temperature has changed since the last triggering.
185 186 187 188 189 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 185 def set_object_temperature_callback_period(period) check_validity send_request FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 8, '' end |
#set_object_temperature_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_OBJECT_TEMPERATURE_REACHED callback.
The following options are possible:
"Option", "Description"
"'x'", "Callback is turned off"
"'o'", "Callback is triggered when the object temperature is *outside* the min and max values"
"'i'", "Callback is triggered when the object temperature is *inside* the min and max values"
"'<'", "Callback is triggered when the object temperature is smaller than the min value (max is ignored)"
"'>'", "Callback is triggered when the object temperature is greater than the min value (max is ignored)"
233 234 235 236 237 |
# File 'lib/tinkerforge/bricklet_temperature_ir.rb', line 233 def set_object_temperature_callback_threshold(option, min, max) check_validity send_request FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, '' end |