API Reference

qwiic_buzzer

Python module for the SparkFun Qwiic Buzzer This is a port of the existing Arduino Library This package can be used with the overall SparkFun Qwiic Python Package New to Qwiic? Take a look at the entire SparkFun Qwiic ecosystem

class qwiic_buzzer.QwiicBuzzer(address=None, i2c_driver=None)[source]

SparkFun Qwiic Buzzer Initialise the Qwiic Buzzer at address with i2c_driver.

param address

The I2C address to use for the device. If not provided, the default address is used.

param i2c_driver

An existing i2c driver object. If not provided a driver object is created.

return

Constructor Initialization True- Successful False- Issue loading I2C driver

rtype

Bool

begin()[source]

Initializes this device with default parameters Run is_connected() and check the ID in the ID register

Returns

Returns True if successful, otherwise False

Return type

bool

change_address(address)[source]

Changes the I2C address of the Qwiic Buzzer

Parameters

address (int) – New address, must be in the range 0x08 to 0x77

Returns

Returns True if successful, otherwise False

Return type

bool

configure(frequency=2730, duration=0, volume=4)[source]

Configures the Qwiic Buzzer without causing the buzzer to buzz. This allows configuration in silence (before you may want to buzz). It is also useful in combination with saveSettings(), and then later causing buzzing by using the physical TRIGGER pin. To start buzzing (via Qwiic) with your desired configuration, use this function, then call on().

Parameters
  • frequency (int) – Frequency in Hz of buzzer tone

  • duration (int) – Duration in milliseconds (0 = forever)

  • volume (int) – Volume (4 settings; 0=off, 1=quiet… 4=loudest)

Returns

Returns true if the register write has completed

Return type

bool

property connected

Determines if this device is connected

Returns

True if connected, otherwise False

Return type

bool

firware_version_major()[source]

Reads the Firmware Version Major from the Qwiic Buzzer

Returns

Firmware Version Major

Return type

int

firware_version_minor()[source]

Reads the Firmware Version Minor from the Qwiic Buzzer

Returns

Firmware Version Minor

Return type

int

get_address()[source]

Gets the current I2C address of the Qwiic Buzzer

Returns

The current I2C address, 7-bit unshifted

Return type

int

is_connected()[source]

Determines if this device is connected

Returns

True if connected, otherwise False

Return type

bool

off()[source]

Turns off the buzzer

Returns

Returns true if the register write has completed

Return type

bool

on()[source]

Turns on the buzzer

Returns

Returns true if the register write has completed

Return type

bool

play_sound_effect(sound_effect_number=0, volume=4)[source]

Plays the desired sound effect at a specified volume

Parameters
  • sound_effect_number (int) – Which sound effect you’d like to play (0-9)

  • volume (int) – The volume of the sound effect played (1-4)

save_settings()[source]

Stores settings to EEPROM

Returns

Returns true if the register write has completed

Return type

bool

sound_effect_0(volume)[source]

Plays sound effect 0 (aka “Siren”) Intended to sound like a siren, starting at a low frequency, and then increasing rapidly up and then back down. This sound effect does a single “up and down” cycle.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_1(volume)[source]

Plays sound effect 1 (aka “3 Fast Sirens”) Intended to sound like a siren, starting at a low frequency, and then increasing rapidly up and then back down. This sound effect does this cycle of “up and down” three times rapidly.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_2(volume)[source]

Plays sound effect 2 (aka “robot saying ‘Yes’”) Intended to sound like a robot saying the word “yes”. It starts at a low frequency and quickly ramps up to a high frequency, then stops. This can be interpreted by most to be an affirmative sound to any question you may ask your buzzing robot.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_3(volume)[source]

Plays sound effect 3 (aka “robot yelling ‘YES!’” - faster) Intended to sound like a robot saying the word “yes”. It starts at a low frequency and quickly ramps up to a high frequency, then stops. This can be interpreted by most to be an affirmative sound to any question you may ask your buzzing robot. As this sound is done more quickly, it can add enthusiasm to the buzzing sound.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_4(volume)[source]

Plays sound effect 4 (aka “robot saying ‘No’”) Intended to sound like a robot saying the word “no”. It starts at a high frequency and quickly ramps down to a low frequency, then stops. This can be interpreted by most to be an negative sound to any question you may ask your buzzing robot.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_5(volume)[source]

Plays sound effect 5 (aka “robot yelling ‘NO!’” - faster) Intended to sound like a robot saying the word “no”. It starts at a high frequency and quickly ramps down to a low frequency, then stops. This can be interpreted by most to be an negative sound to any question you may ask your buzzing robot. As this sound is done more quickly, it can add enthusiasm to the buzzing sound.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_6(volume)[source]

Plays sound effect 6 (aka “Laughing Robot”) Intended to sound like your robot is laughing at you.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_7(volume)[source]

Plays sound effect 7 (aka “Laughing Robot Faster”) Intended to sound like your robot is laughing at you. As this sound is done more quickly, it can add enthusiasm to the buzzing sound.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_8(volume)[source]

Plays sound effect 8 (aka “Crying Robot”) Intended to sound like a robot is crying and sad.

Parameters

volume (int) – The volume of the sound effect played (1-4)

sound_effect_9(volume)[source]

Plays sound effect 9 (aka “Crying Robot Faster”) Intended to sound like a robot is crying and sad. As this sound is done more quickly, it can add enthusiasm to the buzzing sound.

Parameters

volume (int) – The volume of the sound effect played (1-4)