Real-time glass-break detection with Machine Learning, Edge Impulse, and the Qualcomm-powered RUBIK Pi 3.
This project demonstrates how to deploy an audio classification model on a Thundercomm RUBIK Pi 3 and use the classification result to trigger physical hardware through GPIO.
A USB microphone continuously captures ambient sound. An Edge Impulse model classifies the audio as normal street noise or breaking glass. When the confidence for the glass class exceeds a configured threshold, a GPIO output is activated.
The example implementation lights an LED, but the same signal could trigger a siren, relay, notification service, recording system, or other automation.
β οΈ This is an experimental Machine Learning project. It should not be treated as a certified alarm or security system.
- ποΈ Real-time audio classification
- π§ Machine Learning with Edge Impulse
- πͺ Glass-break detection
- β‘ Local inference on RUBIK Pi 3
- π Qualcomm Dragonwing QCS6490 platform
- π Python result parser
- π¨ Configurable confidence threshold
- π‘ GPIO response when glass is detected
- β±οΈ Configurable output activation time
- π€ Standard USB microphone input
- π§ Canonical Ubuntu environment
- π MIT licensed
The original experiment was motivated by detecting the characteristic sound of a car window being broken.
Instead of continuously monitoring video footage, a dedicated edge device can listen for a particular acoustic event:
Street sound
β
Microphone
β
Audio classifier
β
Is it breaking glass?
β
YES
β
GPIO alert
The same architecture can be adapted to many other acoustic-event detection tasks.
βββββββββββββββββββββββββββββ
β Ambient Sound β
β β
β traffic / voices / glass β
βββββββββββββββ¬ββββββββββββββ
β
βΌ
ββββββββββββββββ
β USB Microphoneβ
βββββββββ¬βββββββ
β
βΌ
βββββββββββββββββββββββββββββ
β RUBIK Pi 3 β
β β
β Edge Impulse Linux Runner β
β β
β Audio inference β
βββββββββββββββ¬ββββββββββββββ
β
β classifyRes
βΌ
βββββββββββββββββββββββββββββ
β glass.py β
β β
β β’ Parse probabilities β
β β’ Read `glass` confidence β
β β’ Apply 75% threshold β
βββββββββββββββ¬ββββββββββββββ
β
β GPIO
βΌ
βββββββββββββ
β LED β
β / Alarm β
βββββββββββββ
The model is built and deployed with Edge Impulse.
Two main sound categories are used:
street
glass
The project trains an audio classifier using recordings of:
- normal street noise
- breaking glass
The resulting model is deployed to the RUBIK Pi through the Edge Impulse Linux runner.
Example inference output:
classifyRes 2ms. { street: 0.9999, glass: 0.0001 }
classifyRes 2ms. { street: 0.8629, glass: 0.1371 }
The Python script continuously parses these results.
The Machine Learning project is publicly available in Edge Impulse Studio:
Open the public Edge Impulse project
The Edge Impulse project can be used to inspect the dataset, impulse configuration, training process, and deployment options.
The project runs on the Thundercomm RUBIK Pi 3, a Raspberry Pi-style edge-AI development platform based on the Qualcomm Dragonwing QCS6490.
Relevant specifications include:
| Specification | RUBIK Pi 3 |
|---|---|
| Platform | Qualcomm Dragonwing QCS6490 |
| CPU | Kryo / Cortex-A78 + Cortex-A55 |
| GPU | Adreno 643 |
| AI performance | Up to 12 TOPS |
| RAM | 8 GB LPDDR4x |
| Storage | 128 GB UFS 2.2 |
| Network | Gigabit Ethernet, Wi-Fi |
| GPIO | 40-pin header |
| Audio | USB / 3.5 mm interfaces |
Official documentation:
βΉοΈ The original tutorial instructs Edge Impulse users to select the unoptimized Linux deployment option. The RUBIK Pi hardware includes Qualcomm AI acceleration capabilities, but this particular example should not be assumed to use the NPU unless an optimized deployment is explicitly selected.
| Component | Purpose |
|---|---|
| Thundercomm RUBIK Pi 3 | Edge inference and GPIO control |
| RUBIK Pi active cooler | Thermal management |
| 12 V / 3 A USB-C PD supply | Power |
| USB microphone | Audio capture |
| LED | Detection indicator |
| 2 jumper wires | LED connection |
| Ethernet cable | Initial networking / SSH |
A microphone connected to the 3.5 mm audio interface can also be used if appropriately configured.
The reference build connects an LED between:
RUBIK Pi GPIO header pin 13
β
βΌ
LED
β
βΌ
Pin 6 / GND
The RUBIK Pi Linux GPIO mapping used by the Python program is:
GPIO_PIN = 571This corresponds to header pin 13 in the project configuration.
The repository contains a single Python application:
glass.py
It performs four main tasks:
Start Edge Impulse runner
β
Read inference output
β
Extract classification scores
β
Trigger GPIO when glass is detected
The current source defines:
CONFIDENCE_THRESHOLD = 75.0This means the GPIO alert is activated when:
glass confidence β₯ 75%
For example:
street: 18.00%
glass: 82.00%
results in:
π¨ WINDOW BREAK SOUND DETECTED!
When detection exceeds the threshold, the script activates the output:
out_gpio.write(True)The LED remains on for:
LED_ON_TIME = 3seconds.
Then the output returns low:
out_gpio.write(False)Conceptually:
Glass confidence
β
β β₯ 75%
βΌ
GPIO HIGH
β
β 3 seconds
βΌ
GPIO LOW
glass.py launches the Edge Impulse runner directly:
RUNNER_PATH = "/home/ubuntu/edge-impulse-tools/node/bin/edge-impulse-linux-runner"and writes its output to:
output.txt
The script monitors the file and searches for lines matching:
classifyRes ... { ... }
It then converts the classification result into JSON-compatible data and reads the individual scores.
For example:
classifyRes 53ms. {'glass': 0.91, 'street': 0.09}
becomes approximately:
{
"glass": 0.91,
"street": 0.09
}The glass value is converted to a percentage before being compared with the configured threshold.
git clone https://github.com/ronibandini/Rubik-Pi-AudioClassification.git
cd Rubik-Pi-AudioClassificationRepository structure:
Rubik-Pi-AudioClassification/
βββ LICENSE
βββ README.md
βββ glass.py
The project tutorial assumes the RUBIK Pi is running:
Canonical Ubuntu for Qualcomm platforms
Connect:
- power supply
- USB microphone
- Ethernet
Boot the RUBIK Pi and obtain its IP address from your router or local console.
Then connect through SSH:
ssh ubuntu@RUBIK_PI_IPUpdate the system:
sudo apt updateDownload the Qualcomm Linux setup script:
wget https://cdn.edgeimpulse.com/firmware/linux/setup-edge-impulse-qc-linux.shInstall the SELinux utility required by the setup:
sudo apt install selinux-utilsThen:
source ~/.profile
chmod +x setup-edge-impulse-qc-linux.sh
./setup-edge-impulse-qc-linux.shOfficial Edge Impulse documentation:
Audio Classification and GPIO Response β RUBIK Pi 3
Connect the USB microphone and run:
alsamixerPress:
F6
to select the USB input.
Increase the recording level if required using the arrow keys.
Install:
sudo apt install python3-pip
sudo apt install python3-peripheryThe script imports:
from periphery import GPIOCreate a GPIO user group:
sudo groupadd -f gpio
sudo usermod -aG gpio ubuntuEdit:
sudo nano /etc/udev/rules.d/99-gpio.rulesAdd rules granting the gpio group access to GPIO devices.
After saving the file:
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo rebootReconnect to the board after reboot.
Run:
edge-impulse-linux-runner --cleanLog in with your Edge Impulse account.
Select:
- the audio-classification project
- the unoptimized model
- the USB microphone
You should begin seeing output similar to:
classifyRes 2ms. { street: 0.9999, glass: 0.0001 }
Stop the runner with:
CTRL-C
Start:
python3 glass.pyThe application displays:
Machine Learning with Edge Impulse
Monitoring for glass breaking sounds...
Stop with CTRL-C
When a classification arrives, the scores are printed:
--- Inference ---
street: 4.23%
glass: 95.77%
If the confidence exceeds 75%:
π¨ WINDOW BREAK SOUND DETECTED!
π’ Alert LED activated on GPIO 571
Three seconds later:
π΄ Alert LED deactivated
Stop the program with:
CTRL-C
The script closes the GPIO cleanly before terminating.
The main configuration values are at the beginning of glass.py:
CONFIDENCE_THRESHOLD = 75.0
GPIO_PIN = 571
LED_ON_TIME = 3| Variable | Default | Purpose |
|---|---|---|
CONFIDENCE_THRESHOLD |
75.0 |
Minimum glass probability |
GPIO_PIN |
571 |
Linux GPIO number |
LED_ON_TIME |
3 |
Output duration in seconds |
-
π² Send notifications β call a webhook when glass is detected to trigger WhatsApp, email, Telegram, n8n, Home Assistant, or another automation system.
-
πΉ Trigger video recording β connect the detector to a security camera and preserve footage from immediately before and after the acoustic event.
-
π§ Add more sound classes β extend the model to distinguish breaking glass from alarms, impacts, car horns, shouting, or other urban acoustic events.
This project is documented and indexed outside GitHub on both Edge Impulse and the official RUBIK Pi / Thundercomm documentation.
Audio Classification and GPIO Response β RUBIK Pi 3
Edge Impulse hosts the complete project in its official Expert Network documentation.
The page covers:
- project motivation
- RUBIK Pi 3 specifications
- hardware setup
- Edge Impulse installation
- audio dataset
- USB microphone setup
- GPIO configuration
- Python parser
- alert output
- possible webhook integration
Most importantly, the Edge Impulse page explicitly references this repository:
github.com/ronibandini/Rubik-Pi-AudioClassification
Edge Impulse Expert Network β Project List
Edge Impulse also lists:
Audio Classification and GPIO Response - Rubik Pi 3
among its Featured Machine Learning Projects.
Rubik Pi Audio Classification β Edge Impulse Studio
Public Edge Impulse Studio project associated with the audio-classification experiment.
Audio Classification and GPIO Response β RUBIK Pi 3
Thundercomm includes the project directly in the official RUBIK Pi 3 documentation.
The page identifies:
Created By: Roni Bandini
and explicitly links to:
- the public Edge Impulse project
- this GitHub repository
It documents the complete workflow from hardware setup through audio inference and GPIO activation.
RUBIK Pi β AI & Machine Learning
Thundercomm also indexes the project as one of the official RUBIK Pi AI/ML examples alongside other edge-AI applications.
Other projects by Roni Bandini involving Edge Impulse, audio classification, and the RUBIK Pi.
Anomaly detection on the RUBIK Pi 3 using Edge Impulse and n8n.
The closest companion project in terms of hardware: it also explores Machine Learning deployment on the Qualcomm-powered RUBIK Pi 3, with n8n handling the higher-level automation workflow.
github.com/ronibandini/rubikpi3-anomaly-detection
Punched-card recognition using computer vision, Edge Impulse, and LattePanda IOTA.
Another Edge Impulse project demonstrating how local inference results can be consumed by a small Python application running on Linux edge hardware.
github.com/ronibandini/PunchedCards
Machine Learning audio classification with a Raspberry Pi and Edge Impulse.
Another project centered on real-time audio classification, where the detected sound class triggers a physical/wireless response.
github.com/ronibandini/reggaetonBeGone
Audio classification is probabilistic.
Factors that can affect accuracy include:
- microphone sensitivity
- microphone placement
- distance from the sound source
- room acoustics
- background noise
- audio clipping
- sounds similar to breaking glass
- differences between training and real-world environments
The 75% confidence threshold is an experimental value, not a guaranteed security threshold.
For a real alarm application, consider combining audio classification with additional evidence such as:
audio detection
+
camera event
+
vibration sensor
+
multiple consecutive classifications
Rubik-Pi-AudioClassification is released under the MIT License.
See LICENSE for details.
Roni Bandini
Maker, AI developer, electronic artist and writer.
- π GitHub: @ronibandini
- πΈ Instagram: @ronibandini
- π¦ X: @RoniBandini
- βοΈ Medium: bandini.medium.com
- π€ Edge Impulse: Expert Network
Contributions, forks, alternative sound models, notification integrations, and other RUBIK Pi experiments are welcome.
