..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################


:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-modbus">Software</a> / Modbus - Temperature Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _temperature_bricklet_modbus:

Modbus - Temperature Bricklet
=============================

This is the description of the :ref:`Modbus protocol <llproto_modbus>` for the :ref:`Temperature Bricklet <temperature_bricklet>`. General information and technical
specifications for the Temperature Bricklet are summarized in its :ref:`hardware description
<temperature_bricklet_description>`.

.. _temperature_bricklet_modbus_api:

API
---

A general description of the Modbus protocol structure can be found
:ref:`here <llproto_modbus>`.




Basic Functions
^^^^^^^^^^^^^^^



.. modbus:function:: BrickletTemperature.get_temperature

 :functionid: 1
 :emptyrequest: empty payload

 :response temperature: int16

 Returns the temperature of the sensor. The value
 has a range of -2500 to 8500 and is given in °C/100,
 e.g. a value of 4223 means that a temperature of 42.23 °C is measured.
 
 If you want to get the temperature periodically, it is recommended 
 to use the callback :modbus:func:`CALLBACK_TEMPERATURE <BrickletTemperature.CALLBACK_TEMPERATURE>` and set the period with 
 :modbus:func:`set_temperature_callback_period <BrickletTemperature.set_temperature_callback_period>`.
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. modbus:function:: BrickletTemperature.set_i2c_mode

 :functionid: 10
 :request mode: uint8

 :noresponse: no response

 Sets the I2C mode. Possible modes are:
 
 * 0: Fast (400kHz, default)
 * 1: Slow (100kHz)
 
 If you have problems with obvious outliers in the
 Temperature Bricklet measurements, they may be caused by EMI issues.
 In this case it may be helpful to lower the I2C speed.
 
 It is however not recommended to lower the I2C speed in applications where
 a high throughput needs to be achieved.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. modbus:function:: BrickletTemperature.get_i2c_mode

 :functionid: 11
 :emptyrequest: empty payload

 :response mode: uint8

 Returns the I2C mode as set by :modbus:func:`set_i2c_mode <BrickletTemperature.set_i2c_mode>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. modbus:function:: BrickletTemperature.get_identity

 :functionid: 255
 :emptyrequest: empty payload

 :response uid: char[8]
 :response connected_uid: char[8]
 :response position: char
 :response hardware_version: uint8[3]
 :response firmware_version: uint8[3]
 :response device_identifier: uint16

 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 :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


Callback Configuration Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. modbus:function:: BrickletTemperature.set_temperature_callback_period

 :functionid: 2
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :modbus:func:`CALLBACK_TEMPERATURE <BrickletTemperature.CALLBACK_TEMPERATURE>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :modbus:func:`CALLBACK_TEMPERATURE <BrickletTemperature.CALLBACK_TEMPERATURE>` is only triggered if the temperature has changed since the
 last triggering.
 
 The default value is 0.
 
.. modbus:function:: BrickletTemperature.get_temperature_callback_period

 :functionid: 3
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :modbus:func:`set_temperature_callback_period <BrickletTemperature.set_temperature_callback_period>`.
 
.. modbus:function:: BrickletTemperature.set_temperature_callback_threshold

 :functionid: 4
 :request option: char
 :request min: int16
 :request max: int16

 :noresponse: no response

 Sets the thresholds for the :modbus:func:`CALLBACK_TEMPERATURE_REACHED <BrickletTemperature.CALLBACK_TEMPERATURE_REACHED>` callback. 
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'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)"
 
 The default value is ('x', 0, 0).
 
.. modbus:function:: BrickletTemperature.get_temperature_callback_threshold

 :functionid: 5
 :emptyrequest: empty payload

 :response option: char
 :response min: int16
 :response max: int16

 Returns the threshold as set by :modbus:func:`set_temperature_callback_threshold <BrickletTemperature.set_temperature_callback_threshold>`.
 
.. modbus:function:: BrickletTemperature.set_debounce_period

 :functionid: 6
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callback
 
 * :modbus:func:`CALLBACK_TEMPERATURE_REACHED <BrickletTemperature.CALLBACK_TEMPERATURE_REACHED>`
 
 is triggered, if the threshold
 
 * :modbus:func:`set_temperature_callback_threshold <BrickletTemperature.set_temperature_callback_threshold>`
 
 keeps being reached.
 
 The default value is 100.
 
.. modbus:function:: BrickletTemperature.get_debounce_period

 :functionid: 7
 :emptyrequest: empty payload

 :response debounce: uint32

 Returns the debounce period as set by :modbus:func:`set_debounce_period <BrickletTemperature.set_debounce_period>`.
 


.. _temperature_bricklet_modbus_callbacks:

Callbacks
^^^^^^^^^

.. modbus:function:: BrickletTemperature.CALLBACK_TEMPERATURE

 :functionid: 8

 :response temperature: int16


 This callback is triggered periodically with the period that is set by
 :modbus:func:`set_temperature_callback_period <BrickletTemperature.set_temperature_callback_period>`. The response value is the temperature
 of the sensor.
 
 :modbus:func:`CALLBACK_TEMPERATURE <BrickletTemperature.CALLBACK_TEMPERATURE>` is only triggered if the temperature has changed since the
 last triggering.
 
.. modbus:function:: BrickletTemperature.CALLBACK_TEMPERATURE_REACHED

 :functionid: 9

 :response temperature: int16


 This callback is triggered when the threshold as set by
 :modbus:func:`set_temperature_callback_threshold <BrickletTemperature.set_temperature_callback_threshold>` is reached.
 The response value is the temperature of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :modbus:func:`set_debounce_period <BrickletTemperature.set_debounce_period>`.
 


