VL53L0X vs HC-SR04 range sensor (Part 1)

Robotics Weekends
Robotics Weekends
Published in
4 min readDec 10, 2019

This is the first part of experiment with optical range sensor from STMicroelectronics - VL53L0X. I’m going to test max distance and precision with various obstacle materials and under different conditions. I also used a popular ultrasonic sensor HC-SR04 to compare basic properties.

First look at VL53L0X

VL53L0X has I2C bus for communication. This protocol is popular in embedded devices. Since the sensor needs 2.8V for operation, the breakout board has voltage regulator and level shifter to make it possible to work with 5V Arduino boards or 3.3V controllers, for example esp8266 or esp32.

In IR spectrum it is possible to see what the beam in VL53L0X looks like. If you expected to see a thin laser dot, then… Surprise! The beam has ~25-30 degree slant angle and light intensity decreases quickly with range increase.

First of all let’s compare the main properties for VL53L0X and HC-SR04 sensors:

VL53L0X

  • Sensor type: Time-of-Flight — 940nm Laser
  • Range: 20–1250mm (20–2100mm in long-range mode)
  • Size: 10x25x2mm
  • Field of view: 25 degrees

HC-SR04

  • Sensor type: Ultrasonic
  • Range: 20–4000mm
  • Size: 45x20x15mm
  • Field of view: 30 degrees

Test bench

For experiments I’ve built a simple test bench, based on Arduino Mega 2560. Actually any Arduino board will fit. Wiring is simple — optical sensor is connected to i2c bus, and ultrasonic sensor is connected to the digital I/O pins with interruption support.

Sketch

The purpose of the Arduino sketch is to get measurement data from both sensors and send it to serial port.

For VL53L0X I used Adafruit_VL53L0X library. It is very simple library and it doesn’t uncover all the sensor’s potential, but will be enough for our purposes. The library can be installed from Arduino’s library manager.

For HC-SR04 sensor HC_SR04 library. It is also available in the library manager.

Maximum range test

Ultrasonic sensor can measure ranges up to 4m and has 10mm (1cm) resolution. Of course resolution is specifics of the library, but the data with 1mm step will be too noisy. VL53L0X supports two modes: normal and long-range. In normal mode the maximum measurable range is 1200mm. In long-range mode maximum measurable range is 2100mm, but result is more noisy. Both modes provide the data with 1mm precision. Below are the graphs from official sensor documentation:

Adafruit library sets the normal mode for VL53L0X sensor by default. In my experiment the maximum range measured by VL53L0X was 1272mm, and despite the fact that HC-SR04 has bigger measurable distance, I’ve stopped the experiment at 2300mm range.

Ranging accuracy test

To test sensors’ precision I’ve made a series of measurements with 100mm (10cm) step. Noise of VL53L0X increases starting from 380mm. But let’s take in account, that VL53L0X API returns values in mm, while HC-SR04 in cm. And I didn’t add any filtering.

Also it can be seen that measurement error for VL53L0X is rather big even on 900mm (discrepancy is 30–40mm), while HC-SR04 showed stable measurements during all 1000mm range.

Below is ranging accuracy table from documentation:

Max obstacle angle

This is where VL53L0X is the best! Time-of-Flight technology does not critically depend on angle of incidence. HC-SR04 start failing on 30 degrees from perpendicular to the sensor — on greater angles sound echo is mirrored to direction out of HC-SR04 sensing range.

To be continued…

Next time I will test how sensor works with water, glass, mirror, concrete and other materials; how it performs on different light conditions; power consumption; etc. Stay tuned!

Links

Arduino sketch: https://gist.github.com/Andrew-rw/19e0bd651af51ed51a89f65fa6423256
VL53L0X library: https://github.com/adafruit/Adafruit_VL53L0X
HC-SR04 library: https://github.com/jazzycamel/arduino
VL53L0X datasheet: http://www.st.com/content/ccc/resource/technical/document/datasheet/group3/b2/1e/33/77/c6/92/47/6b/DM00279086/files/DM00279086.pdf/jcr:content/translations/en.DM00279086.pdf
HC-SR04 datasheet: http://www.micropik.com/PDF/HCSR04.pdf

--

--