..
 #############################################################
 # 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 - Voltage/Current Bricklet

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

.. _voltage_current_bricklet_tcpip:

TCP/IP - Voltage/Current Bricklet
=================================

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

.. _voltage_current_bricklet_tcpip_api:

API
---

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




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



.. tcpip:function:: BrickletVoltageCurrent.get_current

 :functionid: 1
 :emptyrequest: empty payload

 :response current: int32

 Returns the current. The value is in mA
 and between -20000mA and 20000mA.
 
 If you want to get the current periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_CURRENT <BrickletVoltageCurrent.CALLBACK_CURRENT>` and set the period with 
 :tcpip:func:`set_current_callback_period <BrickletVoltageCurrent.set_current_callback_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.get_voltage

 :functionid: 2
 :emptyrequest: empty payload

 :response voltage: int32

 Returns the voltage. The value is in mV
 and between 0mV and 36000mV.
 
 If you want to get the voltage periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_VOLTAGE <BrickletVoltageCurrent.CALLBACK_VOLTAGE>` and set the period with 
 :tcpip:func:`set_voltage_callback_period <BrickletVoltageCurrent.set_voltage_callback_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.get_power

 :functionid: 3
 :emptyrequest: empty payload

 :response power: int32

 Returns the power. The value is in mW
 and between 0mV and 720000mW.
 
 If you want to get the power periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_POWER <BrickletVoltageCurrent.CALLBACK_POWER>` and set the period with 
 :tcpip:func:`set_power_callback_period <BrickletVoltageCurrent.set_power_callback_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_configuration

 :functionid: 4
 :request averaging: uint8
 :request voltage_conversion_time: uint8
 :request current_conversion_time: uint8

 :noresponse: no response

 Sets the configuration of the Voltage/Current Bricklet. It is
 possible to configure number of averages as well as
 voltage and current conversion time.
 
 Averaging:
 
 .. csv-table::
  :header: "Value", "Number of Averages"
  :widths: 20, 20
 
  "0",    "1"
  "1",    "4"
  "2",    "16"
  "3",    "64"
  "4",    "128"
  "5",    "256"
  "6",    "512"
  ">=7",  "1024"
 
 Voltage/Current conversion:
 
 .. csv-table::
  :header: "Value", "Conversion time"
  :widths: 20, 20
 
  "0",    "140µs"
  "1",    "204µs"
  "2",    "332µs"
  "3",    "588µs"
  "4",    "1.1ms"
  "5",    "2.116ms"
  "6",    "4.156ms"
  ">=7",  "8.244ms"
 
 The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage 
 conversion and current conversion.
 
.. tcpip:function:: BrickletVoltageCurrent.get_configuration

 :functionid: 5
 :emptyrequest: empty payload

 :response averaging: uint8
 :response voltage_conversion_time: uint8
 :response current_conversion_time: uint8

 Returns the configuration as set by :tcpip:func:`set_configuration <BrickletVoltageCurrent.set_configuration>`.
 


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

.. tcpip:function:: BrickletVoltageCurrent.set_calibration

 :functionid: 6
 :request gain_multiplier: uint16
 :request gain_divisor: uint16

 :noresponse: no response

 Since the shunt resistor that is used to measure the current is not
 perfectly precise, it needs to be calibrated by a multiplier and
 divisor if a very precise reading is needed.
 
 For example, if you are expecting a measurement of 1000mA and you
 are measuring 1023mA, you can calibrate the Voltage/Current Bricklet 
 by setting the multiplier to 1000 and the divisor to 1023.
 
.. tcpip:function:: BrickletVoltageCurrent.get_calibration

 :functionid: 7
 :emptyrequest: empty payload

 :response gain_multiplier: uint16
 :response gain_divisor: uint16

 Returns the calibration as set by :tcpip:func:`set_calibration <BrickletVoltageCurrent.set_calibration>`.
 
.. tcpip:function:: BrickletVoltageCurrent.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:: BrickletVoltageCurrent.set_current_callback_period

 :functionid: 8
 :request period: uint32

 :noresponse: no response

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

 :functionid: 9
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_current_callback_period <BrickletVoltageCurrent.set_current_callback_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_voltage_callback_period

 :functionid: 10
 :request period: uint32

 :noresponse: no response

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

 :functionid: 11
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_voltage_callback_period <BrickletVoltageCurrent.set_voltage_callback_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_power_callback_period

 :functionid: 12
 :request period: uint32

 :noresponse: no response

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

 :functionid: 13
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`get_power_callback_period <BrickletVoltageCurrent.get_power_callback_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_current_callback_threshold

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

 :noresponse: no response

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

 :functionid: 15
 :emptyrequest: empty payload

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

 Returns the threshold as set by :tcpip:func:`set_current_callback_threshold <BrickletVoltageCurrent.set_current_callback_threshold>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_voltage_callback_threshold

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

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_VOLTAGE_REACHED <BrickletVoltageCurrent.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:: BrickletVoltageCurrent.get_voltage_callback_threshold

 :functionid: 17
 :emptyrequest: empty payload

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

 Returns the threshold as set by :tcpip:func:`set_voltage_callback_threshold <BrickletVoltageCurrent.set_voltage_callback_threshold>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_power_callback_threshold

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

 :noresponse: no response

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

 :functionid: 19
 :emptyrequest: empty payload

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

 Returns the threshold as set by :tcpip:func:`set_power_callback_threshold <BrickletVoltageCurrent.set_power_callback_threshold>`.
 
.. tcpip:function:: BrickletVoltageCurrent.set_debounce_period

 :functionid: 20
 :request debounce: uint32

 :noresponse: no response

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

 :functionid: 21
 :emptyrequest: empty payload

 :response debounce: uint32

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


.. _voltage_current_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletVoltageCurrent.CALLBACK_CURRENT

 :functionid: 22

 :response current: int32


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

 :functionid: 23

 :response voltage: int32


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

 :functionid: 24

 :response power: int32


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_power_callback_period <BrickletVoltageCurrent.set_power_callback_period>`. The response value is the power of the
 sensor.
 
 :tcpip:func:`CALLBACK_POWER <BrickletVoltageCurrent.CALLBACK_POWER>` is only triggered if the power has changed since the
 last triggering.
 
.. tcpip:function:: BrickletVoltageCurrent.CALLBACK_CURRENT_REACHED

 :functionid: 25

 :response current: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_current_callback_threshold <BrickletVoltageCurrent.set_current_callback_threshold>` is reached.
 The response value is the current 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 <BrickletVoltageCurrent.set_debounce_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.CALLBACK_VOLTAGE_REACHED

 :functionid: 26

 :response voltage: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_voltage_callback_threshold <BrickletVoltageCurrent.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 <BrickletVoltageCurrent.set_debounce_period>`.
 
.. tcpip:function:: BrickletVoltageCurrent.CALLBACK_POWER_REACHED

 :functionid: 27

 :response power: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_power_callback_threshold <BrickletVoltageCurrent.set_power_callback_threshold>` is reached.
 The response value is the power 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 <BrickletVoltageCurrent.set_debounce_period>`.
 


