Home > Sensors & Modules > Sensors > Range & Distance Sensors

Introduction

The TF Mini LiDAR is an unidirectional laser range finder based on time-of-flight (ToF) technology. It consists of special optical and electronic devices, which integrates adaptive algorithm for indoor and outdoor application environment. It has tiny body and high performance in distance measurement.

The laser sensor can be used as a distance-measuring tool to detect the distance from it to obstacles. It can also be used as an eye of a robot; it provides distance information for robotic safe avoidance and route selection. It supports for system automation in a variety of machine control scenarios. Because of its small size, light weight and low power consumption, it is also suitable for altitude holding and terrain following.

TF Mini's maximum detection distance is 12 meters. TF Mini also supports 100Hz sampling resolution, within 6 meters, its accuracy is within 4cm, 6~12 meters, accuracy within 6 cm. FOV of 2.3 degree. Its anti-interference is strong, and can work in outdoor light, the overall weight is 4.7g.

TF Mini LiDAR adopts UART (TTL) communication interface, can supplied by standard 5V, and its average power consumption is 0.6w. It can be compatible with a variety of Arduino controllers. With the DFRobot Gravity IO Expansion Shield, Arduino can be plugged in directly without additional wiring. It can be easily integrated into the system when used with the Arduino library developed by DFRobot.

warning_yellow.png NOTE:

Specification

Board Overview

TF_Mini_LiDAR(12m) Pinout

Label Name Function Description
Black GND -
Red VCC +
Blue RXD Receive Data
Green TXD Transmit Data

Tutorial

Here are two ways listed to make the LiDAR(ToF) laser range finder be more intuitive.

  1. Arduino Usage
  2. PC software Debugging
  3. Black and white line detection (line-tracking)

Requirements

Arduino Debugging (PC serial port)

Since TF mini is a serial device and the ordinary Arduino only has one hardware serial port, so we recommend you to  use a software serial port to match the sensor. Users can also use multi-serial port devices such as Arduino Leonardo and Arduino Mega2560. Here we choose Arduino UNO as a controller, which is very common to see and define D12 and D13 as software serial port.

Connection Diagram

TF Mini LiDAR(ToF) Laser Range Sensor Connection Diagram

Sample Code(Arduino Debugging)

/*
  * @File  : DFRobot_TFmini_test.ino
  * @Brief : This example use TFmini to measure distance
  *         With initialization completed, we can get distance value and signal strength
  * @Copyright   [DFRobot](http://www.dfrobot.com), 2016
  *             GNU Lesser General Public License
  *
  * @version  V1.0
  * @date  2018-1-10
*/

#include <DFRobot_TFmini.h>

SoftwareSerial mySerial(12, 13); // RX, TX

DFRobot_TFmini  TFmini;
uint16_t distance,strength;

void setup(){
    Serial.begin(115200);
    TFmini.begin(mySerial);
}

void loop(){
    if(TFmini.measure()){                      //Measure Distance and get signal strength
        distance = TFmini.getDistance();       //Get distance data
        strength = TFmini.getStrength();       //Get signal strength data
        Serial.print("Distance = ");
        Serial.print(distance);
        Serial.println("cm");
        Serial.print("Strength = ");
        Serial.println(strength);
        delay(500);
    }
    delay(500);
}
 Distance = 1000 mm
 Strength =  688

Arduino LCD Distance Numerical Display

In practical application, the sensor will generally work offline. We provide a special case, which powered by a lithium battery and display distance measurement data with LCD. It is especially suitable for outdoor usage.

Connection Diagram(LCD)

TF Mini LiDAR(ToF) Laser Range Sensor LCD Connection Diagram

####Sample Code (Arduino Test)

/*
  * @File  : DFRobot_TFmini_test.ino
  * @Brief : This example use TFmini to measure distance
  *         With initialization completed, we can get distance value and signal strength
  * @Copyright   [DFRobot](http://www.dfrobot.com), 2016
  *             GNU Lesser General Public License
  *
  * @version  V1.0
  * @date  2018-1-10
*/
#include <Wire.h>
#include <DFRobot_RGBLCD.h>
#include <DFRobot_TFmini.h>            //TF Mini header file

SoftwareSerial mySerial(12, 13);      // RX, TX
DFRobot_TFmini  TFmini;
uint16_t distance,strength;

unsigned int lcd_r = 0, lcd_g = 0, lcd_b = 0;
unsigned long delaytime = 0, lighttime = 0;
DFRobot_RGBLCD lcd(16, 2);
void setup()
{lcd.init();
  delay(5000);
  Serial.begin(115200);
  Serial.println("hello start");

  TFmini.begin(mySerial);
  lighttime = millis();
  lcd.setCursor(0, 0);
  lcd.print("Dis:");
  lcd.setCursor(0, 1);
  lcd.print("Str:");
  lcd.setRGB(255, 255, 000);
}
void loop() {

/******************LCD*******************/
 lcd_r = random(256);
  delayMicroseconds(10);
  lcd_g = random(256);
  delayMicroseconds(10);
  lcd_b = random(256);
  if (millis() - lighttime > 3000)
  {
    lcd.setRGB(lcd_r, lcd_g, lcd_b);
    lighttime = millis();
  }
  //delay(100);
  /**************TF Mini***************/
 if(TFmini.measure()){                          //Measure Distance and get signal strength
        distance = TFmini.getDistance();       //Get distance data
        strength = TFmini.getStrength();       //Get signal strength data

    lcd.setCursor(5, 0);                       //LCD display
    lcd.print(  distance / 10000);
    lcd.print(  distance/ 1000 % 10);
    lcd.print('.');
    lcd.print(  distance / 100 % 10);
    lcd.print(  distance / 10 % 10);
    lcd.print(  distance  % 10);
    lcd.print(" m");
    lcd.setCursor(5, 1);
    lcd.print(strength / 10000);
    lcd.print(strength / 1000 % 10);
    lcd.print(strength / 100 % 10);
    lcd.print(strength / 10 % 10);
    lcd.print(strength % 10);
    }
}
Dis: 05.000 m
Str: 00600

TF Mini LiDAR(ToF) Laser Range Sensor LCD

Upper Computer Display

In addition to reading data through a single chip, we can also use PC Software to read distance output. ====Connection Diagram(Upper PC Display)====

TF Mini LiDAR(ToF) Laser Range Sensor Connection Diagram(Upper PC)

TF Mini LiDAR(ToF) Laser Range Sensor Upper PC Data Display

Black & White Line Detection (Line-tracking Inspection)

Connection Diagram(Line-tracking)

TF Mini LiDAR(ToF) Laser Range Sensor Connection Diagram(Line-tracking)

Sample Code(Line-tracking)

/*
  * @File  : DFRobot_TFmini_test.ino
  * @Brief : This example use TFmini to measure distance
  *         With initialization completed, we can get distance value and signal strength
  * @Copyright   [DFRobot](http://www.dfrobot.com), 2016
  *             GNU Lesser General Public License
  *
  * @version  V1.0
  * @date  2018-1-10
*/

#include <DFRobot_TFmini.h>

SoftwareSerial mySerial(12, 13); // RX, TX

DFRobot_TFmini  TFmini;
uint16_t distance,strength;

void setup(){
    Serial.begin(115200);
    TFmini.begin(mySerial);
}

void loop(){
    if(TFmini.measure()){                      //Measure Distance and get signal strength
        strength = TFmini.getStrength();       //Get signal strength data
        Serial.print("Strength = ");
        Serial.println(strength);
    }
}

TF Mini LiDAR(ToF) Laser Range Sensor Signal Strength change

FAQ

Q&A Some general Arduino Problems/FAQ/Tips
A For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get TF Mini LiDAR(ToF) Laser Range Sensor from DFRobot Store or DFRobot Distributor.