Range fluid with the HC-SR04 Ultrasonic

Hi,

This is my first time on the Arduino site. I'm an IT engineer by trade, and this is my first dabble into Arduino. Actually thrown into the deep end.

I have a project that I am building for a University. The original specification requires a measure of the height of a perspex tube full of watered down poo.
The level of water will change up and down as methane gas is produced and produce a pressure.

So for this I have used a HC-SR04 ultrasonic to measure fluid level changes, and an MPRLS for pressure.
So far, the the sensors are working, and giving me what I want, until we enclosed them in a head to house the sensors and electronic, and the wheels fell off with the HC-SR04.
The specification for accuracy is +/- 3mm, but what I have noticed, is values jumping all over the place.

Typically we can get 21mm,45mm,81mm,35mm in a static environment. It does seem to suggest that I am getting back scatter and reflections messing the sensor around.

I have tried various libraries. Default Arduino library worked only if I removed the trigger pin, but seemed stable. The newping worked, but the resolution is not good enough.
I am now using another one which slips my mind, and that library gives the MM resolution, but is very unstable.

One concern you may raise, is the ultrasonic in the environment. My thoughts exactly, and I don't hold out much hope they will survive.

Any thoughts on the best library for HC-SR04.

cheers

The HC-SR04 won't last long in a moist environment, corrosion will quickly ruin it.

Consider a capacitive water level sensor exterior to the tube, like the simple DIY one described in the attached article (PDF).

NV27-Measuring Water Level.pdf (520 KB)

I don't think it's corrosion, it's more like the tube.

That sounds like long and thin. The HC-SR04 has a cone of about 30°, so you'll be hitting the walls of the tube, which can give reflections. Another possible issue is if you try to measure too often and don't give echoes time to die out.

The sensor is so simple, a library is not needed. It's just a few lines of code: the trigger signal and then a pulseIn() call.

This...

saffer:
the sensors are working, and giving me what I want, until we enclosed them in a head to house the sensors

...suggests a problem with the head, not the HC-SR04, code/library, or tube/reflections.

But, even if you could fix that, you are left with the corrosion problem. If you can live with a 20 cm blind distance, the "waterproof" jsn-sr04t could be a solution.

There is also a two-transducer "waterproof" ultrasonic distance sensor similar to the HC-SR04 that shouldn't have the 20 cm blind distance. Several people were recently promoting it on this forum. Search the jsn-sr04t threads.

Unfortunately, all such sensors will suffer from the problems described in the following link and may be unlikely to achieve the stated 3 mm in "stock" form, even in ideal conditions: HC-SR04 | David Pilling