TOF红外激光测距传感器模块(0.2~12m)

简介

这款测距模组是一个基于单点TOF技术,采用850nm LED光源,配合独特的光学、结构、电路设计而成的低成本测距模组,实现中短距离的测距需求,测距范围为 0.2m~12m,结合相应的滤波算法处理,可以得到极低的测量噪声。 该款测距模组同时支持 I2C 和 UART 的通信,便于终端产品的集成。在测距方面提供单次被动测量和连续主动测量,以满足不同终端产品的实际使用需求。

技术规格

注:除了能在各主板上使用外,模组还可以直接在上位机使用,上位机软件与使用教程在最下方的PDF资料文件中。

引脚示意图

引脚示意图
标号 名称 功能描述
1 SCL I2C 通讯时钟线
2 SDA I2C 通讯数据线
3 GND_LED 光源供电地
4 VCC_LED 光源供电电源(5V)
5 TX UART 发送数据线
6 RX UART 接收数据线
7 GND 模块主供电地
8 VCC 模块主供电电源(5V)

使用教程

准备

Arduino I2C接线图

下载DFRobot LIDAR 07库文件如何安装库文件

I2C接线图

示例代码

/**
 * @file measureDistance.ino
 * @brief This example demonstrated the basic distance measuring function of LIDAR07, the range is 0.2m-12m (Operating voltage: 5 V)
 * @n Connection rules: PIN1-PIN8 are in the front of the sensor from right to left. 
 * @n          PIN1----------------------SCL--------------------Maincontroller SCL(IIC mode)
 * @n          PIN2----------------------SDA--------------------Maincontroller SDA(IIC mode)
 * @n          PIN3----------------------Light source power supply ground--------------Maincontroller GND
 * @n          PIN4----------------------Light source power supply(5V)--------Maincontroller VCC
 * @n          PIN5----------------------TX---------------------Maincontroller RX pin, which is set to be used for serial communication with the sensor (UART mode)
 * @n          PIN6----------------------RX---------------------Maincontroller TX pin, which is set to be used for serial communication with the sensor (UART mode)
 * @n          PIN7----------------------Module main power supply ground------------Maincontroller GND
 * @n          PIN8----------------------Module main power supply(5V)------Maincontroller VCC
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author [yangfeng]<feng.yang@dfrobot.com>
 * @version  V1.0
 * @date  2022-06-20
 * @url https://github.com/DFRobot/DFRobot_LIDAR07
 */
#include"DFRobot_LIDAR07.h"

//If using IIC mode, please enable macro USE_IIC
#define USE_IIC
#ifdef USE_IIC  
DFRobot_LIDAR07_IIC  LIDAR07;
#endif

//If using UART mode, please enable macro USE_UART. The USE_UART is enabled by default. The two modes USE_IIC and USE_UART can’t be used at the same time.
//#define USE_UART
#ifdef USE_UART

#if defined(ESP8266)||defined(ARDUINO_AVR_UNO)
#include <SoftwareSerial.h>
SoftwareSerial  mySerial(4,12);//GPIO4 is corresponding to RX on main control board, GPIO12 is corresponding to TX on main control board
/**!
 * The TX of esp32 Serial1 is GPIO10, and the RX is GPIO9 
 * The TX of mega2560 Serial1 is GPIO18, and the RX is GPIO19
 * The TX of M0 Serial1 is GPIO1, and the RX is GPIO0
 * The TX of leonardo Serial1 is GPIO1, and the RX is GPIO0
 */
#endif
DFRobot_LIDAR07_UART  LIDAR07;  
#endif

void setup() {
  uint32_t version;
  Serial.begin(115200);
#ifdef USE_IIC
  while(!LIDAR07.begin()){
    Serial.println("The sensor returned data validation error");
    delay(1000);
  }
#endif

#ifdef USE_UART
#if defined(ESP8266)||defined(ARDUINO_AVR_UNO)
  mySerial.begin(115200);
  while(!LIDAR07.begin(mySerial)){
    Serial.println("The sensor returned data validation error");
    delay(1000);
  }
#else
  Serial1.begin(115200);
  while(!LIDAR07.begin(Serial1)){
    Serial.println("The sensor returned data validation error");
    delay(1000);
  }
#endif
#endif

  version = LIDAR07.getVersion();
  Serial.print("VERSION: ");
  Serial.print((version>>24)&0xFF,HEX);
  Serial.print(".");Serial.print((version>>16)&0xFF,HEX);
  Serial.print(".");Serial.print((version>>8)&0xFF,HEX);
  Serial.print(".");Serial.println((version)&0xFF,HEX);

  //After enabling the filter, it can be stopped by calling LIDAR07.stopFilter()
  LIDAR07.startFilter();

  /**
   * @brief  Configure the sensor to single acquisition mode
   * @param  mode The way data are collected
   * @n      eLidar07Single  A single collection
   * @n      eLidar07Continuous  Continuous acquisition
   * @return true (Successful) , false (Failed)
   */
  while(!LIDAR07.setMeasureMode(LIDAR07.eLidar07Single)){
      Serial.println("set measure mode err");
  }
}

void loop() {

  //Open measurement (in single measurement mode, it will automatically close after sampling),To stop collection, use stopMeasure()
  LIDAR07.startMeasure();

  //Get the collected data
  if(LIDAR07.getValue()){
    Serial.print("Distance:");Serial.print(LIDAR07.getDistanceMM());Serial.println(" mm");
    Serial.print("Amplitude:");Serial.println(LIDAR07.getSignalAmplitude());
  }
  delay(1000);
}

示例结果

结果图

各类主板兼容性

兼容性图

常见问题

还没有客户对此产品有任何问题,欢迎通过 qq 或者论坛联系我们! 更多问题及有趣的应用,可以访问论坛进行查阅或发帖

更多

DFRobot 商城购买链接

通信协议与规格书

上位机软件

上位机操作说明.pdf