Experiment: Sonar

From phyphox
Jump to navigation Jump to search
Experiment Sonar
Category Acoustics
Used sensors Microphone, Speaker

The experiment "Sonar" sends out short sounds through the speaker and records the echoes with the microphone. It shows a graph indicating at which distances an echo was created.


While in theory the phone can perform this experiment on its own, it is nearly impossible to interpret the echos generated in a random room. The floor, the ceiling, every wall and every object will contribute to the result. Therefore, you should shield all directions from the phone (speaker and microphone) which you do not need.

As an example, this can be achieved with foam (for example from packaging material), thick clothing or sofa cushions. You can build a cavity in which you place the phone and leave one side open for echoes. On this side you can then use a strong reflector like a flat porcelain plate.

You may also want to use the remote interface from a second device (PC, Tablet, Smartphone, etc.) to control the experiment and get the results as your phone may not be easily accessible in this construction.

There should be little environmental noise during the experiment. Talking may already disturb the results.

You might be able to improve your experiment by using an external external microphone and/or speaker, especially if they are directed.


Place your phone in a way that it can only hear the defined echoes, in which you are interested and start the experiment. Also, make sure to turn up the volume of your phone! You will hear a clicking sound and should see data in the distance graph. You will probably still see multiple peeks from irrelevant echos, but if you move a reflecting surface (like a flat plate) you should see that a corresponding peak moves accordingly.


The noise you hear is not just a simple click, but a so-called chirp. A chirp is a sine function which changes its frequency rapidly. In this case it rises from 1kHz to 4kHz over a period of 5ms. Additionally, a weighting function is applied to allow for a smooth beginning and ending of the chirp. The chirp is then repeated five times at an interval of about 30ms.

The recording runs simultaneously. Phyphox calculates the crosscorrelation of the five chirps and the recording. The result is a measure for how strongly the recording resembles the original chirp at a given time. The strongest correlation is assumed to be the direct sound from the speaker to the microphone and thus the beginning of the experiment. This point is set to t=0 and the remainder of the crosscorrelation is shown to the user. To make it a little easier on the eye it is smoothed by a gaussian filter (sigma width of 3 data points).

The time on the x axis is multiplied by the speed of sound and divided by 2 to give the corresponding distance of the echoes.

Problems and resolutions

  • Many random peaks. This may be caused by strong background noise. Try to do this experiment in a quiet environment.
  • Many peaks in fixed positions. If many peaks appear which are always at the same distance (while the phone remains in the same place), you should try to improve the shielding from the environment as these probably originate from other sound reflecting objects.

Demonstration video