element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Using DFRobot_LIDAR07 with Arduino Uno
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 20 Dec 2021 6:01 PM Date Created
  • Views 3225 views
  • Likes 6 likes
  • Comments 0 comments
  • dfrobot
  • i2c
  • arduino uno
  • lidar
  • lidar07
Related
Recommended

Using DFRobot_LIDAR07 with Arduino Uno

ralphjy
ralphjy
20 Dec 2021

I've used ST microLIDAR Time-of-Flight sensors previously to measure short distances.  A VL6180X to focus my laser cutter laser-focus-assembly-completed and VL53L0/1X sensors for distances up to 4 meters in projects whose blogs I can't locate on this new site.

I have a requirement for longer distance measurements of 10-12 meters and I came across the LIDAR07 from DFRobot that is spec'ed to measure up to 12 meters:  TOF_IR_Distance_Sensor_0.2_12m .  One compromise of the longer range is that minimum measurable distance is 20cm.

In honor of the 10 millionth Arduino Uno, I decided to use one for my initial tests Slight smile.

image

image

The LIDAR07 uses either a UART or I2C interface.  I am going to use I2C.

I 3D printed a tripod mount and wired a small proto board to interface the 8 pin cable to a Grove connector since I have a lot of Grove cables.

image

image

I downloaded and installed the DFRobot_LIDAR07 Arduino library from github DFRobot_LIDAR07 .

Lidar07_I2C_measureDistance.ino

/**
 * @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  2021-04-16
 * @get from https://www.dfrobot.com
 * @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);

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

void loop() {
  int errinfo;
  while(!LIDAR07.startMeasure()){
    Serial.println("Incorrect data was returned");
    delay(1000);
  }
  Serial.print("Distance:");Serial.print(LIDAR07.getDistanceMM());Serial.println(" mm");
  Serial.print("Amplitude:");Serial.println(LIDAR07.getSignalAmplitude());
  delay(1000);
}

Here is a sample of readings from the Serial Monitor:

image

You can see that the amplitude of the received signal reduces as the distance to the target increases.  Another issue with this sensor is that the minimum required target size increases by quite a bit with distance.  It is 0.9m at 12 meters.  Luckily, I am looking for larger objects and this would possibly act as a filter to exclude small animal detection.

image

Accuracy and repeatability will not be as good as the shorter range sensors, but if it's good to ~20cm - that will be sufficient for my use case.  That's something that I'll need to characterize.

For outdoor and full range testing, I'm going to hook the sensor up to an ESP32.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube