openHAB - IMU Brick

Warning

The openHAB bindings are still in beta, but the development was stopped.

This is the description of the openHAB API bindings for the IMU Brick. General information and technical specifications for the IMU Brick are summarized in its hardware description.

An installation guide for the openHAB API bindings is part of their general description.

Thing

UID:
  • tinkerforge:brickimu:[UID]
Required firmware version:
  • 2.3.5
Firmware update supported:
  • no
Channels:
Actions:
Parameters:
  • Enable Orientation – Type: boolean, Default: true
  • Turns the orientation calculation of the IMU Brick on or off. The trigonometric functions that are needed to calculate the orientation are very expensive. We recommend to turn the orientation calculation off if the orientation is not needed, to free calculation time for the sensor fusion algorithm.

  • Convergence Speed – Type: integer, Default: 30, Min: 0, Max: 65535
  • Sets the convergence speed of the IMU Brick in °/s. The convergence speed determines how the different sensor measurements are fused. If the orientation of the IMU Brick is off by 10° and the convergence speed is set to 20°/s, it will take 0.5s until the orientation is corrected. However, if the correct orientation is reached and the convergence speed is too high, the orientation will fluctuate with the fluctuations of the accelerometer and the magnetometer. If you set the convergence speed to 0, practically only the gyroscope is used to calculate the orientation. This gives very smooth movements, but errors of the gyroscope will not be corrected. If you set the convergence speed to something above 500, practically only the magnetometer and the accelerometer are used to calculate the orientation. In this case the movements are abrupt and the values will fluctuate, but there won't be any errors that accumulate over time. In an application with high angular velocities, we recommend a high convergence speed, so the errors of the gyroscope can be corrected fast. In applications with only slow movements we recommend a low convergence speed. You can change the convergence speed on the fly. So it is possible (and recommended) to increase the convergence speed before an abrupt movement and decrease it afterwards again. You might want to play around with the convergence speed in the Brick Viewer to get a feeling for a good value for your application. The default value is 30.

  • Orientation Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the orientation as euler angles in milliseconds. A value of 0 disables automatic updates.

  • Quaternion Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the orientation as quaternion in milliseconds. A value of 0 disables automatic updates.

  • Acceleration Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the acceleration in milliseconds. A value of 0 disables automatic updates.

  • Magnetic Field Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the magnetic field in milliseconds. A value of 0 disables automatic updates.

  • Angular Velocity Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the angular velocity in milliseconds. A value of 0 disables automatic updates.

  • Status LED Configuration – Type: boolean, Default: true
  • The status LED is the blue LED next to the USB connector. If enabled is is on and it flickers if data is transfered. If disabled it is always off.

  • SPITFP Enable Dynamic Baudrate – Type: boolean, Default: true
  • The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is enabled, the Brick will try to adapt the baudrate for the communication between Bricks and Bricklets according to the amount of data that is transferred. The baudrate will be increased exponentially if lots of data is sent/received and decreased linearly if little data is sent/received. This lowers the baudrate in applications where little data is transferred (e.g. a weather station) and increases the robustness. If there is lots of data to transfer (e.g. Thermal Imaging Bricklet) it automatically increases the baudrate as needed. In cases where some data has to transferred as fast as possible every few seconds (e.g. RS485 Bricklet with a high baudrate but small payload) you may want to turn the dynamic baudrate off to get the highest possible performance. The maximum value of the baudrate can be set per port. If the dynamic baudrate is disabled, the maximum baudrate will be used statically.

  • SPITFP Minimum Dynamic Baudrate – Type: integer, Default: 400000, Min: 400000, Max: 2000000
  • See SPITFP Enable Dynamic Baudrate

  • (Maximum) SPITFP Baudrate Port A – Type: integer, Default: 1400000, Min: 400000, Max: 2000000
  • The baudrate for Bricklet port A. If you want to increase the throughput of Bricklets you can increase the baudrate. If you get a high error count because of high interference you can decrease the baudrate. If the dynamic baudrate feature is enabled, this is the maximum baudrate. Regulatory testing is done with the default baudrate. If CE compatibility or similar is necessary in your applications we recommend to not change the baudrate.

  • (Maximum) SPITFP Baudrate Port B – Type: integer, Default: 1400000, Min: 400000, Max: 2000000
  • The baudrate for Bricklet port B. If you want to increase the throughput of Bricklets you can increase the baudrate. If you get a high error count because of high interference you can decrease the baudrate. If the dynamic baudrate feature is enabled, this is the maximum baudrate. Regulatory testing is done with the default baudrate. If CE compatibility or similar is necessary in your applications we recommend to not change the baudrate.

Channels

Orientation - Roll

The current orientation (roll, pitch, yaw) of the IMU Brick as Euler angles in °. Note that Euler angles always experience a gimbal lock.

We recommend that you use quaternions instead.

The order to sequence in which the orientation values should be applied is roll, yaw, pitch.

Type:
  • Number:Angle
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUOrientationRoll
Read only:
  • Yes
Predicate:
  • This channel will only be available if Enable Orientation is enabled.
Unit:
  • Degree Angle
Range:
  • -180 Degree Angle to 180 Degree Angle (Step 0.01 Degree Angle)
Orientation - Pitch

The current orientation (roll, pitch, yaw) of the IMU Brick as Euler angles in °. Note that Euler angles always experience a gimbal lock.

We recommend that you use quaternions instead.

The order to sequence in which the orientation values should be applied is roll, yaw, pitch.

Type:
  • Number:Angle
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUOrientationPitch
Read only:
  • Yes
Predicate:
  • This channel will only be available if Enable Orientation is enabled.
Unit:
  • Degree Angle
Range:
  • -180 Degree Angle to 180 Degree Angle (Step 0.01 Degree Angle)
Orientation - Yaw

The current orientation (roll, pitch, yaw) of the IMU Brick as Euler angles in °. Note that Euler angles always experience a gimbal lock.

We recommend that you use quaternions instead.

The order to sequence in which the orientation values should be applied is roll, yaw, pitch.

Type:
  • Number:Angle
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUOrientationYaw
Read only:
  • Yes
Predicate:
  • This channel will only be available if Enable Orientation is enabled.
Unit:
  • Degree Angle
Range:
  • -180 Degree Angle to 180 Degree Angle (Step 0.01 Degree Angle)
Quaternion - X

The current orientation (x, y, z, w) of the IMU as quaternions.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUQuaternionX
Read only:
  • Yes
Range:
  • -1 to 1 (Step 1)
Quaternion - Y

The current orientation (x, y, z, w) of the IMU as quaternions.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUQuaternionY
Read only:
  • Yes
Range:
  • -1 to 1 (Step 1)
Quaternion - Z

The current orientation (x, y, z, w) of the IMU as quaternions.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUQuaternionZ
Read only:
  • Yes
Range:
  • -1 to 1 (Step 1)
Quaternion - W

The current orientation (x, y, z, w) of the IMU as quaternions.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUQuaternionW
Read only:
  • Yes
Range:
  • -1 to 1 (Step 1)
Enable LEDs

Enable/disable the orientation and direction LEDs of the IMU Brick.

Type:
  • Switch
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUEnableLEDs
Read only:
  • No
Acceleration - X

The calibrated acceleration from the accelerometer for the x, y and z axis in g (1g = 9.80665m/s²).

Type:
  • Number:Acceleration
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUAccelerationX
Read only:
  • Yes
Unit:
  • Standard Gravity
Acceleration - Y

The calibrated acceleration from the accelerometer for the x, y and z axis in g (1g = 9.80665m/s²).

Type:
  • Number:Acceleration
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUAccelerationY
Read only:
  • Yes
Unit:
  • Standard Gravity
Acceleration - Z

The calibrated acceleration from the accelerometer for the x, y and z axis in g (1g = 9.80665m/s²).

Type:
  • Number:Acceleration
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUAccelerationZ
Read only:
  • Yes
Unit:
  • Standard Gravity
Magnetic Field - X

The calibrated magnetic field from the magnetometer for the x, y and z axis in Tesla.

Type:
  • Number:MagneticFluxDensity
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUMagneticFieldX
Read only:
  • Yes
Unit:
  • Tesla
Magnetic Field - Y

The calibrated magnetic field from the magnetometer for the x, y and z axis in Tesla.

Type:
  • Number:MagneticFluxDensity
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUMagneticFieldY
Read only:
  • Yes
Unit:
  • Tesla
Magnetic Field - Z

The calibrated magnetic field from the magnetometer for the x, y and z axis in Tesla.

Type:
  • Number:MagneticFluxDensity
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUMagneticFieldZ
Read only:
  • Yes
Unit:
  • Tesla
Angular Velocity - X

The calibrated angular velocity from the gyroscope for the x, y and z axis in °/s.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUAngularVelocityX
Read only:
  • Yes
Range:
  • -2000 to 2000 (Step 0.06956521739130435)
Angular Velocity - Y

The calibrated angular velocity from the gyroscope for the x, y and z axis in °/s.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUAngularVelocityY
Read only:
  • Yes
Range:
  • -2000 to 2000 (Step 0.06956521739130435)
Angular Velocity - Z

The calibrated angular velocity from the gyroscope for the x, y and z axis in °/s.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickimu:[UID]:BrickIMUAngularVelocityZ
Read only:
  • Yes
Range:
  • -2000 to 2000 (Step 0.06956521739130435)

Actions

Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:

val actions = getActions("tinkerforge", "tinkerforge:brickimu:[UID]")
val hwVersion = actions.brickIMUGetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickIMUGetOrientation()
Return Map:
  • roll – Type: short, Unit: 1/100 °, Range: [-18000 to 18000]
  • pitch – Type: short, Unit: 1/100 °, Range: [-18000 to 18000]
  • yaw – Type: short, Unit: 1/100 °, Range: [-18000 to 18000]

Returns the current orientation (roll, pitch, yaw) of the IMU Brick as Euler angles. Note that Euler angles always experience a gimbal lock.

We recommend that you use quaternions instead.

The order to sequence in which the orientation values should be applied is roll, yaw, pitch.

If you want to get the orientation periodically, it is recommended to use the Orientation - Roll channel and set the period with the thing configuration.

brickIMUGetQuaternion()
Return Map:
  • x – Type: float, Range: [-1.0f to 1.0f]
  • y – Type: float, Range: [-1.0f to 1.0f]
  • z – Type: float, Range: [-1.0f to 1.0f]
  • w – Type: float, Range: [-1.0f to 1.0f]

Returns the current orientation (x, y, z, w) of the IMU as quaternions.

You can go from quaternions to Euler angles with the following formula:

xAngle = atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z)
yAngle = atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z)
zAngle =  asin(2*x*y + 2*z*w)

This process is not reversible, because of the gimbal lock.

It is also possible to calculate independent angles. You can calculate yaw, pitch and roll in a right-handed vehicle coordinate system according to DIN70000 with:

yaw   =  atan2(2*x*y + 2*w*z, w*w + x*x - y*y - z*z)
pitch = -asin(2*w*y - 2*x*z)
roll  = -atan2(2*y*z + 2*w*x, -w*w + x*x + y*y - z*z))

Converting the quaternions to an OpenGL transformation matrix is possible with the following formula:

matrix = [[1 - 2*(y*y + z*z),     2*(x*y - w*z),     2*(x*z + w*y), 0],
          [    2*(x*y + w*z), 1 - 2*(x*x + z*z),     2*(y*z - w*x), 0],
          [    2*(x*z - w*y),     2*(y*z + w*x), 1 - 2*(x*x + y*y), 0],
          [                0,                 0,                 0, 1]]

If you want to get the quaternions periodically, it is recommended to use the Quaternion - X channel and set the period with the thing configuration.

brickIMULedsOn()

Turns the orientation and direction LEDs of the IMU Brick on.

brickIMULedsOff()

Turns the orientation and direction LEDs of the IMU Brick off.

brickIMUGetConvergenceSpeed()
Return Map:
  • speed – Type: int, Unit: 1 °/s, Range: [0 to 216 - 1], Default: 30

Returns the convergence speed as set by the thing configuration.

Advanced Actions

brickIMUGetAcceleration()
Return Map:
  • x – Type: short, Unit: 1/1000 gₙ, Range: [-215 to 215 - 1]
  • y – Type: short, Unit: 1/1000 gₙ, Range: [-215 to 215 - 1]
  • z – Type: short, Unit: 1/1000 gₙ, Range: [-215 to 215 - 1]

Returns the calibrated acceleration from the accelerometer for the x, y and z axis.

If you want to get the acceleration periodically, it is recommended to use the Acceleration - X channel and set the period with the thing configuration.

brickIMUGetMagneticField()
Return Map:
  • x – Type: short, Unit: 1/10 µT, Range: [-215 to 215 - 1]
  • y – Type: short, Unit: 1/10 µT, Range: [-215 to 215 - 1]
  • z – Type: short, Unit: 1/10 µT, Range: [-215 to 215 - 1]

Returns the calibrated magnetic field from the magnetometer for the x, y and z axis.

If you want to get the magnetic field periodically, it is recommended to use the Magnetic Field - X channel and set the period with the thing configuration.

brickIMUGetAngularVelocity()
Return Map:
  • x – Type: short, Unit: 8/115 °/s, Range: [-28750 to 28750]
  • y – Type: short, Unit: 8/115 °/s, Range: [-28750 to 28750]
  • z – Type: short, Unit: 8/115 °/s, Range: [-28750 to 28750]

Returns the calibrated angular velocity from the gyroscope for the x, y and z axis in °/14.375s (you have to divide by 14.375 to get the value in °/s).

If you want to get the angular velocity periodically, it is recommended to use the Angular Velocity - X channel and set the period with the thing configuration.

brickIMUGetAllData()
Return Map:
  • accX – Type: short, Unit: 1/1000 gₙ, Range: [-215 to 215 - 1]
  • accY – Type: short, Unit: 1/1000 gₙ, Range: [-215 to 215 - 1]
  • accZ – Type: short, Unit: 1/1000 gₙ, Range: [-215 to 215 - 1]
  • magX – Type: short, Unit: 1/10 µT, Range: [-215 to 215 - 1]
  • magY – Type: short, Unit: 1/10 µT, Range: [-215 to 215 - 1]
  • magZ – Type: short, Unit: 1/10 µT, Range: [-215 to 215 - 1]
  • angX – Type: short, Unit: 8/115 °/s, Range: [-28750 to 28750]
  • angY – Type: short, Unit: 8/115 °/s, Range: [-28750 to 28750]
  • angZ – Type: short, Unit: 8/115 °/s, Range: [-28750 to 28750]
  • temperature – Type: short, Unit: 1/100 °C, Range: [-215 to 215 - 1]

Returns the data from Acceleration - X, Magnetic Field - X and Angular Velocity - X as well as the temperature of the IMU Brick.

brickIMUGetIMUTemperature()
Return Map:
  • temperature – Type: short, Unit: 1/100 °C, Range: [-215 to 215 - 1]

Returns the temperature of the IMU Brick.

brickIMUGetCalibration(short typ)
Parameters:
  • typ – Type: short, Range: See constants
Return Map:
  • data – Type: short[], Length: 10, Range: [-215 to 215 - 1]

Returns the calibration for a given type as set by This function is not available in openHAB. Please use Brick Viewer to change persistant device settings.

The following constants are available for this function:

For typ:

  • val CALIBRATION_TYPE_ACCELEROMETER_GAIN = 0
  • val CALIBRATION_TYPE_ACCELEROMETER_BIAS = 1
  • val CALIBRATION_TYPE_MAGNETOMETER_GAIN = 2
  • val CALIBRATION_TYPE_MAGNETOMETER_BIAS = 3
  • val CALIBRATION_TYPE_GYROSCOPE_GAIN = 4
  • val CALIBRATION_TYPE_GYROSCOPE_BIAS = 5
brickIMUIsOrientationCalculationOn()
Return Map:
  • orientationCalculationOn – Type: boolean, Default: true

Returns true if the orientation calculation of the IMU Brick is on, false otherwise.

New in version 2.0.2 (Firmware).

brickIMUGetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['0' to '8']
  • hardwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • firmwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • deviceIdentifier – Type: int, Range: [0 to 216 - 1]

Returns the UID, the UID where the Brick is connected to, the position, the hardware and firmware version as well as the device identifier.

The position is the position in the stack from '0' (bottom) to '8' (top).

The device identifier numbers can be found here

brickIMUIsStatusLEDEnabled()
Return Map:
  • enabled – Type: boolean, Default: true

Returns true if the status LED is enabled, false otherwise.

New in version 2.3.1 (Firmware).

brickIMUGetChipTemperature()
Return Map:
  • temperature – Type: short, Unit: 1/10 °C, Range: [-215 to 215 - 1]

Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!

The temperature is only proportional to the real temperature and it has an accuracy of ±15%. Practically it is only useful as an indicator for temperature changes.

brickIMUGetSendTimeoutCount(short communicationMethod)
Parameters:
  • communicationMethod – Type: short, Range: See constants
Return Map:
  • timeoutCount – Type: long, Range: [0 to 232 - 1]

Returns the timeout count for the different communication methods.

The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.

This function is mostly used for debugging during development, in normal operation the counters should nearly always stay at 0.

The following constants are available for this function:

For communicationMethod:

  • val COMMUNICATION_METHOD_NONE = 0
  • val COMMUNICATION_METHOD_USB = 1
  • val COMMUNICATION_METHOD_SPI_STACK = 2
  • val COMMUNICATION_METHOD_CHIBI = 3
  • val COMMUNICATION_METHOD_RS485 = 4
  • val COMMUNICATION_METHOD_WIFI = 5
  • val COMMUNICATION_METHOD_ETHERNET = 6
  • val COMMUNICATION_METHOD_WIFI_V2 = 7

New in version 2.3.3 (Firmware).

brickIMUGetSPITFPBaudrateConfig()
Return Map:
  • enableDynamicBaudrate – Type: boolean, Default: true
  • minimumDynamicBaudrate – Type: long, Unit: 1 Bd, Range: [400000 to 2000000], Default: 400000

Returns the baudrate config, see the thing configuration.

New in version 2.3.5 (Firmware).

brickIMUGetSPITFPErrorCount(char brickletPort)
Parameters:
  • brickletPort – Type: char, Range: ['a' to 'b']
Return Map:
  • errorCountACKChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountMessageChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountFrame – Type: long, Range: [0 to 232 - 1]
  • errorCountOverflow – Type: long, Range: [0 to 232 - 1]

Returns the error count for the communication between Brick and Bricklet.

The errors are divided into

  • ACK checksum errors,
  • message checksum errors,
  • framing errors and
  • overflow errors.

The errors counts are for errors that occur on the Brick side. All Bricklets have a similar function that returns the errors on the Bricklet side.

New in version 2.3.3 (Firmware).

brickIMUGetSPITFPBaudrate(char brickletPort)
Parameters:
  • brickletPort – Type: char, Range: ['a' to 'b']
Return Map:
  • baudrate – Type: long, Unit: 1 Bd, Range: [400000 to 2000000], Default: 1400000

Returns the baudrate for a given Bricklet port, see the thing configuration.

New in version 2.3.3 (Firmware).