15m TOF Laser Ranging Distance Module for Outdoor Wiki - DFRobot

Introduction

This is a TOF-based single-point laser ranging sensor for outdoor use. It has 100K LUX resistance to strong ambient light, which means there will be no problems at all when using it on sunny days.
With a detection range of 5cm to 15m, the product features distance resolution 1mm, 50Hz data update frequency, 1~2° FOV and supports UART, IIC and I/O multiple communication modes(support active and query output data in UART mode).
Small in size, there are standard screw holes reserved on the side and bottom of the module, which is convenient for installation in various places. It can be widely used in the fields of drone height setting, route planning, smart car competition and transportation, industrial automation, high-speed measurement and safety monitoring, etc.

warning_yellow.png NOTE: When exceeding the measurement range of 15m, the error is larger in the range of 15m to about 20m. And the sensor outputs 0 when detecting an object out of 20m.

Specification

Board Overview

Board Overview

For using UART

Num Label Description
1 vcc Power supply +
2 GND Power supply +
3 RX UART receiving data line
4 TX UART transmitting data line

For using I2C

Num Label Description
1 vcc Power supply +
2 GND Power supply +
3 IIC_SDA I2C data line
4 IIC_SCL I2C data line

For using I/O

Num Label Description
1 vcc Power supply +
2 GND Power supply +
3 I/O_H Output High
4 I/O_L Output Low

Module Instruction

Principle of Use

TOF is an absolute distance detection technology, that is, the sensor emits the near-infrared light to be debugged, and it will reflect when encountering an object. The sensor calculates the distance of the captured scene by calculating the time difference or phase difference between light emission and reflection to generate depth information. Compared with the binocular scheme and the 3D structured light scheme, TOF has the advantages of long working distance, wide range of application scenarios, and high accuracy at long distances. Therefore, it is often used in personnel approach detection, robot obstacle avoidance, camera autofocus and other occasions.

Principle

Overview

The module can meet the needs of various scenarios. It can output distance measurement value (dis), distance status (dis_status), signal strength (signal_strength), ranging precision (range_precision) and other information.

Interface and Baud Rate

The module supports configuration as UART, IIC, I/O communication mode, the factory default is UART communication. If you need to use other communication modes, you can configure it through the module host computer.

Host download:
64bitnassistant_windows_64bit.zip 32bitnassistant_windows_32bit.zip

UART

Under serial communication, the baud rate setting range is as follows.

UART_Baudrate Note
115200,230400,460800,921600,1000000,1200000, 1500000,2000000,3000000 Default Baud Rate 921600

I2C

In IIC output mode, the baud rate setting range is shown in the table below.

IIC_Baudrate Note
Up to 400K The maximum baud rate is 400Kbps, determined by the host.

The IIC slave address of the current module. The setting range is as follows:

IIC_Address Note
0x08~0x77 The default address is 0x08 (7-bit address), and the slave address is 0x08+module ID. The slave address can be changed by changing the ID parameter of the module. The ID setting range is 0~111. Pay attention to shifting and increasing the read and write bits when communicating, that is, when the address is 0x08, the bytes with read and write bits sent are 0x10 (write), 0x11 (read)

Distance Status

The module can output the current distance status, and the user can process data in combination with the distance status. The specific meaning is shown in the following table.

Value Note
0 Invalid distance measurement
1 Valid measurement

Signal Strength

Indicates the strength of the current return signal, the larger the value, the stronger the return signal.

Range Precision

Indicates the accuracy of the current ranging, the smaller the value, the better the ranging accuracy.

FOV

The size of the FOV determines the field of view of the module, and the field of view of the module is 1~2°.

Mode Switch

If the module is in UART mode, you can connect NAssistant software to switch to IIC or I/O mode. If the module is in IIC mode, it needs to send a command to the module through IIC communication to switch back to UART mode. In addition, you can switch back to UART mode in the following ways when there is no IIC test environment or after switching to I/O mode:
You need to prepare a USB to TTL module that supports 921600 baud rate (CP2102 is recommended) and install the corresponding driver. Connect the TX, RX, and GND lines of the USB to TTL module to the corresponding pins of the TOF module, and leave the VCC pin temporarily unconnected. Then insert the USB to TTL module into the computer, open our host computer software, click 1 icon to enter the serial port debugging assistant, change the baud rate to 921600, select the COM port corresponding to the USB to TTL module, then click the connect button 2 to connect the COM port (it will connect automatically in most cases). Enter 54 20 00 ff 00 ff ff ff ff 00 ff ff 00 10 0e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7b in the Single Send text box. Change the sending interval to 20ms in the timing sending column in the lower right corner, then check the timing transmission 3 , at this time connect the 5V of the USB to TTL module to the VCC pin of the TOF module, the module will switch to UART mode and start outputting data. At this point, unplug the USB to TTL module, power on the module again, and click the identification button 4 on the main page to identify the module. If the switch fails or the output data is abnormal, you can repeat the whole step.

Module Protocol Analysis

Example

The below takes single-module continuous ranging as an example.

UART Active Output Mode

The protocol consists of Frame Header, Function Mark, Data, and Sum Check. Among them, Frame Header and Function Mark are fixed values; Data is the transmitted data content, and Sum Check is the lowest byte after adding Frame Header, Function Mark, and Data (that is, adding all the preceding bytes). Protocol composition: Frame Header + Function Mark + Data + Sum Check

Original data: 57 00 ff 00 9e 8f 00 00 ad 08 00 00 03 00 ff 3a
The command format is as follows:

Data Type Length(Bytes) Hex Results
Frame Header uint8 1 57 0x57
Function Mark uint8 1 00 0x00
reserved uint8 1 ... *
id uint8 1 00 0
System_time uint32 4 9c 8f 00 00 36766ms
dis*1000 uint24 3 ad 08 00 2.221m
dis_status uint8 1 00 0
signal_strength uint16 2 03 00 3
range_precision uint8 1 06 6cm
Sum Check uint8 1 41 0x41

UART Query Output Mode

Original data: 57 10 FF FF 00 FF FF 63
The command format is as follows:

Data Type Length(Bytes) Hex Results
Frame Header uint8 1 57 0x57
Function Mark uint8 1 10 0x10
reserved uint16 2 ... *
id uint8 1 00 0
reserved uint16 2 ... *
Sum Check uint8 1 63 0x63

I2C Communication Mode

Slave address: The module works as a slave in the IIC bus, the default address is 0x08 (7-bit address), and the slave address is 0x08+module ID. You can change the slave address by changing the ID parameter of the module. When communicating, pay attention to address shifting and adding read and write bits, that is, when the address is 0x08, the bytes with read and write bits are 0x10 (write) and 0x11 (read).
Register address: If there is no corresponding parameter in the register, the default output is 0xff. Refer to the table below.

0

I2C Communication Process:

Single data write
Write

Single data read
Read

Multiple data write
Multiple write

Start: start signal
W: Write flag bit 1
R: Read flag bit 0
ACK: Acknowledgment
NACK: Non-acknowledgment
Stop: Stop signal

Send

Tutorial

Requirements

Debug on Arduino(PC Serial)

Since this module is a serial port device, and ordinary Arduino has only one hardware serial port, it is recommended to use a soft serial port or multi-serial port devices, such as Arduino Leonardo, Arduino Mega2560 and other devices. Here, the most common Arduino UNO is used as the controller, and D10 and D11 are defined as soft serial ports.

Connection Diagram

Use the serial port software on the PC end to display the detected distance and power the entire system.

Connection

Arduino Debug Code

A PC serial port tool is required, the read data will be displayed on the serial port tool interface.

/*
  * @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 <SoftwareSerial.h>
SoftwareSerial mySerial(11,10); // RX, TX
int i;
int dat[32]={0};
unsigned long a,p,q,z;
void setup()
{
 Serial.begin(9600);
 mySerial.begin(115200);
}

void loop()
{
    if(mySerial.available()>=32)
    {
      if(millis()-a>500)
      {
        a=millis();
        for(i=0;i<32;i++)
        {
          dat[i]=mySerial.read();
        }
        for(i=0;i<16;i++)
        {
          if(dat[i]==0x57&&dat[i+1]==0&&dat[i+2]==0xff&&dat[i+3]==0)
          {
            if(dat[i+12]+dat[i+13]*255==0)
            {
              Serial.println("Out of range!");
            }
            else
            { 
          z=dat[i+11];
          Serial.print("Status = ");
          Serial.print(z);
          p=dat[i+12]+dat[i+13]*255;
          Serial.print("  Strength = ");
          Serial.print(p);
              q=dat[i+8]+dat[i+9]*255;
              Serial.print("  Distance = ");
              Serial.print(q);
              Serial.println("mm");
            }
             break; 
          }
        }
      }
    }
}

Expected Results

The serial port software displays the data format as follows.

Result

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Outdoor Laser Ranging Module(15m) from DFRobot Store or DFRobot Distributor.

Turn to the Top