An ultrasonic sensor sends a sound pulse that bounces off the oil and returns to the sensor. The amount of time that it takes can be measured and based on the speed of sound you can figure out the distance. Neat. It's nothing as grand as the pic above, I'm