How hard to convert this sketch to be used with a different sensor

So I have a sketch that works very well, its a water level sketch using a URM37 ultrasonic sensor. The problem with using that sensor is they are no longer available in the US (DFRobot has them, but they ship from China). I would like to be able to use this sketch with a different ultrasonic sensor, but I have no clue how hard it would be to convert the entire sketch to use a different sensor.

Would anyone be willing to take a look at the sketch for me?

My biggest concern is that these sensors don’t seem to be designed to be in a humid environment so the rate of failure is higher than other sensors. Ideally I’d find a system that maybe uses differential pressure as those sensors seem to more stable under humid conditions for long term. Agree or disagree?

In the end I need to be able to monitor the depth of the tank remotely. With my current setup I can see it from anywhere either via the built in server on my network or via Xively, it works very well!

Thank you!
D (20.5 KB)

If the code is well structured then the portion (? a function ?) that reads the distance will be isolated and it should be fairly easy to replace it with code for another device and a different library if required, but it is difficult to give advice without knowing what other sensor you have in mind to use.

Well I'm open to recommendations.

The biggest question is what will last longer and be less problematic , ultrasonic or pressure?

How about a good, old fashioned float and a switch or 2 electrodes in the liquid ?

Well with a float switch, all of the ones I have found that would be long enough are quite expensive. As far as two electrodes in the water. I could try something like the milone etape. I’d be fine with that. In the end I just want to have a precise measurement of the water level.

I’ve attached the main parts of the sketch for viewing.

A01_Setup.ino (3.2 KB)

A02_measuring.ino (1.73 KB)

TankLevelMeasuring2_4.ino (19.7 KB)

Are you looking to measure the liquid level or just to know whether it is above or below two points ?

Measurement by percentage, 0-100%

These are the two views I get from my current setup.

eTape looks a good bet then, provided that it is available in the right length for your application.