激光测距传感器

简介

VL53L0X激光测距传感器是一款基于意法半导体(STMicroelectronics)新出的基于飞行时间测距 (ToF) 原理设计的高精度测距传感器。与传统的技术不同,VL53L0X无论目标反射率如何,都能提供精确的距离测量,最高测量距离2米。 DFRobot基于VL53L0X设计的Gravity传感器模块,提供Gravity-I2C接口,即插即用,支持3.3V~5V供电使用,兼容更多的主板,适应更多的应用场景。 VL53L0X集成了尖端的SPAD (Single Photon Avalanche Diodes) 阵列,并嵌入ST的第二代FlightSenseTM专利技术。精度达±3%,响应时间小于30ms,正常工作模式下功耗仅20mW,待机功耗为5uA。 VL53L0X的940nm VCSEL发射器(垂直腔面发射激光器)对人眼来说是完全不可见的,加上内部物理红外滤波器,它可以实现更远的距离,更强的抗环境光的能力,以及更好的覆盖玻璃光学截面。

技术规格

引脚说明

引脚描述

标号 名称 功能描述
1 绿线 D IIC数据线DATA
2 蓝线 C IIC时钟线CLK
3 黑线 - 电源负极GND
4 红线 + 电源正极VCC

使用教程

准备

硬件

软件

连接图

样例代码

/*!
       @file DFRobot_VL53L0X.ino
       @brief DFRobot's Laser rangefinder library
       @n The example shows the usage of VL53L0X in a simple way.

       @copyright   [DFRobot](https://www.dfrobot.com), 2016
       @copyright   GNU Lesser General Public License

       @author [LiXin]
       @version  V1.0
       @date  2017-8-21
       @https://github.com/DFRobot/DFRobot_VL53L0X
     timer*/
#include "Arduino.h"
#include "Wire.h"
#include "DFRobot_VL53L0X.h"

/*****************Keywords instruction*****************/
//Continuous--->Continuous measurement model
//Single------->Single measurement mode
//High--------->Accuracy of 0.25 mm
//Low---------->Accuracy of 1 mm
/*****************Function instruction*****************/
//setMode(ModeState mode, PrecisionState precision)
//*This function is used to set the VL53L0X mode
//*mode: Set measurement mode       Continuous or Single
//*precision: Set the precision     High or Low
//void start()
//*This function is used to enabled VL53L0X
//float getDistance()
//*This function is used to get the distance
//uint16_t getAmbientCount()
//*This function is used to get the ambient count
//uint16_t getSignalCount()
//*This function is used to get the signal count
//uint8_t getStatus();
//*This function is used to get the status
//void stop()
//*This function is used to stop measuring

DFRobotVL53L0X sensor;

void setup() {
  //initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
  //join i2c bus (address optional for master)
  Wire.begin();
  //Set I2C sub-device address
  sensor.begin(0x50);
  //Set to Back-to-back mode and high precision mode
  sensor.setMode(Continuous, High);
  //Laser rangefinder begins to work
  sensor.start();
}

void loop()
{
  //Get the distance
  Serial.print("Distance: "); Serial.println(sensor.getDistance());
  //The delay is added to demonstrate the effect, and if you do not add the delay,
  //it will not affect the measurement accuracy
  delay(500);
}

测量结果

串口显示测量到的距离等信息

测量结果示意

测试数据表(单位:mm)

API列表

#include <DFRobot_EINK.h>

DFRobotVL53L0X sensor  //创建一个VL53L0X对象
/*
   @函数功能:设置测距模式。
   @参数1 mode: 测距模式。
       Single: 单次测距。
       Continuous: 连续测距。
   @参数2 precision: 测量精度
       High: 高精度(0.25mm)。
       Low: 标准精度(1mm)。
*/
void setMode(uint8_t mode, uint8_t precision);
/*
   @函数功能:开始测量距离。
*/
void start();
/*
   @函数功能:停止测量。
*/
void stop();
/*
   @函数功能:获取距离。
*/
uint16_t getDistance();
/*
   @函数功能:获取环境量。
*/
uint16_t getAmbientCount();
/*
   @函数功能:获取信号数。
*/
uint16_t getSignalCount();

兼容性测试

MCU 测试通过 测试失败 未测试 特别标注
FireBeetle-Board328P
FireBeetle-ESP32
FireBeetle-ESP8266
Arduino UNO/ Leonardo/ Mega2560

Mind+ 上传模式编程

  1. 下载及安装软件。下载地址:https://www.mindplus.cc 详细教程:Mind+基础wiki教程-软件下载安装
  2. 切换到“上传模式”。 详细教程:Mind+基础wiki教程-上传模式编程流程
  3. “扩展”中选择“主控板”中的“Arduino Uno”,“传感器”中加载“VL53L0X激光测距传感器”。 详细教程:Mind+基础wiki教程-加载扩展库流程
  4. 进行编程,程序如下图:
  5. 菜单“连接设备”,“上传到设备”
  6. 程序上传完毕后,打开串口即可看到数据输出。详细教程:Mind+基础wiki教程-串口打印

结果

打开串口监视器,将波特率调整到9600,移动传感器靠近物体,通过串口观察激光测距传感器测得的距离值。

Mind+ Python模式编程(行空板)

Mind+Python模式为完整Python编程,因此需要能运行完整Python的主控板,此处以行空板为例说明

连接图

操作步骤

1、下载及安装官网最新软件。下载地址:https://www.mindplus.cc 详细教程:Mind+基础wiki教程-软件下载安装

2、切换到“Python模式”。“扩展”中选择“官方库”中的“行空板”和“pinpong库”中的”pinpong初始化“和“VL53L0X激光测距传感器”。切换模式和加载库的详细操作链接

3、进行编程

4、连接行空板,程序点击运行后,可在终端查看数据。行空板官方文档-行空板快速上手教程 (unihiker.com)

代码编程

以pinpong库为例,行空板官方文档-行空板快速上手教程 (unihiker.com)

#  -*- coding: UTF-8 -*-

# MindPlus
# Python
from pinpong.libs.dfrobot_vl53l0 import VL53L0
from pinpong.board import Board
import time


Board().begin()
p_vl53l0x = VL53L0()
p_vl53l0x.set_mode(p_vl53l0x.Continuous, p_vl53l0x.High)

while True:
    print(p_vl53l0x.get_distance_mm())
    time.sleep(1)

产品尺寸

常见问题

还没有客户对此产品有任何问题,欢迎通过qq或者论坛联系我们!

更多问题及有趣的应用,可以 访问论坛 进行查阅或发帖。

更多

DFshopping_car1.png DFRobot商城购买链接