..
 #############################################################
 # 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-tcpip">Software</a> / TCP/IP - PTC Bricklet

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

.. _ptc_bricklet_tcpip:

TCP/IP - PTC Bricklet
=====================

This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`PTC Bricklet <ptc_bricklet>`. General information and technical
specifications for the PTC Bricklet are summarized in its :ref:`hardware description
<ptc_bricklet_description>`.

.. _ptc_bricklet_tcpip_api:

API
---

A general description of the TCP/IP protocol structure can be found
:ref:`here <llproto_tcpip>`.




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



.. tcpip:function:: BrickletPTC.get_temperature

 :functionid: 1
 :emptyrequest: empty payload

 :response temperature: int32

 Returns the temperature of connected sensor. The value
 has a range of -246 to 849 °C 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 :tcpip:func:`CALLBACK_TEMPERATURE <BrickletPTC.CALLBACK_TEMPERATURE>` and set the period with 
 :tcpip:func:`set_temperature_callback_period <BrickletPTC.set_temperature_callback_period>`.
 
.. tcpip:function:: BrickletPTC.is_sensor_connected

 :functionid: 19
 :emptyrequest: empty payload

 :response connected: bool

 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.
 
.. tcpip:function:: BrickletPTC.set_wire_mode

 :functionid: 20
 :request mode: uint8

 :noresponse: no response

 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.
 
 The default value is 2 = 2-wire.
 
.. tcpip:function:: BrickletPTC.get_wire_mode

 :functionid: 21
 :emptyrequest: empty payload

 :response mode: uint8

 Returns the wire mode as set by :tcpip:func:`set_wire_mode <BrickletPTC.set_wire_mode>`
 


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

.. tcpip:function:: BrickletPTC.get_resistance

 :functionid: 2
 :emptyrequest: empty payload

 :response resistance: uint16

 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 callback :tcpip:func:`CALLBACK_RESISTANCE <BrickletPTC.CALLBACK_RESISTANCE>` and set the period with 
 :tcpip:func:`set_resistance_callback_period <BrickletPTC.set_resistance_callback_period>`.
 
.. tcpip:function:: BrickletPTC.set_noise_rejection_filter

 :functionid: 17
 :request filter: uint8

 :noresponse: no response

 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.
 
 Default value is 0 = 50Hz.
 
.. tcpip:function:: BrickletPTC.get_noise_rejection_filter

 :functionid: 18
 :emptyrequest: empty payload

 :response filter: uint8

 Returns the noise rejection filter option as set by 
 :tcpip:func:`set_noise_rejection_filter <BrickletPTC.set_noise_rejection_filter>`
 
.. tcpip:function:: BrickletPTC.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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletPTC.set_temperature_callback_period

 :functionid: 3
 :request period: uint32

 :noresponse: no response

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

 :functionid: 4
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_temperature_callback_period <BrickletPTC.set_temperature_callback_period>`.
 
.. tcpip:function:: BrickletPTC.set_resistance_callback_period

 :functionid: 5
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_RESISTANCE <BrickletPTC.CALLBACK_RESISTANCE>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :tcpip:func:`CALLBACK_RESISTANCE <BrickletPTC.CALLBACK_RESISTANCE>` is only triggered if the resistance has changed since the
 last triggering.
 
 The default value is 0.
 
.. tcpip:function:: BrickletPTC.get_resistance_callback_period

 :functionid: 6
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_resistance_callback_period <BrickletPTC.set_resistance_callback_period>`.
 
.. tcpip:function:: BrickletPTC.set_temperature_callback_threshold

 :functionid: 7
 :request option: char
 :request min: int32
 :request max: int32

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_TEMPERATURE_REACHED <BrickletPTC.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).
 
.. tcpip:function:: BrickletPTC.get_temperature_callback_threshold

 :functionid: 8
 :emptyrequest: empty payload

 :response option: char
 :response min: int32
 :response max: int32

 Returns the threshold as set by :tcpip:func:`set_temperature_callback_threshold <BrickletPTC.set_temperature_callback_threshold>`.
 
.. tcpip:function:: BrickletPTC.set_resistance_callback_threshold

 :functionid: 9
 :request option: char
 :request min: uint16
 :request max: uint16

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_RESISTANCE_REACHED <BrickletPTC.CALLBACK_RESISTANCE_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).
 
.. tcpip:function:: BrickletPTC.get_resistance_callback_threshold

 :functionid: 10
 :emptyrequest: empty payload

 :response option: char
 :response min: uint16
 :response max: uint16

 Returns the threshold as set by :tcpip:func:`set_resistance_callback_threshold <BrickletPTC.set_resistance_callback_threshold>`.
 
.. tcpip:function:: BrickletPTC.set_debounce_period

 :functionid: 11
 :request debounce: uint32

 :noresponse: no response

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

 :functionid: 12
 :emptyrequest: empty payload

 :response debounce: uint32

 Returns the debounce period as set by :tcpip:func:`set_debounce_period <BrickletPTC.set_debounce_period>`.
 


.. _ptc_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletPTC.CALLBACK_TEMPERATURE

 :functionid: 13

 :response temperature: int32


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

 :functionid: 14

 :response temperature: int32


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

 :functionid: 15

 :response resistance: uint16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_resistance_callback_period <BrickletPTC.set_resistance_callback_period>`. The response value is the resistance
 of the connected sensor.
 
 :tcpip:func:`CALLBACK_RESISTANCE <BrickletPTC.CALLBACK_RESISTANCE>` is only triggered if the resistance has changed since the
 last triggering.
 
.. tcpip:function:: BrickletPTC.CALLBACK_RESISTANCE_REACHED

 :functionid: 16

 :response resistance: uint16


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_resistance_callback_threshold <BrickletPTC.set_resistance_callback_threshold>` is reached.
 The response value is the resistance of the connected sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletPTC.set_debounce_period>`.
 


