can an ultrasonic sensor detect pingpong ball between water and oil ?

because if i know the level of pingpong ball and the level of oil surface, i can know the level of water and oil.
this is the illustration.

or maybe there is a better method to measure multi level liquid

sensing.jpg

Water conducts better than oil. Fix a piece if stripboard to the inside wall of the tank, with the strips horizontal. Measure the resistance between adjacent strips. Where the resistance is higher, thar be oil!

What sort of ping-pong ball will sink in oil? I guess it's weighted to have a density between the two?

Most ultrasonic distance sensors are designed to operate in air, not a liquid like water or oil. If you came up with an in-liquid sensor pair, you could likely measure the depth to the oil/water interface from the bottom up. It would not matter if there were a ping-pong ball there or not. The impedance discontinuity between the two fluids would reflect the signal just fine.

What is the objective here? To sense the position of the ping-pong ball? The presence/absence of the ball? To measure the water level under the oil? The thickness/level of the oil above the water?

To detect the water level in a small tank like that, an external capacitive liquid-level sensor it easy to make and will work very well. Several designs and other alternatives have been discussed on this forum. Here is are a couple of threads:

gardner:
What sort of ping-pong ball will sink in oil? I guess it's weighted to have a density between the two?

Most ultrasonic distance sensors are designed to operate in air, not a liquid like water or oil. If you came up with an in-liquid sensor pair, you could likely measure the depth to the oil/water interface from the bottom up. It would not matter if there were a ping-pong ball there or not. The impedance discontinuity between the two fluids would reflect the signal just fine.

What is the objective here? To sense the position of the ping-pong ball? The presence/absence of the ball? To measure the water level under the oil? The thickness/level of the oil above the water?

the objective is to measure both water and oil level.

The simplest, lowest tech solution would be to use a couple of float sensors with one set to float at the surface and the other set to float at the boundary.