How to not measure the water level with an ultrasonic sensor

Put an ultrasonic sensor at the end of a 75mm pipe, stick the pipe down a water tank and measure the distance. It seemed like such a good idea. Get an exact distance reading and calculate the water depth.

Testing on dry land gave promising results. The sensor would deliver perfect distance readings up to at least 2m when fitted to the end of a 75 mm pipe. Testing in an actual tank worked equally well. For a while.

Then, suddenly, a stray reading, totally off the scale, and then back to normal. This wouldn’t really have been a problem if it wasn’t for the GSM module, sending me a text message every time it happened, but it was an easy fix to introduce a threshold, requiring a number of readings saying the same thing to trigger the text message telling me something was wrong.

That worked, but not for long, until the messages started coming in. Again the sensor was reporting strange values, completely off the scale, but for longer periods of time than before.

Visual inspection gave no clues. Mechanically everything was all right where the sensor sitting just as it should and the water level was fine, within limits.

The sensor had to go. It was deactivated and later replaced by a differential pressure sensor that has been successfully used before and still works after several months of use. The only downside is that it varies slightly with the weather, but it does so consistently, so that readings can be trusted to stay within certain limits.

I know for a fact that ultrasonic sensors are used for exactly this application industrially, so there’s no doubt that it can be done, but I don’t recommend trying it with the kind of naked sensor that you can buy cheaply at the electronics store. If the sensor is encapsulated in some suitable material that lets the ultrasonic waves through it should be a totally workable solution. Feel free to experiement.