Proximity sensors can measure how near or far an object is.
Think of it echolocation in bats or dolphins.
For everyday distance detection we recommend this type of Ultrasonic Sensor (buy):
Note: If your application involves measuring levels of liquid in containers, using a more industrial, more weather resistant, and more expensive sensor would be the way to go.
Here's a diagram for wiring the sensor to NodeMCU