openHAB - Piezo Speaker Bricklet 2.0

This is the description of the openHAB API bindings for the Piezo Speaker Bricklet 2.0. General information and technical specifications for the Piezo Speaker 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:brickletpiezospeakerv2:[UID]
Required firmware version:
  • 2.0.0
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • 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

Beep

Beeps with the configured default frequency and volume for the configured duration. Frequency and Volume can be updated using the corresponding channels.

Type:
  • Switch
UID:
  • tinkerforge:brickletpiezospeakerv2:[UID]:BrickletPiezoSpeakerV2Beep
Read only:
  • No
Parameters:
  • Default Frequency – Type: integer, Default: 50, Min: 50, Max: 15000
  • The frequency in Hz to start the beep with. The range of the frequency is 50Hz to 15000Hz.

  • Default Volume – Type: integer, Default: 0, Min: 0, Max: 10
  • The volume to start the beep with. The range of the volume is 0 to 10.

  • Duration – Type: decimal, Default: 0, Step: 1
  • The duration in ms to beep for. A duration of 0 stops the current beep if any is ongoing. A duration of 4294967295 results in an infinite beep.
Alarm

Creates an alarm (a tone that goes back and force between two specified frequencies). The following parameters can be set:

  • Start Frequency: Start frequency of the alarm in Hz.
  • End Frequency: End frequency of the alarm in Hz.
  • Step Size: Size of one step of the sweep between the start/end frequencies in Hz.
  • Step Delay: Delay between two steps (duration of time that one tone is used in a sweep) in ms.
  • Duration: Duration of the alarm in ms.

A duration of 0 stops the current alarm if any is ongoing. A duration of 4294967295 results in an infinite alarm.

Type:
  • Switch
UID:
  • tinkerforge:brickletpiezospeakerv2:[UID]:BrickletPiezoSpeakerV2Alarm
Read only:
  • No
Parameters:
  • Start Frequency – Type: integer, Default: 250, Min: 50, Max: 14999
  • Start frequency of the alarm in Hz. The range of the start frequency is 50Hz to 14999Hz. (has to be smaller than end frequency)

  • End Frequency – Type: integer, Default: 750, Min: 51, Max: 15000
  • End frequency of the alarm in Hz. The range of the end frequency is 51Hz to 15000Hz. (has to be bigger than start frequency)

  • Step Size – Type: integer, Default: 1, Min: 0, Max: 14950
  • Size of one step of the sweep between the start/end frequencies in Hz. 1Hz - 65536Hz (has to be small enough to fit into the frequency range)

  • Step Delay – Type: integer, Default: 1, Min: 0, Max: 65535
  • Delay between two steps (duration of time that one tone is used in a sweep) in ms. 1ms - 65535ms (has to be small enough to fit into the duration)

  • Default Volume – Type: integer, Default: 0, Min: 0, Max: 10
  • The volume to start the alarm with. The range of the volume is 0 to 10.

  • Duration – Type: integer, Default: 0
  • The duration in ms to sound the alarm for. A duration of 0 stops the current alarm if any is ongoing. A duration of 4294967295 results in an infinite alarm.
Volume

Volume of an ongoing beep or alarm. The range of the volume is 0 to 10.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletpiezospeakerv2:[UID]:BrickletPiezoSpeakerV2Volume
Read only:
  • No
Range:
  • 0 to 10 (Step 1)
Beep Frequency

Frequency of an ongoing beep. The range of the frequency is 50Hz to 15000Hz.

Type:
  • Number:Frequency
UID:
  • tinkerforge:brickletpiezospeakerv2:[UID]:BrickletPiezoSpeakerV2BeepFrequency
Read only:
  • No
Unit:
  • Hertz
Range:
  • 50 Hertz to 15000 Hertz (Step 1 Hertz)

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

Basic Actions

brickletPiezoSpeakerV2SetBeep(int frequency, int volume, long duration)
Parameters:
  • frequency – Type: int, Unit: 1 Hz, Range: [50 to 15000]
  • volume – Type: int, Range: [0 to 10]
  • duration – Type: long, Unit: 1 ms, Range: [0 to 232 - 1] with constants

Beeps with the given frequency and volume for the duration.

A duration of 0 stops the current beep if any is ongoing. A duration of 4294967295 results in an infinite beep.

The following constants are available for this function:

For duration:

  • val BEEP_DURATION_OFF = 0
  • val BEEP_DURATION_INFINITE = 4294967295
brickletPiezoSpeakerV2GetBeep()
Return Map:
  • frequency – Type: int, Unit: 1 Hz, Range: [50 to 15000]
  • volume – Type: int, Range: [0 to 10]
  • duration – Type: long, Unit: 1 ms, Range: [0 to 232 - 1] with constants
  • durationRemaining – Type: long, Unit: 1 ms, Range: [0 to 232 - 1]

Returns the last beep settings as set by Beep. If a beep is currently running it also returns the remaining duration of the beep.

If the frequency or volume is updated during a beep (with Beep Frequency or Volume) this function returns the updated value.

The following constants are available for this function:

For duration:

  • val BEEP_DURATION_OFF = 0
  • val BEEP_DURATION_INFINITE = 4294967295
brickletPiezoSpeakerV2SetAlarm(int startFrequency, int endFrequency, int stepSize, int stepDelay, int volume, long duration)
Parameters:
  • startFrequency – Type: int, Unit: 1 Hz, Range: [50 to 14999]
  • endFrequency – Type: int, Unit: 1 Hz, Range: [51 to 15000]
  • stepSize – Type: int, Unit: 1 Hz, Range: [0 to 14950]
  • stepDelay – Type: int, Unit: 1 ms, Range: [0 to 216 - 1]
  • volume – Type: int, Range: [0 to 10]
  • duration – Type: long, Unit: 1 ms, Range: [0 to 232 - 1] with constants

Creates an alarm (a tone that goes back and force between two specified frequencies).

The following parameters can be set:

  • Start Frequency: Start frequency of the alarm.
  • End Frequency: End frequency of the alarm.
  • Step Size: Size of one step of the sweep between the start/end frequencies.
  • Step Delay: Delay between two steps (duration of time that one tone is used in a sweep).
  • Duration: Duration of the alarm.

A duration of 0 stops the current alarm if any is ongoing. A duration of 4294967295 results in an infinite alarm.

Below you can find two sets of example settings that you can try out. You can use these as a starting point to find an alarm signal that suits your application.

Example 1: 10 seconds of loud annoying fast alarm

  • Start Frequency = 800
  • End Frequency = 2000
  • Step Size = 10
  • Step Delay = 1
  • Volume = 10
  • Duration = 10000

Example 2: 10 seconds of soft siren sound with slow build-up

  • Start Frequency = 250
  • End Frequency = 750
  • Step Size = 1
  • Step Delay = 5
  • Volume = 0
  • Duration = 10000

The following conditions must be met:

  • Start Frequency: has to be smaller than end frequency
  • End Frequency: has to be bigger than start frequency
  • Step Size: has to be small enough to fit into the frequency range
  • Step Delay: has to be small enough to fit into the duration

The following constants are available for this function:

For duration:

  • val ALARM_DURATION_OFF = 0
  • val ALARM_DURATION_INFINITE = 4294967295
brickletPiezoSpeakerV2GetAlarm()
Return Map:
  • startFrequency – Type: int, Unit: 1 Hz, Range: [50 to 14999]
  • endFrequency – Type: int, Unit: 1 Hz, Range: [51 to 15000]
  • stepSize – Type: int, Unit: 1 Hz, Range: [50 to 14950]
  • stepDelay – Type: int, Unit: 1 ms, Range: [0 to 216 - 1]
  • volume – Type: int, Range: [0 to 10]
  • duration – Type: long, Unit: 1 ms, Range: [0 to 232 - 1] with constants
  • durationRemaining – Type: long, Unit: 1 ms, Range: [0 to 232 - 1] with constants
  • currentFrequency – Type: int, Unit: 1 Hz, Range: [50 to 15000]

Returns the last alarm settings as set by Alarm. If an alarm is currently running it also returns the remaining duration of the alarm as well as the current frequency of the alarm.

If the volume is updated during an alarm (with Volume) this function returns the updated value.

The following constants are available for this function:

For duration:

  • val ALARM_DURATION_OFF = 0
  • val ALARM_DURATION_INFINITE = 4294967295

For durationRemaining:

  • val ALARM_DURATION_OFF = 0
  • val ALARM_DURATION_INFINITE = 4294967295
brickletPiezoSpeakerV2UpdateVolume(int volume)
Parameters:
  • volume – Type: int, Range: [0 to 10]

Updates the volume of an ongoing beep or alarm.

brickletPiezoSpeakerV2UpdateFrequency(int frequency)
Parameters:
  • frequency – Type: int, Unit: 1 Hz, Range: [50 to 15000]

Updates the frequency of an ongoing beep.

Advanced Actions

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

brickletPiezoSpeakerV2GetStatusLEDConfig()
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
brickletPiezoSpeakerV2GetSPITFPErrorCount()
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.

brickletPiezoSpeakerV2GetIdentity()
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

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