Package com.tinkerforge
Class BrickletThermocouple
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletThermocouple
-
public class BrickletThermocouple extends Device
Measures temperature with thermocouples
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletThermocouple.Configuration
class
BrickletThermocouple.ErrorState
static interface
BrickletThermocouple.ErrorStateListener
This Listener is triggered every time the error state changes (seegetErrorState()
).class
BrickletThermocouple.TemperatureCallbackThreshold
static interface
BrickletThermocouple.TemperatureListener
This listener is triggered periodically with the period that is set bysetTemperatureCallbackPeriod(long)
.static interface
BrickletThermocouple.TemperatureReachedListener
This listener is triggered when the threshold as set bysetTemperatureCallbackThreshold(char, int, int)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletThermocouple(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addErrorStateListener(BrickletThermocouple.ErrorStateListener listener)
Adds a ErrorState listener.void
addTemperatureListener(BrickletThermocouple.TemperatureListener listener)
Adds a Temperature listener.void
addTemperatureReachedListener(BrickletThermocouple.TemperatureReachedListener listener)
Adds a TemperatureReached listener.BrickletThermocouple.Configuration
getConfiguration()
Returns the configuration as set bysetConfiguration(short, short, short)
.long
getDebouncePeriod()
Returns the debounce period as set bysetDebouncePeriod(long)
.BrickletThermocouple.ErrorState
getErrorState()
Returns the current error state.Device.Identity
getIdentity()
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.int
getTemperature()
Returns the temperature of the thermocouple.long
getTemperatureCallbackPeriod()
Returns the period as set bysetTemperatureCallbackPeriod(long)
.BrickletThermocouple.TemperatureCallbackThreshold
getTemperatureCallbackThreshold()
Returns the threshold as set bysetTemperatureCallbackThreshold(char, int, int)
.void
removeErrorStateListener(BrickletThermocouple.ErrorStateListener listener)
Removes a ErrorState listener.void
removeTemperatureListener(BrickletThermocouple.TemperatureListener listener)
Removes a Temperature listener.void
removeTemperatureReachedListener(BrickletThermocouple.TemperatureReachedListener listener)
Removes a TemperatureReached listener.void
setConfiguration(short averaging, short thermocoupleType, short filter)
You can configure averaging size, thermocouple type and frequency filtering.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener *BrickletThermocouple.TemperatureReachedListener
is triggered, if the threshold *setTemperatureCallbackThreshold(char, int, int)
keeps being reached.void
setTemperatureCallbackPeriod(long period)
Sets the period with which theBrickletThermocouple.TemperatureListener
listener is triggered periodically.void
setTemperatureCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletThermocouple.TemperatureReachedListener
listener.-
Methods inherited from class com.tinkerforge.DeviceBase
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
-
-
-
-
Field Detail
-
DEVICE_IDENTIFIER
public static final int DEVICE_IDENTIFIER
- See Also:
- Constant Field Values
-
DEVICE_DISPLAY_NAME
public static final java.lang.String DEVICE_DISPLAY_NAME
- See Also:
- Constant Field Values
-
FUNCTION_GET_TEMPERATURE
public static final byte FUNCTION_GET_TEMPERATURE
- See Also:
- Constant Field Values
-
FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_CONFIGURATION
public static final byte FUNCTION_SET_CONFIGURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_CONFIGURATION
public static final byte FUNCTION_GET_CONFIGURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_ERROR_STATE
public static final byte FUNCTION_GET_ERROR_STATE
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OFF
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_OUTSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_INSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_SMALLER
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_GREATER
public static final char THRESHOLD_OPTION_GREATER
- See Also:
- Constant Field Values
-
AVERAGING_1
public static final short AVERAGING_1
- See Also:
- Constant Field Values
-
AVERAGING_2
public static final short AVERAGING_2
- See Also:
- Constant Field Values
-
AVERAGING_4
public static final short AVERAGING_4
- See Also:
- Constant Field Values
-
AVERAGING_8
public static final short AVERAGING_8
- See Also:
- Constant Field Values
-
AVERAGING_16
public static final short AVERAGING_16
- See Also:
- Constant Field Values
-
TYPE_B
public static final short TYPE_B
- See Also:
- Constant Field Values
-
TYPE_E
public static final short TYPE_E
- See Also:
- Constant Field Values
-
TYPE_J
public static final short TYPE_J
- See Also:
- Constant Field Values
-
TYPE_K
public static final short TYPE_K
- See Also:
- Constant Field Values
-
TYPE_N
public static final short TYPE_N
- See Also:
- Constant Field Values
-
TYPE_R
public static final short TYPE_R
- See Also:
- Constant Field Values
-
TYPE_S
public static final short TYPE_S
- See Also:
- Constant Field Values
-
TYPE_T
public static final short TYPE_T
- See Also:
- Constant Field Values
-
TYPE_G8
public static final short TYPE_G8
- See Also:
- Constant Field Values
-
TYPE_G32
public static final short TYPE_G32
- See Also:
- Constant Field Values
-
FILTER_OPTION_50HZ
public static final short FILTER_OPTION_50HZ
- See Also:
- Constant Field Values
-
FILTER_OPTION_60HZ
public static final short FILTER_OPTION_60HZ
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletThermocouple
public BrickletThermocouple(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
-
-
Method Detail
-
getTemperature
public int getTemperature() throws TinkerforgeException
Returns the temperature of the thermocouple. If you want to get the temperature periodically, it is recommended to use theBrickletThermocouple.TemperatureListener
listener and set the period withsetTemperatureCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setTemperatureCallbackPeriod
public void setTemperatureCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletThermocouple.TemperatureListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletThermocouple.TemperatureListener
listener is only triggered if the temperature has changed since the last triggering.- Throws:
TinkerforgeException
-
getTemperatureCallbackPeriod
public long getTemperatureCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetTemperatureCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setTemperatureCallbackThreshold
public void setTemperatureCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletThermocouple.TemperatureReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the temperature is *outside* the min and max values" "'i'", "Listener is triggered when the temperature is *inside* the min and max values" "'<'", "Listener is triggered when the temperature is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the temperature is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getTemperatureCallbackThreshold
public BrickletThermocouple.TemperatureCallbackThreshold getTemperatureCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetTemperatureCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listener *BrickletThermocouple.TemperatureReachedListener
is triggered, if the threshold *setTemperatureCallbackThreshold(char, int, int)
keeps being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
setConfiguration
public void setConfiguration(short averaging, short thermocoupleType, short filter) throws TinkerforgeException
You can configure averaging size, thermocouple type and frequency filtering. Available averaging sizes are 1, 2, 4, 8 and 16 samples. As thermocouple type you can use B, E, J, K, N, R, S and T. If you have a different thermocouple or a custom thermocouple you can also use G8 and G32. With these types the returned value will not be in °C/100, it will be calculated by the following formulas: * G8: ``value = 8 * 1.6 * 2^17 * Vin`` * G32: ``value = 32 * 1.6 * 2^17 * Vin`` where Vin is the thermocouple input voltage. The frequency filter can be either configured to 50Hz or to 60Hz. You should configure it according to your utility frequency. The conversion time depends on the averaging and filter configuration, it can be calculated as follows: * 60Hz: ``time = 82 + (samples - 1) * 16.67`` * 50Hz: ``time = 98 + (samples - 1) * 20``- Throws:
TinkerforgeException
-
getConfiguration
public BrickletThermocouple.Configuration getConfiguration() throws TinkerforgeException
Returns the configuration as set bysetConfiguration(short, short, short)
.- Throws:
TinkerforgeException
-
getErrorState
public BrickletThermocouple.ErrorState getErrorState() throws TinkerforgeException
Returns the current error state. There are two possible errors: * Over/Under Voltage and * Open Circuit. Over/Under Voltage happens for voltages below 0V or above 3.3V. In this case it is very likely that your thermocouple is defective. An Open Circuit error indicates that there is no thermocouple connected. You can use theBrickletThermocouple.ErrorStateListener
listener to automatically get triggered when the error state changes.- Throws:
TinkerforgeException
-
getIdentity
public Device.Identity getIdentity() throws TinkerforgeException
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', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|- Specified by:
getIdentity
in classDevice
- Throws:
TinkerforgeException
-
addTemperatureListener
public void addTemperatureListener(BrickletThermocouple.TemperatureListener listener)
Adds a Temperature listener.
-
removeTemperatureListener
public void removeTemperatureListener(BrickletThermocouple.TemperatureListener listener)
Removes a Temperature listener.
-
addTemperatureReachedListener
public void addTemperatureReachedListener(BrickletThermocouple.TemperatureReachedListener listener)
Adds a TemperatureReached listener.
-
removeTemperatureReachedListener
public void removeTemperatureReachedListener(BrickletThermocouple.TemperatureReachedListener listener)
Removes a TemperatureReached listener.
-
addErrorStateListener
public void addErrorStateListener(BrickletThermocouple.ErrorStateListener listener)
Adds a ErrorState listener.
-
removeErrorStateListener
public void removeErrorStateListener(BrickletThermocouple.ErrorStateListener listener)
Removes a ErrorState listener.
-
-