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

:orphan:
:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-tcpip">Software</a> / TCP/IP - Analog In Bricklet 2.0

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

.. _analog_in_v2_bricklet_tcpip:

TCP/IP - Analog In Bricklet 2.0
===============================

.. note::
 This Bricklet is currently in the prototype stage and the software/hardware
 as well as the documentation is in an incomplete state.


This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`Analog In Bricklet 2.0 <analog_in_v2_bricklet>`. General information and technical
specifications for the Analog In Bricklet 2.0 are summarized in its :ref:`hardware description
<analog_in_v2_bricklet_description>`.

.. _analog_in_v2_bricklet_tcpip_api:

API
---

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




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



.. tcpip:function:: BrickletAnalogInV2.get_voltage

 :functionid: 1
 :emptyrequest: empty payload

 :response voltage: uint16

 Returns the measured voltage. The value is in mV and
 between 0V and 42V. The resolution is approximately 10mV.
 
 If you want to get the voltage periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_VOLTAGE <BrickletAnalogInV2.CALLBACK_VOLTAGE>` and set the period with
 :tcpip:func:`set_voltage_callback_period <BrickletAnalogInV2.set_voltage_callback_period>`.
 


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

.. tcpip:function:: BrickletAnalogInV2.get_analog_value

 :functionid: 2
 :emptyrequest: empty payload

 :response value: uint16

 Returns the value as read by a 12-bit analog-to-digital converter.
 The value is between 0 and 4095.
 
 If you want the analog value periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_ANALOG_VALUE <BrickletAnalogInV2.CALLBACK_ANALOG_VALUE>` and set the period with
 :tcpip:func:`set_analog_value_callback_period <BrickletAnalogInV2.set_analog_value_callback_period>`.
 
.. tcpip:function:: BrickletAnalogInV2.set_moving_average

 :functionid: 13
 :request average: uint8

 :noresponse: no response

 Sets the length of a `moving averaging <http://en.wikipedia.org/wiki/Moving_average>`__
 for the moisture value.
 
 Setting the length to 1 will turn the averaging off. With less
 averaging, there is more noise on the data.
 
 The range for the averaging is 1-50.
 
 The default value is 50.
 
.. tcpip:function:: BrickletAnalogInV2.get_moving_average

 :functionid: 14
 :emptyrequest: empty payload

 :response average: uint8

 Returns the length of the moving average as set by :tcpip:func:`set_moving_average <BrickletAnalogInV2.set_moving_average>`.
 
.. tcpip:function:: BrickletAnalogInV2.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:: BrickletAnalogInV2.set_voltage_callback_period

 :functionid: 3
 :request period: uint32

 :noresponse: no response

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

 :functionid: 4
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_voltage_callback_period <BrickletAnalogInV2.set_voltage_callback_period>`.
 
.. tcpip:function:: BrickletAnalogInV2.set_analog_value_callback_period

 :functionid: 5
 :request period: uint32

 :noresponse: no response

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

 :functionid: 6
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_analog_value_callback_period <BrickletAnalogInV2.set_analog_value_callback_period>`.
 
.. tcpip:function:: BrickletAnalogInV2.set_voltage_callback_threshold

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

 :noresponse: no response

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

 :functionid: 8
 :emptyrequest: empty payload

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

 Returns the threshold as set by :tcpip:func:`set_voltage_callback_threshold <BrickletAnalogInV2.set_voltage_callback_threshold>`.
 
.. tcpip:function:: BrickletAnalogInV2.set_analog_value_callback_threshold

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

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_ANALOG_VALUE_REACHED <BrickletAnalogInV2.CALLBACK_ANALOG_VALUE_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 analog value is *outside* the min and max values"
  "'i'",    "Callback is triggered when the analog value is *inside* the min and max values"
  "'<'",    "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the analog value is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletAnalogInV2.get_analog_value_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_analog_value_callback_threshold <BrickletAnalogInV2.set_analog_value_callback_threshold>`.
 
.. tcpip:function:: BrickletAnalogInV2.set_debounce_period

 :functionid: 11
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callbacks
 
 * :tcpip:func:`CALLBACK_VOLTAGE_REACHED <BrickletAnalogInV2.CALLBACK_VOLTAGE_REACHED>`,
 * :tcpip:func:`CALLBACK_ANALOG_VALUE_REACHED <BrickletAnalogInV2.CALLBACK_ANALOG_VALUE_REACHED>`
 
 are triggered, if the thresholds
 
 * :tcpip:func:`set_voltage_callback_threshold <BrickletAnalogInV2.set_voltage_callback_threshold>`,
 * :tcpip:func:`set_analog_value_callback_threshold <BrickletAnalogInV2.set_analog_value_callback_threshold>`
 
 keep being reached.
 
 The default value is 100.
 
.. tcpip:function:: BrickletAnalogInV2.get_debounce_period

 :functionid: 12
 :emptyrequest: empty payload

 :response debounce: uint32

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


.. _analog_in_v2_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletAnalogInV2.CALLBACK_VOLTAGE

 :functionid: 15

 :response voltage: uint16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_voltage_callback_period <BrickletAnalogInV2.set_voltage_callback_period>`. The response value is the voltage of the
 sensor.
 
 :tcpip:func:`CALLBACK_VOLTAGE <BrickletAnalogInV2.CALLBACK_VOLTAGE>` is only triggered if the voltage has changed since the
 last triggering.
 
.. tcpip:function:: BrickletAnalogInV2.CALLBACK_ANALOG_VALUE

 :functionid: 16

 :response value: uint16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_analog_value_callback_period <BrickletAnalogInV2.set_analog_value_callback_period>`. The response value is the analog value of the
 sensor.
 
 :tcpip:func:`CALLBACK_ANALOG_VALUE <BrickletAnalogInV2.CALLBACK_ANALOG_VALUE>` is only triggered if the voltage has changed since the
 last triggering.
 
.. tcpip:function:: BrickletAnalogInV2.CALLBACK_VOLTAGE_REACHED

 :functionid: 17

 :response voltage: uint16


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_voltage_callback_threshold <BrickletAnalogInV2.set_voltage_callback_threshold>` is reached.
 The response value is the voltage of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletAnalogInV2.set_debounce_period>`.
 
.. tcpip:function:: BrickletAnalogInV2.CALLBACK_ANALOG_VALUE_REACHED

 :functionid: 18

 :response value: uint16


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


