openHAB - Laser Range Finder Bricklet 2.0

This is the description of the openHAB API bindings for the Laser Range Finder Bricklet 2.0. General information and technical specifications for the Laser Range Finder Bricklet 2.0 are summarized in its hardware description.

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

Thing

UID:
  • tinkerforge:brickletlaserrangefinderv2:[UID]
Required firmware version:
  • 2.0.0
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Distance Moving Average Length – Type: integer, Default: 10, Min: 0, Max: 255
  • The length of a moving averaging for the distance.

  • Velocity Moving Average Length – Type: integer, Default: 10, Min: 0, Max: 255
  • The length of a moving averaging for the velocity.

  • Acquisition Count – Type: integer, Default: 128, Min: 1, Max: 255
  • The Acquisition Count defines the number of times the Laser Range Finder Bricklet will integrate acquisitions to find a correlation record peak. With a higher count, the Bricklet can measure longer distances. With a lower count, the rate increases. This setting will be ignored if you have a LIDAR-Lite sensor with hardware version 1.

  • Enable Quick Termination – Type: boolean, Default: false
  • If you enable Quick Termination, the distance measurement will be terminated early if a high peak was already detected. This means that a higher measurement rate can be achieved and long distances can be measured at the same time. However, the chance of false-positive distance measurements increases. This setting will be ignored if you have a LIDAR-Lite sensor with hardware version 1.

  • Threshold Value – Type: integer, Default: 0, Min: 0, Max: 255
  • Normally the distance is calculated with a detection algorithm that uses peak value, signal strength and noise. You can however also define a fixed Threshold Value. Set this to a low value if you want to measure the distance to something that has very little reflection (e.g. glass) and set it to a high value if you want to measure the distance to something with a very high reflection (e.g. mirror). Set this to 0 to use the default algorithm. This setting will be ignored if you have a LIDAR-Lite sensor with hardware version 1.

  • Enable Fixed Measurement Frequency – Type: boolean, Default: false
  • For a stable velocity measurement you should set a fixed measurement frequency. See Measurement Frequency for details. This setting will be ignored if you have a LIDAR-Lite sensor with hardware version 1.

  • Measurement Frequency – Type: integer, Default: 10, Min: 10, Max: 500
  • Set the Measurement Frequency in Hz to force a fixed measurement rate. If set to 0, the Laser Range Finder Bricklet will use the optimal frequency according to the other configurations and the actual measured distance. Since the rate is not fixed in this case, the velocity measurement is not stable. For a stable velocity measurement you should set a fixed measurement frequency. The lower the frequency, the higher is the resolution of the calculated velocity. The allowed values are 10Hz-500Hz. This setting will be ignored if you have a LIDAR-Lite sensor with hardware version 1.

  • Distance LED Config – Type: Choice, Default: Show Distance
  • Configures the distance LED to be either turned off, turned on, blink in heartbeat mode or show the distance (brighter = object is nearer).
  • Options: Off, On, Show Heartbeat, Show Distance

  • Status LED Config – Type: Choice, Default: Show Status
  • The status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
  • Options: Off, On, Show Heartbeat, Show Status

Channels

Distance

The measured distance. Sensor hardware version 1 cannot measure distance and velocity at the same time. Therefore, the distance mode has to be enabled. Sensor hardware version 3 can measure distance and velocity at the same time. Also the laser has to be enabled.

Type:
  • Number:Length
UID:
  • tinkerforge:brickletlaserrangefinderv2:[UID]:BrickletLaserRangeFinderV2Distance
Read only:
  • Yes
Unit:
  • Meter
Range:
  • 0 Meter to 40 Meter (Step 0.01 Meter)
Parameters:
  • Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval in milliseconds. A value of 0 disables automatic updates.
Velocity

The measured velocity. Sensor hardware version 1 cannot measure distance and velocity at the same time. Therefore, the velocity mode has to be enabled. Sensor hardware version 3 can measure distance and velocity at the same time, but the velocity measurement only produces stables results if a fixed measurement rateis configured. Also the laser has to be enabled.

Type:
  • Number:Speed
UID:
  • tinkerforge:brickletlaserrangefinderv2:[UID]:BrickletLaserRangeFinderV2Velocity
Read only:
  • Yes
Unit:
  • Meter Per Second
Range:
  • -128 Meter Per Second to 127 Meter Per Second (Step 0.01 Meter Per Second)
Parameters:
  • Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval in milliseconds. A value of 0 disables automatic updates.
Enable Laser

Activates the laser of the LIDAR.

Type:
  • Switch
UID:
  • tinkerforge:brickletlaserrangefinderv2:[UID]:BrickletLaserRangeFinderV2EnableLaser
Read only:
  • No

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:brickletlaserrangefinderv2:[UID]")
val hwVersion = actions.brickletLaserRangeFinderV2GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletLaserRangeFinderV2GetDistance()
Return Map:
  • distance – Type: int, Unit: 1 cm, Range: [0 to 4000]

Returns the measured distance.

The laser has to be enabled, see Enable Laser.

If you want to get the value periodically, it is recommended to use the Distance channel. You can set the channel configuration with the configuration of Distance.

brickletLaserRangeFinderV2GetVelocity()
Return Map:
  • velocity – Type: int, Unit: 1 cm/s, Range: [-12800 to 12700]

Returns the measured velocity. The value has a range of -12800 to 12700 and is given in 1/100 m/s.

The velocity measurement only produces stables results if a fixed measurement rate (see the thing configuration) is configured. Also the laser has to be enabled, see Enable Laser.

If you want to get the value periodically, it is recommended to use the Velocity channel. You can set the channel configuration with the configuration of Velocity.

brickletLaserRangeFinderV2SetEnable(boolean enable)
Parameters:
  • enable – Type: boolean, Default: false

Enables the laser of the LIDAR if set to true.

We recommend that you wait 250ms after enabling the laser before the first call of Distance to ensure stable measurements.

brickletLaserRangeFinderV2GetEnable()
Return Map:
  • enable – Type: boolean, Default: false

Returns the value as set by Enable Laser.

brickletLaserRangeFinderV2GetConfiguration()
Return Map:
  • acquisitionCount – Type: int, Range: [1 to 255], Default: 128
  • enableQuickTermination – Type: boolean, Default: false
  • thresholdValue – Type: int, Range: [0 to 255], Default: 0
  • measurementFrequency – Type: int, Unit: 1 Hz, Range: [0, 10 to 500], Default: 0

Returns the configuration as set by the thing configuration.

brickletLaserRangeFinderV2GetDistanceLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the LED configuration as set by the thing configuration

The following constants are available for this function:

For config:

  • val DISTANCE_LED_CONFIG_OFF = 0
  • val DISTANCE_LED_CONFIG_ON = 1
  • val DISTANCE_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val DISTANCE_LED_CONFIG_SHOW_DISTANCE = 3

Advanced Actions

brickletLaserRangeFinderV2GetMovingAverage()
Return Map:
  • distanceAverageLength – Type: int, Range: [0 to 255], Default: 10
  • velocityAverageLength – Type: int, Range: [0 to 255], Default: 10

Returns the length moving average as set by the thing configuration.

brickletLaserRangeFinderV2GetOffsetCalibration()
Return Map:
  • offset – Type: int, Unit: 1 cm, Range: [-215 to 28767]

Returns the offset value as set by This function is not available in openHAB. Please use Brick Viewer to change persistant device settings.

brickletLaserRangeFinderV2GetChipTemperature()
Return Map:
  • temperature – Type: int, Unit: 1 °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 bad accuracy. Practically it is only useful as an indicator for temperature changes.

brickletLaserRangeFinderV2GetStatusLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the configuration as set by the thing configuration

The following constants are available for this function:

For config:

  • val STATUS_LED_CONFIG_OFF = 0
  • val STATUS_LED_CONFIG_ON = 1
  • val STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val STATUS_LED_CONFIG_SHOW_STATUS = 3
brickletLaserRangeFinderV2GetSPITFPErrorCount()
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 Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.

brickletLaserRangeFinderV2GetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'z']
  • 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 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 Isolator Bricklet is always as position 'z'.

The device identifier numbers can be found here

Internal Actions

brickletLaserRangeFinderV2ReadUID()
Return Map:
  • uid – Type: long, Range: [0 to 232 - 1]

Returns the current UID as an integer. Encode as Base58 to get the usual string version.