Stufin
Home Quick Cart Profile

M5Stack Time-of-Flight Ranging Unit (VL53L0X)

Buy Now

Supply Voltage

3.3V to 5V

Current Consumption

20mA (typical)

Distance Measurement Range

Up to 2 meters

Distance Measurement Accuracy

1% (up to 1 meter), 2% (up to 2 meters)

Update Rate

Up to 50 Hz

I2C InterfaceStandard I2C bus with 7-bit or 10-bit addressing

Operating Temperature Range

-40C to 85C

Storage Temperature Range

-40C to 125C

Applications

The M5Stack Time-of-Flight Ranging Unit (VL53L0X) is suitable for a wide range of applications, including

Robotics and automation

IoT projects

Gesture recognition

Object detection and tracking

Level measurement

Proximity sensing

Obstacle detection

Conclusion

The M5Stack Time-of-Flight Ranging Unit (VL53L0X) is a high-precision distance measurement module that provides accurate and reliable distance measurements up to 2 meters. Its compact size, low power consumption, and fast distance updates make it suitable for a wide range of applications, including robotics, automation, and IoT projects.

Pin Configuration

  • M5Stack Time-of-Flight Ranging Unit (VL53L0X) Pinout Overview
  • The M5Stack Time-of-Flight Ranging Unit (VL53L0X) is a high-accuracy distance measurement module based on the VL53L0X laser ranging sensor. This documentation provides a detailed explanation of each pin on the module, along with connection guidelines.
  • Pinout Structure:
  • The M5Stack Time-of-Flight Ranging Unit (VL53L0X) has a total of 10 pins, which are grouped into two rows of 5 pins each. The pinout structure is as follows:
  • Row 1:
  • Pin 1: VCC (Power Supply)
  • Pin 2: GND (Ground)
  • Pin 3: SCL (Serial Clock)
  • Pin 4: SDA (Serial Data)
  • Pin 5: XSHUT (Shutdown)
  • Row 2:
  • Pin 6: GPIO1 (General Purpose Input/Output)
  • Pin 7: GPIO2 (General Purpose Input/Output)
  • Pin 8: NC (Not Connected)
  • Pin 9: NC (Not Connected)
  • Pin 10: NC (Not Connected)
  • Pin-by-Pin Explanation:
  • Pin 1: VCC (Power Supply)
  • Function: Provides power to the module
  • Voltage: 2.6V to 3.5V (typical operating range)
  • Connection: Connect to a power source (e.g., a microcontroller's VCC pin or a battery)
  • Pin 2: GND (Ground)
  • Function: Provides a ground connection for the module
  • Connection: Connect to a ground source (e.g., a microcontroller's GND pin or a ground plane)
  • Pin 3: SCL (Serial Clock)
  • Function: Serial clock signal for I2C communication
  • Connection: Connect to the SCL pin of a microcontroller or I2C bus
  • Pin 4: SDA (Serial Data)
  • Function: Serial data signal for I2C communication
  • Connection: Connect to the SDA pin of a microcontroller or I2C bus
  • Pin 5: XSHUT (Shutdown)
  • Function: Active-low shutdown input
  • Connection: Connect to a digital output of a microcontroller or a logic level signal
  • Notes:
  • + Pulling XSHUT low will put the module into shutdown mode, reducing power consumption.
  • + Leaving XSHUT unconnected or pulling it high will keep the module enabled.
  • Pin 6: GPIO1 (General Purpose Input/Output)
  • Function: General-purpose input/output
  • Connection: Connect to a digital input/output of a microcontroller or a peripheral device
  • Notes:
  • + Can be used as an interrupt output or a status indicator.
  • + Consult the datasheet for specific configuration and usage.
  • Pin 7: GPIO2 (General Purpose Input/Output)
  • Function: General-purpose input/output
  • Connection: Connect to a digital input/output of a microcontroller or a peripheral device
  • Notes:
  • + Can be used as an interrupt output or a status indicator.
  • + Consult the datasheet for specific configuration and usage.
  • Pin 8: NC (Not Connected)
  • Function: Not connected (reserved for future use)
  • Connection: Leave unconnected
  • Pin 9: NC (Not Connected)
  • Function: Not connected (reserved for future use)
  • Connection: Leave unconnected
  • Pin 10: NC (Not Connected)
  • Function: Not connected (reserved for future use)
  • Connection: Leave unconnected
  • Connection Guidelines:
  • When connecting the module to a microcontroller, ensure that the I2C bus is properly configured and driven.
  • Use a suitable power source and provide a stable voltage within the recommended operating range.
  • Avoid connecting the XSHUT pin to a power source or a digital output that may cause unintended shutdown.
  • Consult the datasheet and relevant application notes for specific usage and configuration guidelines.
  • By following this documentation, you should be able to properly connect and utilize the M5Stack Time-of-Flight Ranging Unit (VL53L0X) in your IoT projects.

Code Examples

M5Stack Time-of-Flight Ranging Unit (VL53L0X) Documentation
The M5Stack Time-of-Flight Ranging Unit (VL53L0X) is a high-accuracy distance measurement module based on the STMicroelectronics VL53L0X sensor. This module provides a reliable and accurate way to measure distances up to 2 meters with a resolution of 1 mm. It is compatible with the M5Stack ecosystem, allowing for easy integration with various microcontrollers and development boards.
Pinout
The M5Stack Time-of-Flight Ranging Unit (VL53L0X) has the following pinout:
VCC: 3.3V power supply
 GND: Ground
 SCL: I2C clock signal
 SDA: I2C data signal
 XSHUT: Shutdown pin (active low)
Arduino Library
To use the M5Stack Time-of-Flight Ranging Unit (VL53L0X) with Arduino, you can use the official VL53L0X library. You can install it through the Arduino Library manager or download it from the GitHub repository.
Code Examples
### Example 1: Basic Distance Measurement
This example demonstrates how to use the M5Stack Time-of-Flight Ranging Unit (VL53L0X) to measure the distance to an object.
```c++
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
void setup() {
  Wire.begin();
  sensor.init();
  sensor.setTimeout(500);
  sensor.setMeasurementTimingBudget(20000);
}
void loop() {
  int distance = sensor.readRangeSingleMillimeters();
  if (distance > 0) {
    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.println(" mm");
  } else {
    Serial.println("Error reading distance");
  }
  delay(100);
}
```
### Example 2: Object Detection with Threshold
This example demonstrates how to use the M5Stack Time-of-Flight Ranging Unit (VL53L0X) to detect objects within a certain range.
```c++
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
const int threshold = 200; // 200 mm threshold
void setup() {
  Wire.begin();
  sensor.init();
  sensor.setTimeout(500);
  sensor.setMeasurementTimingBudget(20000);
}
void loop() {
  int distance = sensor.readRangeSingleMillimeters();
  if (distance > 0 && distance < threshold) {
    Serial.println("Object detected!");
  } else {
    Serial.println("No object detected");
  }
  delay(100);
}
```
### Example 3: Integration with M5Stack Core2
This example demonstrates how to use the M5Stack Time-of-Flight Ranging Unit (VL53L0X) with the M5Stack Core2 board to display the measured distance on the built-in LCD screen.
```c++
#include <M5Core2.h>
#include <Wire.h>
#include <VL53L0X.h>
M5Core2 lcd;
VL53L0X sensor;
void setup() {
  M5.begin();
  Wire.begin();
  sensor.init();
  sensor.setTimeout(500);
  sensor.setMeasurementTimingBudget(20000);
  lcd.begin();
  lcd.clear(BLACK);
  lcd.setCursor(0, 0);
  lcd.println("Distance: ");
}
void loop() {
  int distance = sensor.readRangeSingleMillimeters();
  if (distance > 0) {
    lcd.setCursor(0, 1);
    lcd.print("    ");
    lcd.setCursor(0, 1);
    lcd.print(distance);
    lcd.print(" mm");
  }
  delay(100);
}
```
These examples demonstrate the basic usage of the M5Stack Time-of-Flight Ranging Unit (VL53L0X) and provide a starting point for more advanced applications.