First project

Build a hydrophone

A hydrophone is a waterproof microphone you lower into the water. With a few electronic parts and a little code, you can record and listen to underwater life. Here are the parts, the plans and the code to build one.

Step 1

The parts

Simple, affordable parts. The heart of the build is a piezoelectric sensor, which turns vibrations in the water into an electrical signal.

PartRoleNote
Piezoelectric sensorPick up sound vibrations in the waterPiezo disc, 20 to 35 mm
Shielded cableCarry the signal without interference2 to 5 m, shielded mono
PreamplifierBoost the weak raw signalOp-amp mic module
Epoxy resinMake the sensor fully waterproofSolvent-free resin
Heat-shrink tubingProtect and insulate the jointsA few diameters
3.5 mm jack connectorPlug into the recorderMono or stereo jack
RecorderCapture and save the soundsComputer, Raspberry Pi or audio recorder
Weight and floatSet the listening depthSmall weight and buoy

Tip: a preamp module with adjustable gain makes the first tests much easier.

Step 2

The wiring plans

The idea: the waterproof sensor sends its signal to the preamp, which sends it to the recorder. Follow it in order.

Signal flow
Piezo sensor | (vibrations in the water) v Shielded cable | v Preamplifier --> power | (boosted signal) v Recorder (3.5 mm jack) | v Audio file .wav
Steps
  • Solder two wires to the piezo disc, one to the center and one to the rim.
  • Connect the wires to the shielded cable, insulate each joint with tubing.
  • Fully coat the sensor in epoxy resin, with no air bubbles.
  • Let it cure, then test for leaks in a glass of water.
  • Plug the cable into the preamp and set a medium gain.
  • Connect the preamp to the recorder through the 3.5 mm jack.
  • Add the weight and float to choose the depth.

⚠️ Safety and respect for wildlife

Always stay with an adult near the water. Never play loud sounds underwater, and keep your distance from animals: the goal is to listen without disturbing them.

Step 3

The code

A bit of Python to record the sounds, then turn them into an image (a spectrogram) to see what you captured.

record.py
# Record 30 seconds of underwater sound
import sounddevice as sd
from scipy.io.wavfile import write

fs = 44100        # sampling rate
duration = 30     # seconds

print("Recording...")
audio = sd.rec(int(duration * fs), samplerate=fs, channels=1)
sd.wait()
write("ocean.wav", fs, audio)
print("Done: ocean.wav created")
spectrogram.py
# Turn the recording into an image
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile

fs, data = wavfile.read("ocean.wav")
if data.ndim > 1:
    data = data[:, 0]   # keep a single channel

plt.specgram(data, Fs=fs, cmap="ocean")
plt.ylabel("Frequency (Hz)")
plt.xlabel("Time (s)")
plt.title("Sounds captured underwater")
plt.savefig("spectrogram.png", dpi=150)
print("Image saved: spectrogram.png")

Install the tools

A single command, in a terminal, to install the libraries used here:

pip install sounddevice scipy numpy matplotlib

An idea, a question, an improvement?

The project is open. Write to me to share your tests or your advice.

Get in touch