← All work

01 Final-year capstone built & tested 2026

CryNet

Two-cot infant cry detection with wearable caregiver alert

Two ESP32-C3 nodes sit with two cots, track their own noise floors, and freeze two seconds of audio when a sound crosses three times that floor. A 286-fragment ESP-NOW burst with CRC-16/CRC-32 carries the window to an ESP32-S3 hub, which computes the log-Mel front end in C (41.7 ms) and runs a 122,770-parameter INT8 CNN on-chip (101.8 ms) before paging a BLE wearable. Zero false alarms across 308 windows of real non-cry audio.

Role
Sole hardware & firmware engineer
Stack
ESP32-C3 ×3 · ESP32-S3 · TFLite Micro · ESP-DSP · Python
Headline
0.9993: Test AUC · INT8, all on-chip
01Overview

CryNet is a monitor for rooms with more than one cot: a NICU bay, a maternity ward, a daycare, a twin nursery at home. Two microphone nodes sit beside the cots and listen continuously. When a node hears something interesting, it freezes two seconds of audio and sends them to a central hub over a short-range radio link. The hub runs a small neural network on the clip and decides whether it is an infant cry. If it is, the hub names the cot on its display and sends an alert over Bluetooth, and a wristband turns that into a vibration.

Choice 1: who speaks

The nodes decide when to speak; the hub decides what it means. A node that hears nothing interesting sends almost nothing. That is what makes the radio work with two nodes sharing one channel, and it keeps a battery node alive for a whole shift.

Choice 2: who thinks

Only the hub runs the model. One ESP32-S3 with 8 MB of PSRAM is a far better home for a neural network than two small battery-powered nodes. It also means the model gets retrained and re-flashed in one place instead of at every cot.

Choice 3: who warns

The wearable is a dumb, reliable terminal. It runs no model. Receive alert, vibrate. Its only job is to be trusted with something the caregiver must not miss.

Hub panel, listening: two cot cards online
LISTENING · two cots linked, live level bars per cot
Hub panel with a cry detected on cot one, named, at 97 percent
CRY DETECTED · cot named, confidence on the panel

panel renders from the running hub · the same pixels the device draws

02The chain

The path of a cry, with the constants the firmware actually uses:

  1. capture16 kHz, 16-bit I²S off the INMP441, continuously. The node removes the DC bias the microphone sits at (~+18000 counts).
  2. track the floorA running noise floor: g_floor += (g_rms − g_floor) × 0.002, slow enough to ride out a scream and fast enough to follow a room.
  3. triggerLevel = 3 × floor, clamped to [0.005, 0.030]. Crossing it freezes a two-second window centred on the crossing, so the onset is kept rather than clipped off.
  4. offerThe node streams the window as a 286-fragment ESP-NOW burst (per-fragment CRC-16, whole-window CRC-32) and holds it until the hub pulls it.
  5. pullThe hub arbitrates between cots, reassembles the audio, and refuses the window outright if any sample clipped (peak ≥ 31,000 of 32,767; that saturation once made it name the wrong cot for 42 seconds).
  6. front endZero-padded 512-pt Hann FFT, 81 frames at hop 400 → 257 bins → 64 log-Mel bands → dB floored at −80 → per-window standardisation. Straight C on the ESP-DSP FFT: 41.7 ms.
  7. decideINT8 quantisation, TFLite Micro invoke with ESP-NN SIMD kernels: 101.8 ms for a 122,770-parameter CNN.
  8. announceOnly a near-saturated window announces alone; otherwise two consecutive windows must agree, the second carrying real energy and the right crest. On real room audio the model never sits between P(cry) 0.215 and 0.992; the rule is built on that gap.
  9. reach the wristA six-byte alert packet over BLE → 2.5 s haptic pulse train and a screen that names every crying cot (two-at-once staged on the bench: mask held at 0x03 for fifteen seconds).

The finding that forced the design

The original fixed trigger was RMS ≥ 0.030. The confusion session showed that a cry at one metre never reaches it: median RMS 0.0070, 0 of 590 records over threshold. So the system was blind at one metre by trigger, not by hearing. Asked anyway, the model still caught 18 of 44 windows. That measurement is why the adaptive 3×-floor trigger exists. After the change: 39 trigger events per minute at one metre instead of 0, and the hub asks 5–11 times a minute instead of 1–2.

03Hardware
Cot node × 2
ESP32-C3 Pro Mini + INMP441 I²S MEMS mic. GPIO4/5/6 for I²S, node ids 1 and 2 set over serial and kept in NVS, verified to survive a reflash. ESP-NOW channel 6. 75 % flash, 50 % RAM.
Hub
ESP32-S3-DevKitC-1 (dual-core LX7 @ 240 MHz, 512 KB SRAM, 8 MB PSRAM, 16 MB flash) + 2.8″ ILI9341 TFT on GPIO10–14, backlight GPIO4. 13.0 % RAM, 63.6 % flash.
Wearable
ESP32-C3 SuperMini + 0.96″ SSD1306 OLED + coin ERM motor on a BC547 low-side switch (GPIO7 → 2.2 kΩ → base, 22 Ω stall cap). 52 % flash, 5 % RAM.
The full CryNet system in printed enclosures: wearable, hub booting to its splash screen, both cot nodes
IN THE SHELLS · the wearable, the hub and both cot nodes
INSIDE THE SHELLS · the wearable going together: pack, buck and board into the enclosure
The real hub panel showing CRY DETECTED on cot one at 100 percent while the wearable names cot one
THE ALERT, END TO END · the hub names cot 1 at 100 %, the wrist names it too
Me assembling the CryNet hub enclosure at the bench
ASSEMBLING THE HUB
CryNet nodes and the TFT panel on breadboards during bring-up, firmware open on a laptop
BEFORE THE SHELLS · nodes and the TFT on breadboards
The wearable prototype on a breadboard, OLED showing CRYNET LINK and a cleared screen
THE WEARABLE, ON THE BENCH · OLED showing LINK
04The model

Before training anything I profiled every public infant-cry corpus on Kaggle and Hugging Face: sample rates, durations, F0, spectral flatness, real versus synthetic. Three of the five mirrors of one popular dataset were rejected outright. Their "silence" class is a constant 1,225 Hz tone at RMS 0.22, and their "noise" class is renamed ESC-50 files. Training on that teaches dataset artifacts, not cries.

Primary: ICD
28,478 clips, all 16 kHz mono / 5 s, five balanced folds. Cries from three independent corpora (hundreds of different infants); negatives are VoxCeleb speech, domestic noise, human non-speech, cat meows and silence.
Cry diversity
Baby Cry 4-class: 4,871 real cries, LUFS-normalised, VAD-trimmed, deduplicated. Held out as an unseen cross-corpus test.
Hard negatives
ESC-50 (1,960 non-cry clips: speech, laughing, vacuum, alarms, knocks) and a 1,000-clip snoring corpus: the confusion class a nursery monitor hits constantly.

The network is a compact CNN over the 81×64 log-Mel spectrogram: 122,770 parameters, 135 KB as INT8. Two decisions mattered more than the architecture:

  • The front end must match training exactly. Log-Mel computed by librosa and by naive firmware code differ enough to destroy accuracy, so the training notebook generates the Mel filterbank and Hann window as C tables, and the compiled front end is parity-tested against Python, with a measured worst-case deviation of 7 × 10⁻⁵, and on-chip ≤ 1 LSB with ≤ 1 % of the 5,184 features differing.
  • Confusers get mined, not tolerated. Coughing produced a 57 % false-alarm rate; acoustically, a cough is a vocal expulsion. After the main training, the notebook scores its own training set, takes the 600 most cry-like non-cry windows and the 600 least cry-like cry windows, and fine-tunes at 3× lower learning rate. Only training rows are mined, so the held-out folds stay honest. Cross-corpus false alarms fell 0.109 → 0.004 on the validation run, and music false alarms 8.19 % → 0.21 % after the retrain.

0.9994

ICD validation AUC · fold 4

0.9993

ICD test AUC · fold 5

0.9984

Cross-corpus AUC on unseen corpora, unseen babies

−0.0014

INT8 vs float32 ΔAUC · 99.956 % decision agreement

05Results

Measured on the desk and in the room, not only in the notebook. One caveat: every positive cry in these tests is a recording played through a phone speaker. The honest-status section below explains what that means.

The confusion session: nine one-minute takes on the real microphone

Speech, music, film and quiet, at desk / 30 cm / 1 m distances, cut into 308 non-cry windows:

0 / 308

False alarms on non-cry audio: speech, music, film, quiet

86.4 %

Recall on the cry at 15 cm (38/44 windows)

0 / 44

Loudest music this room can produce, refused post-retrain

20.5 min

Ambient room with people talking, 0 false alarms

The live chain: hub + node + a real BLE client

Radio integrity
286/286 fragments with CRC-32 MATCH, with a BLE client connected. 0 bad frames, 0 bad payloads over thousands of frames.
Burst duration
2.06–5.19 s, median 3.55 s, down from 5.54–6.93 s before the airtime fixes.
Request → verdict
2.23–5.35 s, mean 4.03 s, end to end.
Demo session
45 bursts, 45/45 complete: no stall, no timeout, no CRC error, no resend round. 26 alerts at P(cry) 0.9922–0.9961, 16 refusals at 0.0078–0.2148.
Verdict gap
Nothing between 0.2148 and 0.9922 in the whole session. On real audio in this room the model is never ambivalent: it is either near-zero or saturated.

The two-cot bench session, 2026-11-05/06

The session that says the system works, not just the components. Board identities were read from each boot banner before anything was flashed, and both cot ids survived the flash out of NVS.

Frames
993 frames off the air, 993 parsed, 0 bad, 0 bad payload: both cots heard and online.
A full burst
Node 2: 286/286 fragments in 0.99 s; window crc32 0xA8FCEBD5 → MATCH; the model ran on it and correctly refused room noise.
Alert + cancel
Console alert 2 → wrist ALERT cot 2 type 1 conf 100 %; clear → matching type-2 cancel on the wrist.
The bug it caught
The wrist still read 0 cot(s): the BLE state packet published only when a cry started or stopped, so a cot joining never reached the caregiver. Fix: rebuild the eight-byte packet every cycle and publish whenever the cry mask, deaf mask or cot count moves. Verified on hardware: the wrist now reads 2 cot(s).
Two at once
Two cots crying together staged 2026-11-20: the crying mask held at 0x03 for fifteen seconds, and the wrist screen names every crying cot (the alert packet names the loudest; one cry, one buzz).
06The dashboard

The monitor works with no network at all, but every cry the hub hears is written into its own flash first, and when it finds Wi-Fi it uploads what it has. The dashboard turns that record into something a caregiver can read: which cot, when, how long, how loud, and whether the nights are getting better or worse.

  • No dependencies. The server is one Python file using only the standard library and a SQLite file. python dashboard/server.py and it runs. A Cloudflare Worker build hosts a public copy: amazings-crynet.amazingadelowo.workers.dev.
  • A contract, tested. A hardware-free test builds the hub's upload body byte for byte, posts it, and checks what comes back, so the hub and the dashboard cannot drift apart silently.
  • The monitor wins over the record. The hub has one radio: if the router is not on channel 6, where ESP-NOW lives, the hub drops Wi-Fi and takes the radio back. A dashboard that looks healthy while the wrist has gone silent is the dangerous failure, so the firmware refuses to allow it.
Open the live dashboard ↗
The CryNet dashboard in the dark theme, demo data: episode totals, cries-by-day and night-by-night charts, the by-cot table The CryNet dashboard in the light theme, demo data

the caregiver dashboard · shown with demo data

07Honest status

The dossier opens with this section before any results, because these facts shape how every number should be read. A project page that hides them is not worth much.

O-2: no real infant yet

Every cry the model has been tested against is a recording played through a phone speaker: compressed, band-limited, EQ'd by a small loudspeaker in a plastic case. The negatives are authentic: this room, this microphone. On the proxy the model is strong; on a real infant it is unproven. This is the single largest accuracy risk in the project.

O-1d: no battery runtime measured

The wearable has run from its Li-Po pouch and kept working, so the battery path is not wholly untried. But no unit's battery life has been measured; the runtime figures that exist are projections, labelled as such. During the pouch session the haptic buzz went missing; a sagging 3.3 V rail is the live candidate and the investigation is open.

O-1c: what the zero watchdog does not cover yet

The node's I²S zero watchdog is on the boards. The dossier records two limits: it detects exact zeros only, so a microphone stuck at a DC value is not caught, and the fault-injection test proved the code executes and refills a window, not that it recovers the original physical fault. The closing test is a played-cry end-to-end run behind a real recovery. The microphone also has a measured close-range blind spot (O-1g): a source loud enough to drive it to the rail produces a window the hub refuses outright.

What the system is not

It is not a certified infant monitor; it is an academic prototype. It is not a cause classifier; the model is binary, cry or no cry, on purpose (the BLE packet has one bit for it). And it is not a replacement for a parent. It is a second pair of ears that wakes someone up. There is no battery monitoring either, by decision.

08Build it yourself

Everything needed to reproduce the build is written down, because the project was documented as if the next reader is a stranger with a soldering iron.

— end of case study —