Sonar · measure a room with sound

Your phone already owns a speaker and a microphone a few centimetres apart. That is a sonar. It chirps 2–10 kHz for eight milliseconds, matched-filters what comes back, and reads the distance to every hard surface in front of it from the echo delay. No tape, no laser, no app to install — and the same trick a bat uses, at 30 cm accuracy.

Echo profile — distance, not time

Point the top of the phone at a flat wall, 0.5–8 m away, and press Ping.
Method: 8 ms linear chirp sweeping 2→10 kHz, matched filter (cross-correlation with the transmitted waveform) against the recording, then envelope detection. Matched filtering means range resolution comes from bandwidth, not chirp length: 8 kHz of sweep → c/2B ≈ 2 cm of theoretical separation. Eight pings are averaged and aligned on their own direct-path peak, which cancels the unknown latency between the audio output and the microphone — the thing that makes naive browser sonar unusable. The first 1.5 ms after the direct path is blanked (speaker ringing), so the minimum range is about 25 cm.
m
nearest hard surface

Floor plan

Turn on the spot: each ping is plotted at the current heading (compass if the phone grants it, otherwise the step wheel — 15° per ping gets a room in 24 pings). Straight walls fall out as straight runs of dots. Area is estimated with the shoelace formula over the hull of the readings.