Package com.tinkerforge
Class BrickletTemperature
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletTemperature
-
public class BrickletTemperature extends Device
Measures ambient temperature with 0.5°C accuracy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletTemperature.TemperatureCallbackThreshold
static interface
BrickletTemperature.TemperatureListener
This listener is triggered periodically with the period that is set bysetTemperatureCallbackPeriod(long)
.static interface
BrickletTemperature.TemperatureReachedListener
This listener is triggered when the threshold as set bysetTemperatureCallbackThreshold(char, short, short)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEVICE_DISPLAY_NAME
static int
DEVICE_IDENTIFIER
static byte
FUNCTION_GET_DEBOUNCE_PERIOD
static byte
FUNCTION_GET_I2C_MODE
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_GET_TEMPERATURE
static byte
FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD
static byte
FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD
static byte
FUNCTION_SET_DEBOUNCE_PERIOD
static byte
FUNCTION_SET_I2C_MODE
static byte
FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD
static byte
FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD
static short
I2C_MODE_FAST
static short
I2C_MODE_SLOW
static char
THRESHOLD_OPTION_GREATER
static char
THRESHOLD_OPTION_INSIDE
static char
THRESHOLD_OPTION_OFF
static char
THRESHOLD_OPTION_OUTSIDE
static char
THRESHOLD_OPTION_SMALLER
-
Constructor Summary
Constructors Constructor Description BrickletTemperature(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
addTemperatureListener(BrickletTemperature.TemperatureListener listener)
Adds a Temperature listener.void
addTemperatureReachedListener(BrickletTemperature.TemperatureReachedListener listener)
Adds a TemperatureReached listener.long
getDebouncePeriod()
Returns the debounce period as set bysetDebouncePeriod(long)
.short
getI2CMode()
Returns the I2C mode as set bysetI2CMode(short)
.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.short
getTemperature()
Returns the temperature of the sensor.long
getTemperatureCallbackPeriod()
Returns the period as set bysetTemperatureCallbackPeriod(long)
.BrickletTemperature.TemperatureCallbackThreshold
getTemperatureCallbackThreshold()
Returns the threshold as set bysetTemperatureCallbackThreshold(char, short, short)
.void
removeTemperatureListener(BrickletTemperature.TemperatureListener listener)
Removes a Temperature listener.void
removeTemperatureReachedListener(BrickletTemperature.TemperatureReachedListener listener)
Removes a TemperatureReached listener.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener *BrickletTemperature.TemperatureReachedListener
is triggered, if the threshold *setTemperatureCallbackThreshold(char, short, short)
keeps being reached.void
setI2CMode(short mode)
Sets the I2C mode.void
setTemperatureCallbackPeriod(long period)
Sets the period with which theBrickletTemperature.TemperatureListener
listener is triggered periodically.void
setTemperatureCallbackThreshold(char option, short min, short max)
Sets the thresholds for theBrickletTemperature.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_I2C_MODE
public static final byte FUNCTION_SET_I2C_MODE
- See Also:
- Constant Field Values
-
FUNCTION_GET_I2C_MODE
public static final byte FUNCTION_GET_I2C_MODE
- 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
-
I2C_MODE_FAST
public static final short I2C_MODE_FAST
- See Also:
- Constant Field Values
-
I2C_MODE_SLOW
public static final short I2C_MODE_SLOW
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletTemperature
public BrickletTemperature(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 short getTemperature() throws TinkerforgeException
Returns the temperature of the sensor. If you want to get the temperature periodically, it is recommended to use theBrickletTemperature.TemperatureListener
listener and set the period withsetTemperatureCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setTemperatureCallbackPeriod
public void setTemperatureCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletTemperature.TemperatureListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletTemperature.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, short min, short max) throws TinkerforgeException
Sets the thresholds for theBrickletTemperature.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 BrickletTemperature.TemperatureCallbackThreshold getTemperatureCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetTemperatureCallbackThreshold(char, short, short)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listener *BrickletTemperature.TemperatureReachedListener
is triggered, if the threshold *setTemperatureCallbackThreshold(char, short, short)
keeps being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
setI2CMode
public void setI2CMode(short mode) throws TinkerforgeException
Sets the I2C mode. Possible modes are: * 0: Fast (400kHz) * 1: Slow (100kHz) If you have problems with obvious outliers in the Temperature Bricklet measurements, they may be caused by EMI issues. In this case it may be helpful to lower the I2C speed. It is however not recommended to lower the I2C speed in applications where a high throughput needs to be achieved. .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getI2CMode
public short getI2CMode() throws TinkerforgeException
Returns the I2C mode as set bysetI2CMode(short)
. .. versionadded:: 2.0.1$nbsp;(Plugin)- 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(BrickletTemperature.TemperatureListener listener)
Adds a Temperature listener.
-
removeTemperatureListener
public void removeTemperatureListener(BrickletTemperature.TemperatureListener listener)
Removes a Temperature listener.
-
addTemperatureReachedListener
public void addTemperatureReachedListener(BrickletTemperature.TemperatureReachedListener listener)
Adds a TemperatureReached listener.
-
removeTemperatureReachedListener
public void removeTemperatureReachedListener(BrickletTemperature.TemperatureReachedListener listener)
Removes a TemperatureReached listener.
-
-