ElectroHub

Ultrasonic Distance Sensor

Sensor

A sensor that measures distance by sending out ultrasonic sound waves and timing how long they take to reflect back.

What it looks like

Ultrasonic Distance Sensor

A typical sensor — exact shape, colour and markings vary between manufacturers.

Types & variants

HC-SR04LV-MaxSonar EZURM37JSN-SR04TMB7040GP2Y0A02YK0FDYP-ME007SRO4100

Key specs

Operating voltage

V

Typically 5V for most modules, check datasheet for exact requirements.

Range

cm

Minimum to maximum detectable distance (usually 2cm to 400cm).

Resolution

mm

Smallest detectable distance change (typically 1mm to 1cm).

Beam angle

degrees

Angle of the ultrasonic cone (typically 15-30 degrees).

Trigger pulse

µs

Minimum high pulse duration to initiate measurement (usually 10µs).

Response time

ms

Time between trigger and echo pulse (depends on distance).

Laws that govern it

  • Law of capacitance — capacitance formula Q = CVQ = C × V, i = C·dv/dt, E = ½CV²

    The piezo transducer is a capacitive load driven with a burst of pulses; the driver must supply that di/dt or the ping is too weak to hear back.

  • The 5 V ECHO pin into a 3.3 V board needs a divider — the loop calculation that saves an ESP32 from a slow death.

  • Echo strength falls with distance the same way light does, which is why cheap modules stop being reliable past a couple of metres.

Each law is stated in full — with its diagram, variables and worked meaning — on the electrical laws page.

Markings

Usually labeled with model number (e.g. 'HC-SR04'). VCC/Trig/Echo/GND pins marked on PCB. Some have range adjustment potentiometer.

Standard values

Operating voltage: 3.3V or 5V. Range: 2cm-4.5m (varies by model). Common trigger pulse: 10µs high.

How to choose

1) Check voltage compatibility (3.3V or 5V). 2) Select range based on your needs (2cm-4m for most). 3) Consider beam angle (narrower for focused detection). 4) Check interface type (digital/analog/I2C/SPI).

Pinout & package

module boardVCC1TRIG2ECHO3GND4

HC-SR04 — 4-pin header

Check first: ECHO idles at 5 V, so on a 3.3 V board (ESP32, Pi) it needs a divider or level shifter. 3-pin variants (Ping))) ) share one trigger/echo line.

Typically 4 pins: VCC (power), Trig (trigger input), Echo (output pulse), GND. Packages: PCB module with mounting holes or breadboard-friendly pins.

Example circuits

  • Distance measurement for robotics
  • Parking assistance system
  • Liquid level measurement in tanks
  • People counter
  • Obstacle avoidance for drones

Common failures

Water/damage to transducers causing weak/no echo. Internal electronics failure. Drift in timing measurements. Physical damage to transducer elements.

How to test

1) Connect VCC and GND. 2) Send 10µs high pulse to Trig. 3) Measure duration of high pulse on Echo pin. 4) Calculate distance: Distance = (duration × speed of sound) / 2. 5) Compare with known distance.

Substitutes

Laser rangefinders (more precise, more expensive), infrared distance sensors (shorter range, affected by color), time-of-flight sensors (more accurate, higher cost).

Where to buy