RC India
Welcome Guest, please login or register.
Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools Topic Tools 
« on: January 16, 2018, 02:35:22 PM »
Plane Lover
Active Member

Reputation Power: 2 
Kevin_Sunny has no influence.
Offline Offline

City: Beijing, China
RC Skills: Beginner
Posts: 10
Join Date: Jan, 2018

 Hello, everyone. I am sharing how to connect Benewake TF LiDAR to Arduino.
    May this helpful.

Step 1: Hardware Connection
    The linear order for the LiDAR products of our company is defined as: red +5V, black GND, green
TX, white RX; the power supply voltage for TF02 is 5V, so it is permissible to directly connect 5V and
GND on the Arduino board. For other LiDARs, please refer to product specification to ensure normal
power supply; For serial communication connection, please note that with regard to Arduino UNO board, the TX end of LiDAR connects to pin 2 port (soft serial port Serial1ís RX) and the RX end of LiDAR connects to pin 3 (soft serial port Serial1ís TX). This is relevant to the programming hereinafter; For Arduino DUE board, the TX end of LiDAR connects to RX1 port and the RX end of LiDAR connects to TX1 port.
Development Routines of TF LiDAR on Arduino

Step 2: Programming

The implementation of this routine functions requires at least two serial ports: one for receiving
data from LiDAR and the other for sending data to PC for display. You can copy the following code to
IDE syntax editor or directly open corresponding attachment files.
/* This program is a parsing routine of TF02 product standard output protocol on Arduino.

The format of data package is 0x59 0x59 Dist_L Dist_H Strength_L Strength_H Sequence_L Sequence_H CheckSum_L
Refer to the product specification for detailed description.
For Arduino board with one serial port, use software to virtualize serial portís functions: such as UNO board.
#include<SoftwareSerial.h>// soft serial port header file
SoftwareSerial Serial1(2,3); // define the soft serial port as Serial1, pin2 as RX, and pin3 as TX
/*For Arduino board with multiple serial ports such as DUE board, comment out the above two codes, and directly use Serial1 port*/
int dist;// LiDAR actually measured distance value
int strength;// LiDAR signal strength
int check;// check numerical value storage
int i;
int uart[9];// store data measured by LiDAR
const int HEADER=0x59;// data package frame header
void setup()
  Serial.begin(9600);//set the Baud rate of Arduino and computer serial port
  Serial1.begin(115200);//set the Baud rate of LiDAR and Arduino serial port
void loop()
  if (Serial1.available())//check whether the serial port has data input
    if(Serial1.read()==HEADER)// determine data package frame header 0x59
      if(Serial1.read()==HEADER)//determine data package frame header 0x59
        for(i=2;i<9;i++)// store data to array
      if(uart[8]==(check&0xff))// check the received data as per protocols
        dist=uart[2]+uart[3]*256;// calculate distance value
        strength=uart[4]+uart[5]*256;// calculate signal strength value
        Serial.print("dist = ");
        Serial.print(dist);// output LiDAR tests distance value
        Serial.print("strength = ");
        Serial.print(strength);// output signal strength value

Step 3: Data View
    Upload the program to the Arduino board and open the serial monitor to check the distance value
detected by LiDAR in real time and corresponding signal strength as in Figure 3;
    Besides, you can also check the data curves on the serial curve plotter, but for that you need to
modify the code related to serial printing (Serial.print):
//         Serial.print("dist = ");
            Serial.print(dist);// output LiDAR tests distance value
            Serial.print(' ');
//         Serial.print("strength = ");
            Serial.print(strength);// output signal strength value
     Re-compile and upload them to Arduino board. Open the serial curve plotter and you can see two
curves representing distance and strength as in Figure 4.

Development Routines of TF LiDAR on Arduino

Development Routines of TF LiDAR on Arduino


Pages: [1]   Go Up
Jump to:  

Related Topics
Subject Started by Replies Views Last post
3D routines from a master showing stick movement
RC Maneuvers and Skills
anwar 3 4027 Last post October 05, 2012, 08:55:25 PM
30 Arduino Projects Evil Genius:- Great book to start Arduino Projects
rcpilotacro 5 5533 Last post July 05, 2012, 10:23:44 AM
by xxkrishxx
UAV development « 1 2 3  All »
Self-designed, DIY and College Projects
INFAMOUS 56 10613 Last post July 12, 2015, 03:09:57 PM
by Devanesan Andrews
Development of quadcopter
Chatter Zone
Swayam 0 334 Last post November 14, 2016, 08:05:28 AM
by Swayam
TF02 LiDAR-- Rangefinder for drone
Electric Planes
Kevin_Sunny 0 128 Last post January 25, 2018, 01:45:48 PM
by Kevin_Sunny