GitHub Digital Lab

Fox Red Labs / Builds / Edge AI

Hear a smoke alarm's beep pattern

It has heard only recorded alarm sounds from a laptop speaker and over USB; a real alarm was not tested.

HardNo wiring1 evening

The MSPM0 G5187 this build runs on, drawn from its user guide. Drag to turn it.

What you need

Works on this board
LP-MSPM0G5187
A smoke or CO alarm with a test buttonthe alarm it learns
A Macbuild, flash and the notification
On Linux or WindowsThe steps were recorded on a Mac; paths and port names in them are the Mac ones.

macOS (recorded)

TI's tools
/Applications/ti, or ~/ti
Serial port
/dev/cu.usbmodem<serial>1
Probe access
nothing to do

Linux

TI's tools
~/ti (also searched: /opt/ti)
Serial port
/dev/ttyACM0 (by name: /dev/serial/by-id/*<serial>*-if00*)
Probe access
one udev rule, how

Windows

TI's tools
C:\ti (also searched: %USERPROFILE%\ti)
Serial port
COM<n>, named "XDS110 Class Application/User UART" in Device Manager
Probe access
the XDS110 USB driver from UniFlash or CCStudio

Your probe's serial on any system: python3 tools/frl/frl.py detect. Not run on a board under Linux or Windows. Everything else that differs: the full table.

Steps

Set up your computer once: 1 step. Done already? Start at step 2.
  1. Install the tools in the list above, then get a copy of this repository.TERMINAL

    To fetch only the board folder, use the sparse-checkout line in its README. The trained model is already compiled for the NPU in mspm0g5187/alarm/model/nnc_g5187_npu/, so no training is needed.

    You should see: ls mspm0g5187/alarm/model/nnc_g5187_npu lists mod.a and tvmgen_default.h.

  1. Build the listener.TERMINAL

    The script copies one of TI's SDK examples for its makefile and puts the listener's code in. It links the NPU model and CMSIS-DSP, and builds in a scratch folder under your home folder.

    Replace <repository folder> before you run this.

    cd <repository folder> APP=detect bash mspm0g5187/alarm/build.sh

    You should see: A size line with text 80608 and bss 30417, which is 78.7 kB of flash and 29.7 kB of RAM, then image: mspm0g5187/alarm/out/alarm_detect.out.

  2. Plug the board into your computer and read its probe serial number: it is the text after usbmodem without the last digit.BENCH

    ls /dev/cu.usbmodem*

    You should see: Two lines with the same text, ending in 1 and 4, for example /dev/cu.usbmodem<probe serial>1 and /dev/cu.usbmodem<probe serial>4.

  3. Flash it.TERMINAL

    Make a copy of the connection file with your probe serial number in its name and inside it. The command below does both; replace <probe serial> with yours from step 3. Then load the image with UniFlash's command line (the path below is the Mac install folder). This is the board README's tested flash command with the listener's image in place of the blink.

    Replace <probe serial> before you run this.

    PROBE=<probe serial> sed "s/MG020001/$PROBE/g" mspm0g5187/MSPM0G5187_MG020001.ccxml > mspm0g5187/MSPM0G5187_$PROBE.ccxml /Applications/ti/uniflash_9.6.0/dslite.sh --mode flash -c mspm0g5187/MSPM0G5187_$PROBE.ccxml -e -f -v -u mspm0g5187/alarm/out/alarm_detect.out

    You should see: The flash ends without an error in about 5 s, and the green LED gives a short blink every 2 seconds, which means the board is listening. The LED lines are in detect.h, in the main loop.

  4. Start the listener's Mac script on the first serial port, the one ending in 1.TERMINAL

    It logs every line and turns an alarm into a Mac notification. Leave it running.

    Replace <probe serial> before you run this.

    PROBE=<probe serial> python3 mspm0g5187/alarm/host/listen.py --port /dev/cu.usbmodem${PROBE}1 --log ~/alarm.log

    You should see: The terminal stays quiet while the room is quiet. tail -f ~/alarm.log in a second window shows one I n=... cls=other line a second.

  5. Put the board beside your alarm, where it will stay.BENCH

    Press S2 once and the blue LED blinks fast. Then press and hold the alarm's test button until it has sounded for about 10 seconds. Ear protection helps; smoke alarms are loud up close.

    You should see: LEARNED cls=smoke f0=... L0=... saved in the terminal and the blue LED stops; the record is kept through a power cut. Not done with a real alarm: in these runs the learn step used alarm sound sent over USB. The 10 seconds is the expected time: four inferences that hear the pattern. It is not a measured time.

  6. Press the alarm's test button again.BENCH

    Then press S2 once to clear the alarm.

    You should see: ALARM smoke from the learned alarm and the red LED on. Expected about 10 s after the sound starts; measured 9.4 s with a laptop speaker and nothing learned. The script also raises a Mac notification; these runs did not record one. S2 prints CLEARED.

What to build next

Run an edge AI model on the chipA room-occupancy model answers on the chip, timed and checked against its test set
Recognize a handwritten digit on the chipDraw a digit with your finger; the chip names it on the screen
Run a vision model on a Linux board's AI acceleratorVision models from TI's zoo running on the accelerator of a Linux board

Every build

If something goes wrong

mod.a is missingThe clone did not bring the model; it is tracked in the repository, so clone again.
It cannot find spi_controller_echo_interrupts or tiarmclangThe SDK or CCStudio is not in TI's default install folder; set FRL_MSPM0_SDK and FRL_TICLANG.
Nothing listedThe cable or adapter is charge-only; swap it.
DSLite cannot find the probeThe serial number in the .ccxml does not match yours.
`ModuleNotFoundErrorNo module named 'serial'`: install pyserial, as in the list above. No lines in the log: check that the port ends in 1 and not 4.
More troubleshooting
`LEARN FAILEDNo smoke or CO pattern heard in 45 s: hold the test button longer, or move the board closer. To start over, hold S2 for 5 s until FORGOT: generic mode`.
`IGNORED Too quiet` means the board is farther from the alarm than when it learned; learn again in its final place (FAQ).

Every fix for this board: the FAQ.

Get the code

Paste this in a terminal. It hands off to an AI assistant.

git clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs ./start.sh mspm0g5187 alarm-listener --assistant claude
Not Claude Code? Copy this prompt instead.
Clone https://github.com/Fox-Red-Labs/fox-red-labs and read mspm0g5187/AGENTS.md first. Then run Detect a smoke alarm's beeps with a microphone on my LP-MSPM0G5187, following docs/builds/alarm-listener.md. Tell me when to plug in a board and what you saw at each step.

The code is in mspm0g5187/, with notes for your AI assistant in AGENTS.md.

Reports from others, and the report forms

Clone the repository and open the board's folder below. AGENTS.md is a plain text file of notes for AI coding assistants, and llms.txt at the root indexes the site for one.

git clone https://github.com/Fox-Red-Labs/fox-red-labs.git

Code is BSD-3-Clause, writing is CC BY 4.0; third-party folders keep their own licenses.

Built it? Tell us

Built this, or got stuck? Report it on GitHub with a few short answers. Your report shows here in your words, marked as yours. A failure that repeats on the bench gets its fix here.

Evidence and limitsThe MSPM0 G5187 reported a smoke alarm pattern from a laptop speaker 9.4 s after it started, through its own microphone, and gave 0 alarms in 3.4 hours of a quiet room. Learning has run only on audio sent over USB; a real alarm's horn is the test still to run. Results, sources, timing and limits.

Expected result: Expected from the speaker and USB runs, and not seen with a real alarm: your alarm's test sound is reported as smoke, or as CO for a CO alarm, about 10 s after it starts. Beeping from a TV, a kettle, a whistle, a phone or an oven timer is not reported. Neither is the same alarm pattern played quieter or at another pitch.

What this shows

  • A 13.8k-parameter model runs on the MSPM0G5187's NPU, on its own microphone, once a second. It takes 20.2 ms per inference in the self-test and 32.4 ms median live, and keeps up in real time.
  • With nothing learned it reported a smoke alarm pattern from a laptop speaker 9.4 s after it started, and stayed silent through 3.4 hours of a quiet room, 12.1k inferences.
  • With an alarm learned, on audio streamed over USB and no sound played, it ignored 18 of 18 look-alike sounds. These were oven timers, backup beepers, whistles, a kettle, ringtones, speech and music. It also ignored the same alarm 31 dB quieter, and the same pattern at 3,600 Hz instead of 3,150 Hz.
  • The learned-alarm rules were applied afterwards to the board's logged answers from the speaker run. They silenced all 16 look-alikes and the same alarm about 22 dB quieter, and still passed the alarm. It was a replay of logged answers; nothing was decided live.
  • It tells smoke (three beeps) from CO (four short pulses) on the same horn.
What this does not establish, and limits

What this does not establish

  • That it learns a real smoke alarm's horn: every alarm sound was synthetic, from a laptop speaker or sent over USB. A real horn has harmonics and sometimes a warble that the training never heard.
  • False alarms over weeks in a busy house: 3.4 hours of a quiet room and 2 hours of held-out synthetic scenes are what was measured.
  • Doorbells: there is no standard doorbell pattern, and none was built.
  • That it replaces a connected or monitored alarm. It is a demonstration and is not a listed safety device.

Limits to keep in mind

  • On this board PB10 and PB11 are both the microphone's clock lines and the BP-CC1407P radio's reset and interrupt wires. The listener and that radio cannot share J20 as wired here.
  • The Mac script is the notification path in this version; the board on its own only lights its red LED.
  • Placement matters: it learns how loud the alarm is where the board sits, and ignores anything more than 10 dB quieter. Move the board and learn again.

Sources

Why this board

The MSPM0 G5187 is the one board here with a microphone, an audio converter and a neural network accelerator on it, so the listener needs no extra parts.

Versions, sizes and timing

ModelFive-layer 1-D CNN, 13.8k parameters, 8-bit quantization-aware training, compiled with TI's NNC for the TinyEngine NPU; 16 inputs by 128 frames (8.3 s); answers other, smoke, CO once a secondREADME notes
Inference20.2 ms per inference in the self-test (6 of 6 classes matched onnxruntime); 32.4 ms median over 443 inferences in the live runMSPM0G5187 alarm listener notes
AudioOnboard ICS-40720 microphone into the PCM1809, I2S at 47,619 Hz, filtered to 15,873 Hz; 13 features every 64.5 ms from two 512-point FFTs (CMSIS-DSP)README notes
Decision6 of the last 8 answers agree, the NFPA 72 timing check passes, and once learned the tone is within 4 % and the level no more than 10 dB below the learned oneREADME notes
Image78.7 kB of flash of 128 kB, 29.7 kB of RAM of 32 kB, from tiarmsize on the 2026-10-13 build
ToolsMSPM0 SDK 2.11.00.07, TI Arm Clang 5.1.1.LTS, SysConfig 1.26.3, UniFlash 9.6.0, Intel Mac, macOS 15.7MSPM0G5187 alarm listener notes

Evidence

  • On 2026-10-13 a laptop speaker beside the board played 16 look-alike sounds and a smoke alarm pattern through the board's own microphone. The pattern was reported as smoke 9.4 s after it started; 14 of the 16 look-alikes stayed silent with nothing learned. Nothing was learned live in this run. MSPM0G5187 alarm listener notes
  • Audio was streamed over USB onto real room sound, with no sound played. The board learned a smoke alarm, saved it and alarmed on it. It ignored 18 of 18 look-alikes, the same alarm 31 dB quieter, another pitch and a CO pattern.
  • The two look-alikes that alarmed were CO-like patterns; after a fix to the CO timing check both stay silent, and a CO pattern from the learned horn is reported as CO.

Other boards

What the status words mean

Works ran here and did what it shouldCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why

Result grid

Project
LP-MSPM0G3507MSPM0G3507 chip
LP-MSPM0L1306MSPM0L1306 chip
LP-EM-CC2340R5CC2340R52 chip
LAUNCHXL-F2800137TMS320F2800137 chip
Detect a smoke alarm's beeps with a microphone
LP-MSPM0G3507
LP-MSPM0L1306
LP-EM-CC2340R5
LAUNCHXL-F2800137

Works ran here and did what it shouldShould work it builds; only naming, packaging or build glue is in the way; hover for whichCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why

Experiments (1)

StatusWhat was triedResult
Could workCan the LP-MSPM0G5187's NPU learn your smoke or CO alarm by ear and ignore every other sound?
MSPM0 G5187, 2026-10-13
A 13.8k-parameter model on the MSPM0 G5187's NPU, listening through the onboard microphone, reported a smoke alarm pattern from a laptop speaker 9.4 s after it started, kept 14 of 16 look-alike sounds silent with...

Source files

Code brought from elsewhere

This project uses code that was written for other chips or tools. Each links to how to get it running.

Start with your code, and the prompt to port your own