Ultrasonic sensor HC-SR04/SR06 to measure water level

Hello!

Is anyone using HC-SR04 or HC-SR06 for measuring water level?
How accurate is it?
Are you using temperature compensation?
I'm planing on using it from 5-30cm. Is it accurate in that area?

Thanks, Matej

levak:
Hello!

Is anyone using HC-SR04 or HC-SR06 for measuring water level?
How accurate is it?
Are you using temperature compensation?
I'm planing on using it from 5-30cm. Is it accurate in that area?

Thanks, Matej

Lots of people use the HC-SR04 or HC-SR06 to measure water. They work quite well for that. I would suggest using my NewPing library for faster/better results. Also, when doing so, use the ping_median() method that will do multiple pings and give you the median value. As most water measurement projects don't need to be fast, you can have the ping_median() do many iterations to give you a much more accurate reading and still do readings many times even a second.

Are you doing something like a sump pump logger/alarm?

Tim

I will be using it to measure water level in a fish tank. I will measure water level, so I will know when to add water that evaporated and to know when to stop/start pumping when changing water.

The only problem I see, can be that the surface of the water is wavy and that will affect measurements... But then again, that's way I will use ping_median.

How long does it take to make a measurement?
One second?
Half second?

lp, Matej

levak:
I will be using it to measure water level in a fish tank. I will measure water level, so I will know when to add water that evaporated and to know when to stop/start pumping when changing water.

The only problem I see, can be that the surface of the water is wavy and that will affect measurements... But then again, that's way I will use ping_median.

How long does it take to make a measurement?
One second?
Half second?

lp, Matej

ping_median() sends out a ping every 29 ms. Because the surface isn't still, and the water lever doesn't change quickly, I would suggest doing many iterations to get the median. Let's say 15 iterations. Even at 15 iterations, it will take less than a half second. One ping at a short distance may only take 5ms. The only reason it would take almost a half second is because it's doing it so many times and waiting for echos to dissipate. You may even want to do 30 or more iterations for even more stable results.

I would imagine your sketch doing a measurement a couple times a day at most and put the Arduino to sleep between sensor readings. There's no reason to be sending high-frequency sound into your tank which your fish could sense. You wouldn't want to be possibly aggravating your fish by a constant high-frequency speaker blaring all the time. Sounds a bit like torture.

You may also want to consider a float switch (think the ballcock in your toilet tank). Maybe a little low-tech, but it should work well.

Tim

Hello!

I just got SR04 sensor and is working flawlessly with your library...

ping_mediana is working nice and my results are about 1cm off scale, but that I can fix with software calibration.

As far as my sketch goes, I will be checking my water level every minute or so, since it will also be used for alerting in case something goes wrong and water starts to spill out of the tank...

During water change it will be running non-stop, but that will take 30min every week, no more....

Matej

levak:
Hello!

I just got SR04 sensor and is working flawlessly with your library...

ping_mediana is working nice and my results are about 1cm off scale, but that I can fix with software calibration.

As far as my sketch goes, I will be checking my water level every minute or so, since it will also be used for alerting in case something goes wrong and water starts to spill out of the tank...

During water change it will be running non-stop, but that will take 30min every week, no more....

Matej

Are you measuring from the front or the back of the sensor? The sensor itself is about 1cm in length. If there's a distance issue, it's with where you start the measurement. Also, NewPing rounds to the closest cm. So 10.5 would round to 11. Therefore, it can easily appear to be 1cm off once you factor in where you start your measurement and up to 1/2 cm rounding.

Tim

I figured that out:)

I tried to measure from the front and from the back. Front gives me the best results, but still around 1cm off. I guess that cm goes to the rounding up...

Anyway, 1cm accuracy is enough for me...

Matej