Measure Distance with Laser VL53L0X 6 pin module for Arduino
Measure Distance with Laser VL53L0X 6 pin module for Arduino
This code is to measure distance using laser module ToF Time of Flight VL53L0X 6 pin module. This module is sold on eBay or AliExpress in different color but mostly (as of Jun 2018) sold in pink color.
Use I2C scanner (link below ) to see if wiring is done properly.
VL53L0X Dimensions

VL53L0X Dimensions 2

VL53L0X Emitter and Collector cone angles

Related Videos:
- Introduction to VL53L0X: https://youtu.be/S2jaAQEv3Yo
- How to assign different I2C Address [this video]
- How to use two or more VL523L0X modules: https://youtu.be/0glBk917HPg
- VL53L0X with LCD Bargraph: https://youtu.be/vJStXiSS23Q
- VL53L0X with LCD1602 display: https://youtu.be/t14ly7Y09oI
- VL53L0X with TM1637 LED display: https://youtu.be/oGWpb9C9XXA
- All Robojax videos on VL53L0X: https://youtube.com/robojaxTV/search?query=VL53L0X
Where to buy it?
-Search eBay (no affiliation) Here-Search Amazon (no affiliation) Here
-Search AliExpress (no affiliation) Here
-Search Banggood (no affiliation) Here
- Library (from Robojax.com)
- Download Library(getHub)
- I2C Scanner (If you face problem, use this code to see if wiring is okay)
- Data sheet
/* This example shows how to use continuous mode to take
range measurements with the 6 pin VL53L0X module. It is based on
vl53l0x_ContinuousRanging_Example.c from the VL53L0X API.
The range readings are in units of mm.
Original source: https://github.com/adafruit/Adafruit_VL53L0X
Modified by Ahmad Shamshiri for RoboJax.com
Date modified: May 31, 2018 at 19:25 at Ajax, Ontario, Canada
Watch the instruciton video for this code https://youtu.be/S2jaAQEv3Yo
Pin connection
VL53L0X Pin Arduino Pin
VCC 5V
GND GND
SDA A4 or SDA if available
SCL A5 or SCL if available
GPIO1 leave it unconnected
XSHUT D12 (digital 12 or pin 12)
*/
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
void setup()
{
pinMode(12,INPUT_PULLUP);
digitalWrite(12,HIGH);
Serial.begin(9600);
Wire.begin();
sensor.init();
sensor.setTimeout(500);
// Start continuous back-to-back mode (take readings as
// fast as possible). To use continuous timed mode
// instead, provide a desired inter-measurement period in
// ms (e.g. sensor.startContinuous(100)).
sensor.startContinuous();
}
void loop()
{
int distance =sensor.readRangeContinuousMillimeters();
//int distance =sensor.startContinuous(100);
//distance = distance;
Serial.print("Distance: ");
Serial.print(distance);
Serial.print("mm");
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
delay(100);
}