I'm trying to find a contact-less (ultrasonic, laser, etc) liquid level sensor that is mounted above the liquid line and can read the distance from the sensor to the liquid (the air distance, from which the liquid level can be calculated based on the container height). There are tons of liquid level switches out there that trigger high/low based on the presence of liquid at or below a certain threshold, but I don't want that; I need to be able to measure distance.
You could perhaps use a waterproof ultrasonic distance sensor, but you'd have to take in to account the density of the liquid vs. speed of sound. Density (temperature, salinity, etc) changes the ping/echo time. You could even create a "raft" for a non-waterproof sensor*
That method is used by ships and smaller boats to gauge depth of water at sea.
Why don't you put your liquid container on a pressure sensor, and just weigh the whole thing? That might be inexpensive, and keeps any contacts out of the liquid environment.
What am I missing here?
What's wrong with an ultrasound sensor mounted at the top of the container pointing down? The speed of sound in air changes a bit as the air temperature changes but so little it usually can be ignored.
Yea ultrasonic was the first thing I considered. Are there any really small (and preferably circular) ultrasonic sensors? The shape of the typical Arduino HC-SR04 sensor is not ideal.
Minimum size of the transducer (speaker) is limited by the size of the audio waves it has to produce. At a typical 40 kHz that's a 7.5 mm wavelength. Too small a transducer and you can't produce/detect those signals.
By the way why does it have to be that small, when you container is way too big to put on a scale, as you mentioned before? What actual size are you even talking about?
Laser/IR would be able to go smaller (at least technically) but no idea if that works for bouncing off water or whatever liquid you have.
You could insert a pipe through the 2" hole. The pipe would be open at the bottom but sealed at the top apart from a tube going to a pressure sensor. By measuring the pressure you can calculate the oil depth. A differential pressure sensor would be best as that way your reading will not be affected by changes in atmospheric pressure.
Providing you get a good seal at the top of the pipe I don't see why this would not give an oil tank reading that is accurate enough. The system could be developed/tested using a bath. A dipstick could be used to confirm the readings in the oil tank.
One thing that concerns me is combustion. Your oil tank, and the pipe, will contain a mixture of air and oil vapour. You want to be sure that none of the electronics can generate a spark that might ignite the mixture.