I have bought x2 JSN-SR04T ultrasonic modules to monitor the fuel + water level in my both tanks.
On my test setup, I start with a simple test bench with a known distance against a wall and the simple code.
But I get values, not the best accuracy, and with a lot of artefacts:
To name a few reasons why the SR04's are crap: The SR04 transmits at 40Khz but receives at 38Khz, which begins the degrading of signal received. The SR04 transmits in a cone of 15 degrees, the wide-angle transmission makes the SR04 susceptible to noise.
Thanks you for your quick feedback.
What would be the alternative to measure liquids heights? (fuel or water) with a correct accuracy?
Should be waterproof, and quite narrow (should fit in the filling neck of the tanks).
Have you used the input text box labeled "Search Forum" and words like "sr04 measure liquid levels" to see how other people have done the same project, successfully and even with the faults the SR04 has?
Maybe I'm not taking the correct keywords in account, but after several pages of search, I do not find any posts having the same type of issue and/or how to solve it.
I'm quite ashamed to ask you, but do you have a typical existing topic you had in mind? If yes, possible to drop a link?
I wouldn't recommend putting hobby electronics in or near a fuel tank [*].
But if this was, say, a water tank, I'd try discarding obvious outliers by using a median filter (the NewPing library makes that easy).
And if the water level changes relatively slowly, so that an average can be based on many readings, I'd probably use a moving average that lightly weights new readings.
If that approach gave a sufficiently solid average at, for example, 800 mm, when the real test distance is 819 mm, then I'd try adding 19 mm to the average, to "calibrate" the system.
Then I'd change the test distance, wait for the average to stabilize, and see if I got sufficiently good results. Then do the same throughout the range of expected distances.