Python driver for the SparkFun SPX-17979 Qwiic Sound Trigger.
The package is available on PyPI. Installation is can be done with your favourite package manager. For example:
pip install spx17979-driver
In order to initialise the device we need an open SMBus
object.
Depending on the machine that you are running on you may need to provide another bus number or path:
from spx17979 import SPX17979
from smbus2 import SMBus
with SMBus(1) as bus:
device = SPX17979(bus=bus)
When the device has been triggered by a sound, the trigger
property will be True
.
It can be reset by calling the reset()
method. That is it!
A simple usage example:
from time import sleep
from spx17979 import SPX17979
from smbus2 import SMBus
with SMBus(1) as bus:
device = SPX17979(bus=bus)
device.reset()
while True:
if device.trigger:
print("Triggered!")
sleep(0.5) # Prevent triggering twice on the same sound
device.reset()
sleep(0.001)