Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino Nano HC-SR04 vs VL53L0X: Pick right sensor | ShillehTek

May 29, 2026

Arduino Nano HC-SR04 vs VL53L0X: Pick right sensor | ShillehTek
Project

Compare Arduino Nano readings from HC-SR04 ultrasonic vs VL53L0X ToF to choose the right distance sensor for robots, with bench-tested results from ShillehTek.

20 min Beginner5 parts

Project Overview

Arduino Nano + HC-SR04 + VL53L0X: This guide compares the HC-SR04 ultrasonic sensor and the VL53L0X laser time-of-flight sensor so you can choose the right distance sensor for your robotics project.

Arduino robotics distance sensor comparison showing the HC-SR04 ultrasonic module next to the VL53L0X laser time-of-flight module

Both sensors cost a few dollars, both report distance, and both connect to an Arduino in minutes, but they use different physics. If you pick the wrong one for your robot, you can miss obstacles or get noisy readings when the environment changes.

This guide runs both sensors through the same bench test (a target moving from 5 cm to 100 cm), checks performance on hard, soft, and angled targets, and maps each sensor to real projects like wall-following robots, parking sensors, and short-range precision measurement.

  • Time: 20 to 40 minutes
  • Skill level: Beginner
  • What you will build: A practical comparison you can replicate to choose between ultrasonic and ToF distance sensing on Arduino.

Parts List

From ShillehTek

External

  • Breadboard - for prototyping the wiring.
  • A rigid target board (cardboard works) and a soft target (cushion or sponge) - for repeatable comparison.
  • Tape measure or ruler - for ground-truth distance.

Note: The HC-SR04 typically runs at 5 V logic and can output a 5 V ECHO signal. If you are using a 3.3 V board, level-shift or otherwise protect the input pin, or use a 3.3 V-compatible variant.

Step-by-Step Guide

Step 1 - Understand how each sensor measures distance

Goal: Learn what each sensor is measuring so the strengths and limitations make sense.

What to do: Review the core measurement method for each sensor.

The HC-SR04 emits a 40 kHz ultrasonic burst, then measures the time until the echo returns. Range is 2 to 400 cm, the cone of view is about 15°, and the update rate caps around 25 Hz. It reflects well off hard surfaces but can be absorbed by foam, cloth, and curtains.

The VL53L0X fires a 940 nm infrared laser and measures the time the photons take to return (time-of-flight). Range is about 3 cm to 1.2 m, the cone of view is about 25° total, and the update rate can reach 50 Hz. It is not affected by acoustic absorption, but very dark or matte black targets can reduce range.

Expected result: You understand that HC-SR04 is acoustic echo timing and VL53L0X is optical ToF, which leads to different failure modes.

Step 2 - Wire each sensor the right way

Goal: Identify the key wiring differences so you can connect either sensor quickly and safely.

What to do: Wire the HC-SR04 using two digital pins, and wire the VL53L0X using the I²C bus.

  • HC-SR04: 4 pins: VCC (5 V), GND, TRIG, ECHO. Uses two digital lines.
  • VL53L0X: 4 pins (plus XSHUT for multiple devices on the same bus): VCC (3.3 to 5 V on most breakouts), GND, SDA, SCL. Uses I²C.

If you are using a 3.3 V board and need to read a 5 V HC-SR04 ECHO signal, level-shift or otherwise protect that input, or choose a 3.3 V-compatible sensor variant.

Expected result: You can describe the pinout and signal type for each sensor (digital pulse vs I²C).

Step 3 - Upload the Arduino code and read distances

Goal: Get live distance readings from both sensors over Serial so you can compare behavior.

What to do: Upload the HC-SR04 sketch to verify pulse timing distance output, then use a VL53L0X library example (as shown below) for continuous ToF readings.

Code:

// HC-SR04
#define TRIG 9
#define ECHO 10

void setup() {
  pinMode(TRIG, OUTPUT);
  pinMode(ECHO, INPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG, LOW);

  long dur = pulseIn(ECHO, HIGH);
  float cm = dur * 0.0343 / 2;
  Serial.println(cm);
  delay(50);
}

// VL53L0X (Pololu library)
#include <Wire.h>
#include <VL53L0X.h>

VL53L0X tof;

void setup() {
  Wire.begin();
  tof.init();
  tof.setTimeout(500);
  tof.startContinuous();
}

void loop() {
  Serial.println(tof.readRangeContinuousMillimeters());
}

Expected result: The Serial Monitor prints distance values in centimeters for the HC-SR04 and in millimeters for the VL53L0X.

Step 4 - Run the same bench test on both sensors

Goal: Compare accuracy and reliability on the same target movement (5 cm to 100 cm).

What to do: Move a target from near to far, use a ruler/tape for ground truth, then repeat the test with a hard target, a soft target, and an angled target.

Bench test setup comparing Arduino distance readings from an HC-SR04 ultrasonic sensor and a VL53L0X time-of-flight sensor

On a hard cardboard target, both sensors typically track ground truth within about ±1 cm from 10 to 80 cm. The biggest differences show up at the extremes:

  • 5 cm (very close): HC-SR04 can glitch because the receiver is not ready yet. VL53L0X is stable.
  • 1 m+ (far): HC-SR04 can keep reading reliably to 3 to 4 m. VL53L0X can drop out past about 1.2 m unless configured for longer-range behavior.
  • Soft target (cushion): HC-SR04 can miss because ultrasound is absorbed. VL53L0X typically still works.
  • Angled target (off-axis): HC-SR04 can miss past about 30° off normal. VL53L0X typically tolerates steeper angles.

Expected result: You can see where each sensor is strong (HC-SR04 long range, VL53L0X close-range precision and soft targets).

Step 5 - Pick the right sensor for your robot

Goal: Translate the bench behavior into a clear choice for common robotics projects.

What to do: Match the sensor to your environment and geometry (wide cone vs tight beam, soft targets vs hard targets, long range vs short-range precision).

Project recommendation matrix comparing when to use the HC-SR04 ultrasonic sensor versus the VL53L0X time-of-flight sensor on a robot
  • Wall-following robot car: HC-SR04. The wider cone can help detect walls.
  • Tabletop maze robot: VL53L0X. The narrow beam supports left/forward/right sensing without cross-talk.
  • Parking sensor / garage parking aid: HC-SR04. Low cost, long range, works on rigid surfaces.
  • 3D-printer Z-probe / body-height measurement: VL53L0X. Millimeter precision at short range.
  • Outdoor / dusty / vibrating environment: HC-SR04. Typically less affected by dust on a lens.

Expected result: You can justify your sensor choice based on range, target surface, and beam width.

Conclusion

The HC-SR04 is still a strong choice for cheap, long-range obstacle detection, especially on rigid surfaces. The VL53L0X is the better fit when you need short-range precision, a tighter beam, or reliable readings on soft and angled targets. For more capable robots, combining both can cover long-range detection and close-range precision.

Credit: This comparison was inspired by the bench test on Instructables: HC-SR04 VS VL53L0X - Test 1 - Usage for Robot Car Applications.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.