class Tinkerforge::BrickletTemperatureIR

Measures contactless object temperature between -70°C and +380°C

Constants

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.

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.

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.

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.

Public Class Methods

new(uid, ipcon) click to toggle source

Creates an object with the unique device ID uid and adds it to the IP Connection ipcon.

Calls superclass method
# File lib/tinkerforge/bricklet_temperature_ir.rb, line 75
def initialize(uid, ipcon)
  super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME

  @api_version = [2, 0, 0]

  @response_expected[FUNCTION_GET_AMBIENT_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_OBJECT_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_EMISSIVITY] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_EMISSIVITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE

  @callback_formats[CALLBACK_AMBIENT_TEMPERATURE] = [10, 's']
  @callback_formats[CALLBACK_OBJECT_TEMPERATURE] = [10, 's']
  @callback_formats[CALLBACK_AMBIENT_TEMPERATURE_REACHED] = [10, 's']
  @callback_formats[CALLBACK_OBJECT_TEMPERATURE_REACHED] = [10, 's']

  @ipcon.add_device self
end

Public Instance Methods

get_ambient_temperature() click to toggle source

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.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 109
def get_ambient_temperature
  check_validity

  send_request FUNCTION_GET_AMBIENT_TEMPERATURE, [], '', 10, 's'
end
get_ambient_temperature_callback_period() click to toggle source

Returns the period as set by BrickletTemperatureIR#set_ambient_temperature_callback_period.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 173
def get_ambient_temperature_callback_period
  check_validity

  send_request FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD, [], '', 12, 'L'
end
get_ambient_temperature_callback_threshold() click to toggle source

Returns the threshold as set by BrickletTemperatureIR#set_ambient_temperature_callback_threshold.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 215
def get_ambient_temperature_callback_threshold
  check_validity

  send_request FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
end
get_debounce_period() click to toggle source

Returns the debounce period as set by BrickletTemperatureIR#set_debounce_period.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 263
def get_debounce_period
  check_validity

  send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
end
get_emissivity() click to toggle source

Returns the emissivity as set by BrickletTemperatureIR#set_emissivity.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 155
def get_emissivity
  check_validity

  send_request FUNCTION_GET_EMISSIVITY, [], '', 10, 'S'
end
get_identity() click to toggle source

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|

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 279
def get_identity
  send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
end
get_object_temperature() click to toggle source

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 <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.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 125
def get_object_temperature
  check_validity

  send_request FUNCTION_GET_OBJECT_TEMPERATURE, [], '', 10, 's'
end
get_object_temperature_callback_period() click to toggle source

Returns the period as set by BrickletTemperatureIR#set_object_temperature_callback_period.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 191
def get_object_temperature_callback_period
  check_validity

  send_request FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, [], '', 12, 'L'
end
get_object_temperature_callback_threshold() click to toggle source

Returns the threshold as set by BrickletTemperatureIR#set_object_temperature_callback_threshold.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 239
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) click to toggle source

Registers a callback with ID id to the block block.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 284
def register_callback(id, &block)
  callback = block
  @registered_callbacks[id] = callback
end
set_ambient_temperature_callback_period(period) click to toggle source

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.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 166
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) click to toggle source

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)"
# File lib/tinkerforge/bricklet_temperature_ir.rb, line 208
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) click to toggle source

Sets the period with which the threshold callbacks

are triggered, if the thresholds

keep being reached.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 256
def set_debounce_period(debounce)
  check_validity

  send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
end
set_emissivity(emissivity) click to toggle source

Sets the `emissivity <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 <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.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 148
def set_emissivity(emissivity)
  check_validity

  send_request FUNCTION_SET_EMISSIVITY, [emissivity], 'S', 8, ''
end
set_object_temperature_callback_period(period) click to toggle source

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.

# File lib/tinkerforge/bricklet_temperature_ir.rb, line 184
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) click to toggle source

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)"
# File lib/tinkerforge/bricklet_temperature_ir.rb, line 232
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