Firmware · Nov 2026 · simulated, not yet on hardware

dún firmware

one press. is my ear tired?

The firmware for dún, the earbud that listens for the faint sound a healthy ear makes back. It turns that earbud into an ear-fatigue tracker. Save a baseline over three quiet days, then after a gig, a club or a long session in headphones press the button once, and it tells you whether your ear's echoes have dropped against your own baseline, and at which pitches.

Zephyr RTOS
nRF52840
C99 DSP
Bluetooth LE

One button, one light

Loud sound can leave the ear's echoes weaker for a while. Echoes differ a lot from one person to the next, so the useful comparison is with your own ear rather than with a chart: same person, same earbud, before and after.

The device has no screen. A short press runs a check. Holding the button for three seconds adds the last check to your baseline, which is the middle of three quiet-day checks, so one odd day doesn't set the bar. Ten seconds clears it.

The board keeps its own dated history of the last 64 checks in flash, so it can say which pitches keep dipping without a phone. Every result also goes out as a JSON line over USB and as a Bluetooth notification.

The lightMeans
Slow blinkTesting
One long flashSteady: no drop from your baseline
Five quick flashesDip: your echoes are lower
Three quick flashesReseat the earbud
Two flashesRetest, or baseline not finished
One very long flash afterA pitch keeps dipping
1, 2 or 3 flashes on a holdThat baseline check saved

How one check works

The check uses two tones rather than clicks. Each speaker plays one steady tone, and a working ear mixes them and adds a third note at 2f1 − f2 that neither speaker played. Six pairs of tones cover 1 to 6 kHz, and each pitch is measured on its own, which is what a before-and-after comparison needs. Each check goes into the history, and a pitch that dipped in three of its last five checks is flagged as one that keeps dipping.

  1. Check the room
    The room mic listens first. Over 60 dB SPL and the check refuses, rather than measure a noisy ear.
  2. Check the fit
    One speaker plays a low and a mid tone together. A leak drains the low one first, so if their gap has moved more than 4 dB from your baseline days, it stops in a second and asks you to reseat.
  3. Calibrate in the ear
    Each speaker plays each tone alone, starting very quiet and stepping up 10 dB, until the ear mic hears it. Now the levels are right for this fit.
  4. Measure six pitches
    Both tones at 65 and 55 dB SPL. Blocks spoiled by a swallow or a bump are thrown out, and averaging stops as soon as the answer is clear.
  5. Compare
    Against the baseline, pitch by pitch: steady, dip, or retest when the fit or the room can't be trusted.

A pitch counts as dropped when its echo falls 5 dB below the baseline, or further if that pitch varied across your three baseline days. The verdict is a dip when two or more pitches drop that far, or the average drop is 4 dB or more. An echo that has vanished counts as a drop down to the detection limit, but only if the noise floor was low enough that it would have been seen.

Noise damage usually shows first around 3 to 6 kHz, so the upper pitches matter most. The top one stops at 6 kHz because the sample rate puts the ceiling at 7.8.

f2 Hzf1 HzEcho, 2f1 − f2
1007824641
14951221946
199916331267
300624571907
399832812564
599749133830

The decisions

One tone per speaker

A single cheap speaker playing both tones makes its own 2f1 − f2, which would look like a healthy ear in an empty tube. Speaker 1 only ever plays f1 and speaker 2 only f2, so any third note has to come from the ear.

Every tone on a bin

Speakers and mics both run at 15,625 samples a second off one 32 MHz clock, so they never drift apart. Every tone is a whole number of 15.26 Hz bins, so each 65 ms block holds whole cycles and blocks can simply be averaged.

Quiet first, capped always

Calibration starts at −70 dBFS, so a speaker that turns out louder than expected can't blast the ear. Every tone is capped at 70 dB SPL at the ear and −6 dBFS in code, whatever calibration asks for. If the firmware hangs mid-tone, a guard timer cuts the amps within half a second and the hardware watchdog resets the chip after three.

Refuse rather than guess

A loose fit or a noisy room produces exactly the drop the device is looking for. So a leaking earbud is told to reseat, and too few clear pitches, a check mostly lost to swallowing, or a loud room gives retest, never a dip.

Stop when it is clear

After 24 kept blocks it checks every 8, and stops once the echo is 12 dB clear of the noise or the floor is low enough to rule one out, with at most 80 tries a pitch. A clear ear finishes fast; a hard one gets more time.

A core that never sees the board

The whole test is plain C99 with no allocation, talking to the hardware through three callbacks: play, stop and read. The same code runs against a simulated ear, earbud, mic and room on a laptop, and inside the Zephyr app on the XIAO.

What the simulation says

With no board made yet, the honest test is a simulated ear with the noise of the real microphone. The repository runs hundreds of them and counts how often each kind of ear gets each verdict.

Monte Carlo · 300 simulated ears
How big a drop it can see
0255075100% called a dip0246810dB the echoes fell, 3 and 4 kHzone pitch countsas dropped at 5 dBsame ear, reseated: neverreliable from 8 dBa coin toss at 6
Each point is the share of 300 simulated ears, each with its own three-check baseline, called a dip when their echoes fell by that much at 3 and 4 kHz. The simulation's noise is an estimate; the bench sets the real figures.
Simulated situationHow often
Same ear, reseated normally, called a dip or asked to retest0%
Echoes 10 dB lower, dip found98%
8 dB lower92%
6 dB lower49%
4 dB lower5%
Earbud leaking 3 to 8 dB, called a dip0%
Chewing, called a dip or retest0%
Swallowing in a noisy room, asked to retest16%
Plastic tube, a false echo at one pitch5%

So dún reliably sees drops of 8 dB or more, and smaller ones mostly sink into the noise. The fit check earns its place: a leaking earbud was always stopped to reseat, where without it a 5 dB leak was wrongly called a dip 5% of the time. The plastic tube never produced enough false echoes to reach a verdict.

Where it stands

Written and merged: the full test from room and fit check to verdict, the three-check baseline, the history and trend, and the speaker guard with the hardware watchdog, with 313 host checks against the simulated ear that all pass. The Zephyr app for the XIAO nRF52840 drives the speakers over I2S, both mics over PDM, Bluetooth, the button, the light and the flash. CI builds a firmware image on every push.

Not yet done: running it on real hardware at all, because no board has been made. The bench plan comes first: confirm the pins, the speakers and the microphone's sensitivity, make a hang on purpose to see the guard and watchdog cut the sound, then ten checks in a sealed 2 cc plastic tube, which must show no echoes. Only then an ear, where real reseats set the fit threshold. The hardware itself is on the dún experiment page.

A screening experiment, not a medical device. It can't diagnose hearing loss, and it never says hearing loss: it says your echoes are lower than your baseline. A drop that keeps coming back is a reason to see an audiologist. The tone settings and pass criteria follow the University of Washington's OAEbuds work (MobiSys 2023).