..
 #############################################################
 # 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 - Barometer Bricklet

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

.. _barometer_bricklet_tcpip:

TCP/IP - Barometer Bricklet
===========================

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

.. _barometer_bricklet_tcpip_api:

API
---

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




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



.. tcpip:function:: BrickletBarometer.get_air_pressure

 :functionid: 1
 :emptyrequest: empty payload

 :response air_pressure: int32

 Returns the air pressure of the air pressure sensor. The value
 has a range of 10000 to 1200000 and is given in mbar/1000, i.e. a value
 of 1001092 means that an air pressure of 1001.092 mbar is measured.
 
 If you want to get the air pressure periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_AIR_PRESSURE <BrickletBarometer.CALLBACK_AIR_PRESSURE>` and set the period with
 :tcpip:func:`set_air_pressure_callback_period <BrickletBarometer.set_air_pressure_callback_period>`.
 
.. tcpip:function:: BrickletBarometer.get_altitude

 :functionid: 2
 :emptyrequest: empty payload

 :response altitude: int32

 Returns the relative altitude of the air pressure sensor. The value is given in
 cm and is calculated based on the difference between the current air pressure
 and the reference air pressure that can be set with :tcpip:func:`set_reference_air_pressure <BrickletBarometer.set_reference_air_pressure>`.
 
 If you want to get the altitude periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_ALTITUDE <BrickletBarometer.CALLBACK_ALTITUDE>` and set the period with
 :tcpip:func:`set_altitude_callback_period <BrickletBarometer.set_altitude_callback_period>`.
 
.. tcpip:function:: BrickletBarometer.set_reference_air_pressure

 :functionid: 13
 :request air_pressure: int32

 :noresponse: no response

 Sets the reference air pressure in mbar/1000 for the altitude calculation.
 Setting the reference to the current air pressure results in a calculated
 altitude of 0cm. Passing 0 is a shortcut for passing the current air pressure as
 reference.
 
 Well known reference values are the Q codes
 `QNH <http://en.wikipedia.org/wiki/QNH>`__ and
 `QFE <http://en.wikipedia.org/wiki/Mean_sea_level_pressure#Mean_sea_level_pressure>`__
 used in aviation.
 
 The default value is 1013.25mbar.
 
.. tcpip:function:: BrickletBarometer.get_reference_air_pressure

 :functionid: 19
 :emptyrequest: empty payload

 :response air_pressure: int32

 Returns the reference air pressure as set by :tcpip:func:`set_reference_air_pressure <BrickletBarometer.set_reference_air_pressure>`.
 


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

.. tcpip:function:: BrickletBarometer.get_chip_temperature

 :functionid: 14
 :emptyrequest: empty payload

 :response temperature: int16

 Returns the temperature of the air pressure sensor. The value
 has a range of -4000 to 8500 and is given in °C/100, i.e. a value
 of 2007 means that a temperature of 20.07 °C is measured.
 
 This temperature is used internally for temperature compensation of the air
 pressure measurement. It is not as accurate as the temperature measured by the
 :ref:`temperature_bricklet` or the :ref:`temperature_ir_bricklet`.
 
.. tcpip:function:: BrickletBarometer.set_averaging

 :functionid: 20
 :request moving_average_pressure: uint8
 :request average_pressure: uint8
 :request average_temperature: uint8

 :noresponse: no response

 Sets the different averaging parameters. It is possible to set
 the length of a normal averaging for the temperature and pressure,
 as well as an additional length of a 
 `moving average <http://en.wikipedia.org/wiki/Moving_average>`__ 
 for the pressure. The moving average is calculated from the normal 
 averages.  There is no moving average for the temperature.
 
 The maximum length for the pressure average is 10, for the
 temperature average is 255 and for the moving average is 25.
 
 Setting the all three parameters to 0 will turn the averaging
 completely off. If the averaging is off, there is lots of noise
 on the data, but the data is without delay. Thus we recommend
 to turn the averaging off if the Barometer Bricklet data is
 to be used for sensor fusion with other sensors.
 
 The default values are 10 for the normal averages and 25 for the
 moving average.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletBarometer.get_averaging

 :functionid: 21
 :emptyrequest: empty payload

 :response moving_average_pressure: uint8
 :response average_pressure: uint8
 :response average_temperature: uint8

 Returns the averaging configuration as set by :tcpip:func:`set_averaging <BrickletBarometer.set_averaging>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletBarometer.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:: BrickletBarometer.set_air_pressure_callback_period

 :functionid: 3
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_AIR_PRESSURE <BrickletBarometer.CALLBACK_AIR_PRESSURE>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :tcpip:func:`CALLBACK_AIR_PRESSURE <BrickletBarometer.CALLBACK_AIR_PRESSURE>` is only triggered if the air pressure has changed since the
 last triggering.
 
 The default value is 0.
 
.. tcpip:function:: BrickletBarometer.get_air_pressure_callback_period

 :functionid: 4
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_air_pressure_callback_period <BrickletBarometer.set_air_pressure_callback_period>`.
 
.. tcpip:function:: BrickletBarometer.set_altitude_callback_period

 :functionid: 5
 :request period: uint32

 :noresponse: no response

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

 :functionid: 6
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_altitude_callback_period <BrickletBarometer.set_altitude_callback_period>`.
 
.. tcpip:function:: BrickletBarometer.set_air_pressure_callback_threshold

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

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_AIR_PRESSURE_REACHED <BrickletBarometer.CALLBACK_AIR_PRESSURE_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 air pressure is *outside* the min and max values"
  "'i'",    "Callback is triggered when the air pressure is *inside* the min and max values"
  "'<'",    "Callback is triggered when the air pressure is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the air pressure is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletBarometer.get_air_pressure_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_air_pressure_callback_threshold <BrickletBarometer.set_air_pressure_callback_threshold>`.
 
.. tcpip:function:: BrickletBarometer.set_altitude_callback_threshold

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

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_ALTITUDE_REACHED <BrickletBarometer.CALLBACK_ALTITUDE_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 altitude is *outside* the min and max values"
  "'i'",    "Callback is triggered when the altitude is *inside* the min and max values"
  "'<'",    "Callback is triggered when the altitude is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the altitude is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletBarometer.get_altitude_callback_threshold

 :functionid: 10
 :emptyrequest: empty payload

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

 Returns the threshold as set by :tcpip:func:`set_altitude_callback_threshold <BrickletBarometer.set_altitude_callback_threshold>`.
 
.. tcpip:function:: BrickletBarometer.set_debounce_period

 :functionid: 11
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callbacks
 
 * :tcpip:func:`CALLBACK_AIR_PRESSURE_REACHED <BrickletBarometer.CALLBACK_AIR_PRESSURE_REACHED>`,
 * :tcpip:func:`CALLBACK_ALTITUDE_REACHED <BrickletBarometer.CALLBACK_ALTITUDE_REACHED>`
 
 are triggered, if the thresholds
 
 * :tcpip:func:`set_air_pressure_callback_threshold <BrickletBarometer.set_air_pressure_callback_threshold>`,
 * :tcpip:func:`set_altitude_callback_threshold <BrickletBarometer.set_altitude_callback_threshold>`
 
 keep being reached.
 
 The default value is 100.
 
.. tcpip:function:: BrickletBarometer.get_debounce_period

 :functionid: 12
 :emptyrequest: empty payload

 :response debounce: uint32

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


.. _barometer_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletBarometer.CALLBACK_AIR_PRESSURE

 :functionid: 15

 :response air_pressure: int32


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_air_pressure_callback_period <BrickletBarometer.set_air_pressure_callback_period>`. The response value is the air pressure of the
 air pressure sensor.
 
 :tcpip:func:`CALLBACK_AIR_PRESSURE <BrickletBarometer.CALLBACK_AIR_PRESSURE>` is only triggered if the air pressure has changed since the
 last triggering.
 
.. tcpip:function:: BrickletBarometer.CALLBACK_ALTITUDE

 :functionid: 16

 :response altitude: int32


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_altitude_callback_period <BrickletBarometer.set_altitude_callback_period>`. The response value is the altitude of the
 air pressure sensor.
 
 :tcpip:func:`CALLBACK_ALTITUDE <BrickletBarometer.CALLBACK_ALTITUDE>` is only triggered if the altitude has changed since the
 last triggering.
 
.. tcpip:function:: BrickletBarometer.CALLBACK_AIR_PRESSURE_REACHED

 :functionid: 17

 :response air_pressure: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_air_pressure_callback_threshold <BrickletBarometer.set_air_pressure_callback_threshold>` is reached.
 The response value is the air pressure of the air pressure sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletBarometer.set_debounce_period>`.
 
.. tcpip:function:: BrickletBarometer.CALLBACK_ALTITUDE_REACHED

 :functionid: 18

 :response altitude: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_altitude_callback_threshold <BrickletBarometer.set_altitude_callback_threshold>` is reached.
 The response value is the altitude of the air pressure sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletBarometer.set_debounce_period>`.
 


