Has anyone tried to put an HC-SR04 in a tube.

The water is flowing, disturbed and far too dirty, floating debris of all sorts and sizes, to offer a flat surface.
That is why I was asking about the tube ...
A float seems like a good plan, polystyrene perhaps?

If the dirty floaty stuff is small and moving it should work.
How big is the biggest debris, twigs will be fine, logs will be a problem, probable also for other reasons too :stuck_out_tongue:

Anything small that floats by will not really cause a problem, but all this depends on how good the ultrasonic receiver is.
The electronics in most units usually do quite a bit a processing and you end up with a smoothed output signal.
Oops, I have just seen that the HC-SR04 is a simple device and has no real post processing :.

How about putting a trash rack just ahead of where you want to read, so all the debris is shunted around that area if you think the debris will be a problem.

I would only use a floating disk of sorts if you were to use an optical measuring device, not for really or ultrasonics as the float.
I don't know the specs of the HC-SR04, though I did use such a thing many years ago for a different application not involving water.
The units I have used are industrial types and are fully IP rated and send a 4-20mA signal out.
If you use this unit you may need to think about protecting it against moisture that will have not so good an effect on the sensor over time.

Now here is an idea that is also used, how about putting a pressure sensor at the bottom of your weir or tank.
You can either drop the sensor in or if you can mount it in from the side wall so the cable is not in the water.
Again, I have done this for industrial installations.
With the correct sensor you can get very good constant readings.

rockwallaby . .