Inspiration

Some time ago, I watched a fascinating video about an experiment where researchers were able to "see" through walls using WiFi waves. Leveraging the power and knowledge of modern AI, I decided to investigate if I could build something similar. Through a deep conversation with the AI about this technology, I learned that such a system required highly specialized and powerful hardware that I simply didn't have.

Instead of giving up, the AI and I brainstormed what kind of spatial sensing experiment we could build using only the standard sensors and capabilities of an everyday smartphone. That conversation sparked the idea for Echo Scan: using high-frequency acoustics (similar to ultrasound) to detect objects, turning a standard phone into a biomimetic sonar.

What it does

Echo Scan turns a standard Android phone into a short-range acoustic detector. When the user triggers a scan, the app emits a short, high-frequency sound (a 30 ms, 14-18 kHz Hann-windowed chirp). It simultaneously records the audio environment to capture the returning echo from a frontal object.

The app processes the captured audio locally to determine:

  1. Object Presence: Whether a dominant rigid object is present within 0.50 meters.
  2. Approximate Distance: If detected, it calculates the distance to the object.
  3. Confidence Level: It provides an honest assessment (High, Medium, Low) based on the signal-to-noise ratio and peak prominence, explicitly rejecting uncertain scans rather than guessing a false distance.

How we built it

We built Echo Scan natively for Android using Kotlin and Jetpack Compose. The core architecture follows a clean, highly testable core/data/domain/ui structure.

The Acoustic Engine: We bypassed standard Android voice processing by requesting the UNPROCESSED audio source to avoid automatic gain control (AGC) or system echo cancellation destroying our signal. We implemented a robust full-duplex audio pipeline using AudioTrack and AudioRecord to emit and capture 48 kHz, 16-bit PCM audio simultaneously.

To find the object, we perform cross-correlation between the known emitted chirp and the captured audio. Once we identify the direct speaker-to-mic coupling (our $t=0$ reference) and the prominent echo peak, we calculate the round-trip delay ($\Delta t$).

The distance $d$ is then calculated using the speed of sound $v$ (approx. $343 \text{ m/s}$), accounting for the journey to the object and back:

$$ d = \frac{v \cdot \Delta t}{2} $$

The AI Collaboration: This project was developed in close collaboration with OpenAI Codex and GPT-5.6 to fulfill the Build Week requirements. The models were instrumental in:

  • Scaffolding the Android project, Koin dependency injection, and testing architecture.
  • Writing the deterministic chirp generation and PCM manipulation utilities.
  • Designing the cross-correlation algorithm and near-field classification logic.
  • Building the responsive Jetpack Compose UI states.

Rather than just generating code, the AI acted as a true pair programmer (from the very first brainstorming session), helping us validate assumptions about Android's audio stack and building comprehensive unit tests for our signal processing math.

Challenges we ran into

Building a reliable sonar on a device designed for human speech was incredibly challenging:

  • Direct Coupling: The loudest sound the microphone hears is the phone's own speaker. We had to carefully separate this massive direct-path signal from the much fainter echo returning from an object.
  • The Near-Field Dead Zone: Echoes from objects closer than 10 cm merge with the direct coupling peak. We solved this by classifying extremely early returning energy as "Object very close" instead of fabricating an inaccurate numeric distance.
  • Hardware Fragmentation: Android devices have vastly different acoustic profiles, latencies, and microphone placements. We strictly calibrated our MVP against a reference device (OnePlus 3T) and built the architecture to gracefully handle unsupported audio paths on other phones.

What we learned

We learned that the Android audio stack is a complex beast when you need raw, unfiltered signals. We also discovered the critical importance of building an offline testing pipeline—we captured real WAV files of empty rooms and objects at specific distances so we could iterate on our DSP algorithms in unit tests without needing to physically hold the phone in a quiet room for every compilation.

What's next for Echo Scan

While the MVP successfully demonstrates frontal object detection up to 0.50 meters, the mathematical foundation is highly extensible. In the future, we envision expanding this to continuous background sensing for accessibility aids, using multiple microphones for directional beamforming, and profiling the acoustic signatures of different materials.

Built With

Share this project:

Updates