Package com.tinkerforge
Class BrickletBarometer
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletBarometer
-
public class BrickletBarometer extends Device
Measures air pressure and altitude changes
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletBarometer.AirPressureCallbackThreshold
static interface
BrickletBarometer.AirPressureListener
This listener is triggered periodically with the period that is set bysetAirPressureCallbackPeriod(long)
.static interface
BrickletBarometer.AirPressureReachedListener
This listener is triggered when the threshold as set bysetAirPressureCallbackThreshold(char, int, int)
is reached.class
BrickletBarometer.AltitudeCallbackThreshold
static interface
BrickletBarometer.AltitudeListener
This listener is triggered periodically with the period that is set bysetAltitudeCallbackPeriod(long)
.static interface
BrickletBarometer.AltitudeReachedListener
This listener is triggered when the threshold as set bysetAltitudeCallbackThreshold(char, int, int)
is reached.class
BrickletBarometer.Averaging
-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletBarometer(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
addAirPressureListener(BrickletBarometer.AirPressureListener listener)
Adds a AirPressure listener.void
addAirPressureReachedListener(BrickletBarometer.AirPressureReachedListener listener)
Adds a AirPressureReached listener.void
addAltitudeListener(BrickletBarometer.AltitudeListener listener)
Adds a Altitude listener.void
addAltitudeReachedListener(BrickletBarometer.AltitudeReachedListener listener)
Adds a AltitudeReached listener.int
getAirPressure()
Returns the air pressure of the air pressure sensor.long
getAirPressureCallbackPeriod()
Returns the period as set bysetAirPressureCallbackPeriod(long)
.BrickletBarometer.AirPressureCallbackThreshold
getAirPressureCallbackThreshold()
Returns the threshold as set bysetAirPressureCallbackThreshold(char, int, int)
.int
getAltitude()
Returns the relative altitude of the air pressure sensor.long
getAltitudeCallbackPeriod()
Returns the period as set bysetAltitudeCallbackPeriod(long)
.BrickletBarometer.AltitudeCallbackThreshold
getAltitudeCallbackThreshold()
Returns the threshold as set bysetAltitudeCallbackThreshold(char, int, int)
.BrickletBarometer.Averaging
getAveraging()
Returns the averaging configuration as set bysetAveraging(short, short, short)
.short
getChipTemperature()
Returns the temperature of the air pressure sensor.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.int
getReferenceAirPressure()
Returns the reference air pressure as set bysetReferenceAirPressure(int)
.void
removeAirPressureListener(BrickletBarometer.AirPressureListener listener)
Removes a AirPressure listener.void
removeAirPressureReachedListener(BrickletBarometer.AirPressureReachedListener listener)
Removes a AirPressureReached listener.void
removeAltitudeListener(BrickletBarometer.AltitudeListener listener)
Removes a Altitude listener.void
removeAltitudeReachedListener(BrickletBarometer.AltitudeReachedListener listener)
Removes a AltitudeReached listener.void
setAirPressureCallbackPeriod(long period)
Sets the period with which theBrickletBarometer.AirPressureListener
listener is triggered periodically.void
setAirPressureCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletBarometer.AirPressureReachedListener
listener.void
setAltitudeCallbackPeriod(long period)
Sets the period with which theBrickletBarometer.AltitudeListener
listener is triggered periodically.void
setAltitudeCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletBarometer.AltitudeReachedListener
listener.void
setAveraging(short movingAveragePressure, short averagePressure, short averageTemperature)
Sets the different averaging parameters.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listeners *BrickletBarometer.AirPressureReachedListener
, *BrickletBarometer.AltitudeReachedListener
are triggered, if the thresholds *setAirPressureCallbackThreshold(char, int, int)
, *setAltitudeCallbackThreshold(char, int, int)
keep being reached.void
setI2CMode(short mode)
Sets the I2C mode.void
setReferenceAirPressure(int airPressure)
Sets the reference air pressure for the altitude calculation.-
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_AIR_PRESSURE
public static final byte FUNCTION_GET_AIR_PRESSURE
- See Also:
- Constant Field Values
-
FUNCTION_GET_ALTITUDE
public static final byte FUNCTION_GET_ALTITUDE
- See Also:
- Constant Field Values
-
FUNCTION_SET_AIR_PRESSURE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_AIR_PRESSURE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_AIR_PRESSURE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_AIR_PRESSURE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_ALTITUDE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ALTITUDE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ALTITUDE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ALTITUDE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_AIR_PRESSURE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_AIR_PRESSURE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_AIR_PRESSURE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_AIR_PRESSURE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_SET_ALTITUDE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_ALTITUDE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ALTITUDE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ALTITUDE_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_REFERENCE_AIR_PRESSURE
public static final byte FUNCTION_SET_REFERENCE_AIR_PRESSURE
- See Also:
- Constant Field Values
-
FUNCTION_GET_CHIP_TEMPERATURE
public static final byte FUNCTION_GET_CHIP_TEMPERATURE
- See Also:
- Constant Field Values
-
FUNCTION_GET_REFERENCE_AIR_PRESSURE
public static final byte FUNCTION_GET_REFERENCE_AIR_PRESSURE
- See Also:
- Constant Field Values
-
FUNCTION_SET_AVERAGING
public static final byte FUNCTION_SET_AVERAGING
- See Also:
- Constant Field Values
-
FUNCTION_GET_AVERAGING
public static final byte FUNCTION_GET_AVERAGING
- 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
-
BrickletBarometer
public BrickletBarometer(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
-
getAirPressure
public int getAirPressure() throws TinkerforgeException
Returns the air pressure of the air pressure sensor. If you want to get the air pressure periodically, it is recommended to use theBrickletBarometer.AirPressureListener
listener and set the period withsetAirPressureCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
getAltitude
public int getAltitude() throws TinkerforgeException
Returns the relative altitude of the air pressure sensor. The value is calculated based on the difference between the current air pressure and the reference air pressure that can be set withsetReferenceAirPressure(int)
. If you want to get the altitude periodically, it is recommended to use theBrickletBarometer.AltitudeListener
listener and set the period withsetAltitudeCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAirPressureCallbackPeriod
public void setAirPressureCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletBarometer.AirPressureListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletBarometer.AirPressureListener
listener is only triggered if the air pressure has changed since the last triggering.- Throws:
TinkerforgeException
-
getAirPressureCallbackPeriod
public long getAirPressureCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetAirPressureCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAltitudeCallbackPeriod
public void setAltitudeCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletBarometer.AltitudeListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletBarometer.AltitudeListener
listener is only triggered if the altitude has changed since the last triggering.- Throws:
TinkerforgeException
-
getAltitudeCallbackPeriod
public long getAltitudeCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetAltitudeCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAirPressureCallbackThreshold
public void setAirPressureCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletBarometer.AirPressureReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the air pressure is *outside* the min and max values" "'i'", "Listener is triggered when the air pressure is *inside* the min and max values" "'<'", "Listener is triggered when the air pressure is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the air pressure is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getAirPressureCallbackThreshold
public BrickletBarometer.AirPressureCallbackThreshold getAirPressureCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetAirPressureCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setAltitudeCallbackThreshold
public void setAltitudeCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletBarometer.AltitudeReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the altitude is *outside* the min and max values" "'i'", "Listener is triggered when the altitude is *inside* the min and max values" "'<'", "Listener is triggered when the altitude is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the altitude is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getAltitudeCallbackThreshold
public BrickletBarometer.AltitudeCallbackThreshold getAltitudeCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetAltitudeCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listeners *BrickletBarometer.AirPressureReachedListener
, *BrickletBarometer.AltitudeReachedListener
are triggered, if the thresholds *setAirPressureCallbackThreshold(char, int, int)
, *setAltitudeCallbackThreshold(char, int, int)
keep being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
setReferenceAirPressure
public void setReferenceAirPressure(int airPressure) throws TinkerforgeException
Sets the reference air pressure 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 <https://en.wikipedia.org/wiki/QNH>`__ and `QFE <https://en.wikipedia.org/wiki/Mean_sea_level_pressure#Mean_sea_level_pressure>`__ used in aviation.- Throws:
TinkerforgeException
-
getChipTemperature
public short getChipTemperature() throws TinkerforgeException
Returns the temperature of the air pressure sensor. 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`.- Throws:
TinkerforgeException
-
getReferenceAirPressure
public int getReferenceAirPressure() throws TinkerforgeException
Returns the reference air pressure as set bysetReferenceAirPressure(int)
.- Throws:
TinkerforgeException
-
setAveraging
public void setAveraging(short movingAveragePressure, short averagePressure, short averageTemperature) throws TinkerforgeException
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 <https://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. 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. .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getAveraging
public BrickletBarometer.Averaging getAveraging() throws TinkerforgeException
Returns the averaging configuration as set bysetAveraging(short, short, short)
. .. versionadded:: 2.0.1$nbsp;(Plugin)- 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 Barometer 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.3$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getI2CMode
public short getI2CMode() throws TinkerforgeException
Returns the I2C mode as set bysetI2CMode(short)
. .. versionadded:: 2.0.3$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
-
addAirPressureListener
public void addAirPressureListener(BrickletBarometer.AirPressureListener listener)
Adds a AirPressure listener.
-
removeAirPressureListener
public void removeAirPressureListener(BrickletBarometer.AirPressureListener listener)
Removes a AirPressure listener.
-
addAltitudeListener
public void addAltitudeListener(BrickletBarometer.AltitudeListener listener)
Adds a Altitude listener.
-
removeAltitudeListener
public void removeAltitudeListener(BrickletBarometer.AltitudeListener listener)
Removes a Altitude listener.
-
addAirPressureReachedListener
public void addAirPressureReachedListener(BrickletBarometer.AirPressureReachedListener listener)
Adds a AirPressureReached listener.
-
removeAirPressureReachedListener
public void removeAirPressureReachedListener(BrickletBarometer.AirPressureReachedListener listener)
Removes a AirPressureReached listener.
-
addAltitudeReachedListener
public void addAltitudeReachedListener(BrickletBarometer.AltitudeReachedListener listener)
Adds a AltitudeReached listener.
-
removeAltitudeReachedListener
public void removeAltitudeReachedListener(BrickletBarometer.AltitudeReachedListener listener)
Removes a AltitudeReached listener.
-
-