A proof of concept of a simple sonar

Sonar is a ship device detecting objects in surrounding water. It analyzes sounds that propagates in the water, an active sonar uses the sounds that it produces, a passive one uses the sounds from other sources (e.g. eruptions or sounds of other ships). A wide range of frequencies can be used, from infra-sounds to ultrasounds. A simple, active sonar can be built from a couple of electronic elements and a PC computer - I will present this idea here.

fake reservoir and a floating sonar

I used a piece of Styrofoam as a ship and a bowl as a water that surrounds the ship. The bottom of the "reservoir" is modeled by a couple of floors tiles.


The circuit contains only a speaker and a microphone + a bunch of elements needed by the microphone. They're connected to the computer: speaker to headphone output, microphone to the microphone input.

circuit of a simple active sonar that uses a computer to generate signals and analyse them

The ship:

The ship with assembled sonar:


Python script was used to generate samples of different frequencies. The sample was played in an endless loop in mplayer. Input was analyzed by using software spectrum analyzer.

Tests and further ideas

I had placed the boat on the water and moved it in random directions. A spectrum of the signal received from the microphone was changing when the ship was above an obstacle. A short range of frequency was boosting, it's because the signal were reflected from the surface of the observed object.

This leads me to another idea: could only a built-in computer speaker and microphone be used to detect if something moves near the computer? This software could be used for example to protect a computer against steal.

I made a series of tests with my laptop. In this model, a microphone is placed on the lid, above the screen. Speakers are near the keyboard, on the left and right sides, also near the screen. I have placed the lid in about 120 degrees from the bottom part of the computer and made the same experiment, but without mentioned in first part sonar.

The results were similar: the spectrum changed each time when I was moving something near the computer (for example a bottle of juice or a metal box).

The results in both of the experiments could be improved a lot by using more complex software.


  1. comments from by old blog:

    haha, super sprawa, naprawde przyjemnie sie czyta notki o takich eksperymentach, zaluje jedynie ze nie moge nic dodac do tematu jako ze sie kompletnie nie znam :)

    hehe naprawde ciekawe ;)

    bardzo ciekawe :) trzeba zrobić coś podobnie :)

    a ja proponuję umieścić głośniczek i mikrofon(zalecam użycie drugiego głośniczka) w wodzie. Wodoszczelność można nabyć używając kondoma ;>

    Rezultaty zszokują !!!

    p.s. Membrana musi mieć “sztywny” kontakt z wodą — żadnego powietrza pomiędzy membraną a wodą.

  2. An interesting idea and I really I think that I will do that by myself.
    1. Which one Spectrum Analyzer did you use?
    2. Can you share the Python script?
    3. Do you have the pictures in higher resolution? Those are really small and low quality, it's impossible to say what's on the screen.

    1. Hi,

      Unfortunately, I've made this experiment about three or four years ago, now I don't have the original data and I don't remember the name of the spectrum analyser used during the tests. It was a freeware software, it worked on Linux, IMHO any such tool can be used here.

      Now I'm working on a new version, with a simple hardware signal generator (probably NE555) and with the input driven by the 74HCT4066 key. It will be plugged to the PS as a microphone, just as the original version, but this time I want to make it deaf when the speaker sends the signal.


    2. @up, how are you going to use 74HCT4066 here? Do you already have a circuit? :)

    3. Hi,

      no, I don't have the circuit yet, 74HCT4066 will turn off the microphone, when sonar sends signal.


    4. Maybe you could use some DSP chip for that?

    5. Probably yes, but first I need to improve my skills in electronic and popular microprocessors.

    6. DSP would could be fun! You can use some of the popular ready-to-use board (analogical to Arduino/Raspberry family)..