openHAB - HAT 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 HAT Brick. General information and technical specifications for the HAT Brick are summarized in its hardware description.

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

Thing

UID:
  • tinkerforge:brickhat:[UID]
Required firmware version:
  • 2.0.3
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Voltages Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the voltages in milliseconds. A value of 0 disables automatic updates.

  • Status LED Configuration – 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

Sleep

Starts the configured sleep mode. Note: Triggering this will cut the Raspberry Pi's power after the configured amount of seconds. You have to shut down the operating system yourself, e.g. by calling 'sudo shutdown -h now'.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickhat:[UID]:BrickHATSleep
Read only:
  • No
Commands:
  • Accepts any string
Parameters:
  • Power Off Delay – Type: integer, Default: 60, Min: 0, Max: 4294967295
  • Time in seconds before the RPi/Bricklets are powered off.

  • Power Off Duration – Type: integer, Default: 10, Min: 0, Max: 4294967295
  • Duration in seconds that the RPi/Bricklets stay powered off.

  • Raspberry Pi Off – Type: boolean, Default: false
  • Raspberry Pi is powered off if enabled.

  • Bricklets Off – Type: boolean, Default: true
  • Bricklets are powered off if enabled.

  • Sleep Indicator – Type: boolean, Default: true
  • If enabled, the status LED will blink in a 1s interval during the whole power off duration. This will draw additional 0.3mA.
Power Bricklets

Enable/disable to turn the power supply of the connected Bricklets on/off.

Type:
  • Switch
UID:
  • tinkerforge:brickhat:[UID]:BrickHATPowerBricklets
Read only:
  • No
USB Voltage

The USB supply voltage.

There are three possible combinations:

  • Only USB connected: The USB supply voltage will be fed back to the DC input connector. You will read the USB voltage and a slightly lower voltage on the DC input.
  • Only DC input connected: The DC voltage will not be fed back to the USB connector. You will read the DC input voltage and the USB voltage will be 0.
  • USB and DC input connected: You will read both voltages. In this case the USB supply will be without load, but it will work as backup if you disconnect the DC input (or if the DC input voltage falls below the USB voltage).
Type:
  • Number:ElectricPotential
UID:
  • tinkerforge:brickhat:[UID]:BrickHATUSBVoltage
Read only:
  • Yes
Unit:
  • Volt
DC Voltage

The DC supply voltage.

There are three possible combinations:

  • Only USB connected: The USB supply voltage will be fed back to the DC input connector. You will read the USB voltage and a slightly lower voltage on the DC input.
  • Only DC input connected: The DC voltage will not be fed back to the USB connector. You will read the DC input voltage and the USB voltage will be 0.
  • USB and DC input connected: You will read both voltages. In this case the USB supply will be without load, but it will work as backup if you disconnect the DC input (or if the DC input voltage falls below the USB voltage).
Type:
  • Number:ElectricPotential
UID:
  • tinkerforge:brickhat:[UID]:BrickHATDCVoltage
Read only:
  • Yes
Unit:
  • Volt

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

Basic Actions

brickHATSetSleepMode(long powerOffDelay, long powerOffDuration, boolean raspberryPiOff, boolean brickletsOff, boolean enableSleepIndicator)
Parameters:
  • powerOffDelay – Type: long, Unit: 1 s, Range: [0 to 232 - 1]
  • powerOffDuration – Type: long, Unit: 1 s, Range: [0 to 232 - 1]
  • raspberryPiOff – Type: boolean
  • brickletsOff – Type: boolean
  • enableSleepIndicator – Type: boolean

Sets the sleep mode.

Note

Calling this function will cut the Raspberry Pi's power after Power Off Delay seconds. You have to shut down the operating system yourself, e.g. by calling 'sudo shutdown -h now'.

Parameters:

  • Power Off Delay: Time before the RPi/Bricklets are powered off.
  • Power Off Duration: Duration that the RPi/Bricklets stay powered off.
  • Raspberry Pi Off: RPi is powered off if set to true.
  • Bricklets Off: Bricklets are powered off if set to true.
  • Enable Sleep Indicator: If set to true, the status LED will blink in a 1s interval during the whole power off duration. This will draw additional 0.3mA.

Example: To turn RPi and Bricklets off in 5 seconds for 10 minutes with sleep indicator enabled, call (5, 60*10, true, true, true).

This function can also be used to implement a watchdog. To do this you can write a program that calls this function once per second in a loop with (10, 2, true, false, false). If the RPi crashes or gets stuck the HAT will reset the RPi after 10 seconds.

brickHATGetSleepMode()
Return Map:
  • powerOffDelay – Type: long, Unit: 1 s, Range: [0 to 232 - 1]
  • powerOffDuration – Type: long, Unit: 1 s, Range: [0 to 232 - 1]
  • raspberryPiOff – Type: boolean
  • brickletsOff – Type: boolean
  • enableSleepIndicator – Type: boolean

Returns the sleep mode settings as set by Sleep.

brickHATSetBrickletPower(boolean brickletPower)
Parameters:
  • brickletPower – Type: boolean, Default: true

Set to true/false to turn the power supply of the connected Bricklets on/off.

brickHATGetBrickletPower()
Return Map:
  • brickletPower – Type: boolean, Default: true

Returns the power status of the connected Bricklets as set by Power Bricklets.

brickHATGetVoltages()
Return Map:
  • voltageUSB – Type: int, Unit: 1 mV, Range: [0 to 216 - 1]
  • voltageDC – Type: int, Unit: 1 mV, Range: [0 to 216 - 1]

Returns the USB supply voltage and the DC input supply voltage.

There are three possible combinations:

  • Only USB connected: The USB supply voltage will be fed back to the DC input connector. You will read the USB voltage and a slightly lower voltage on the DC input.
  • Only DC input connected: The DC voltage will not be fed back to the USB connector. You will read the DC input voltage and the USB voltage will be 0.
  • USB and DC input connected: You will read both voltages. In this case the USB supply will be without load, but it will work as backup if you disconnect the DC input (or if the DC input voltage falls below the USB voltage).

Advanced Actions

brickHATGetRTCDriver()
Return Map:
  • rtcDriver – Type: int, Range: See constants

Returns the RTC driver as set by Blah.

The following constants are available for this function:

For rtcDriver:

  • val RTC_DRIVER_PCF8523 = 0
  • val RTC_DRIVER_DS1338 = 1

New in version 2.0.3 (Firmware).

brickHATGetChipTemperature()
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.

brickHATGetStatusLEDConfig()
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
brickHATGetSPITFPErrorCount()
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.

brickHATReset()

Calling this function will reset the Bricklet. All configurations will be lost.

After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!

Internal Actions

brickHATReadUID()
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.