1.Introduction of Traffic flow and Height Detector

This plan use Benewake company’s product TFmini-Plus combined with Arduino-UNO.

The usage:count flowrate and height.

Equipment and wires

2.1    Equipment

  • Benewake TFmini-Plus

TFmini-Plus detail is on the TFmini-Plus Instructions on benewake website: http://en.benewake.com/download

  • Arduino-UNO

Detail introductions and study of Arduino is on the website below:

Chinese community:http://www.arduino.cn/

English Website:https://www.arduino.cc/

  • Computer

The computer is used as the function of program writing, uploading and data displaying. Data display function can be upgraded and optimized later, such as increasing the display screen to display current traffic and height data, and broadcasting greetings such as "Welcome" with speaker.

  • Wires

Dupont Line——Used for Plus and UNO board connection (Plus terminal removable)

USB Square Port Data Connection Line——Used to connect UNO board to computer

2.2           Wiring

TFmini Plus product line is defined as:red+5Vblack GNDgreen TXwhite RXTFmini-Plus The supply voltage is 5Vso connect directlyFor other radars, please refer to the product specificationsto ensure normal power supply

Serial communication connection needs attention,pin 2 ports of TX terminal plate for arduino UNO plate radar(RX of soft serial 1)pin 3 ports of radar RX terminal board(TX of soft serial 1this is related to the programming in the following article.

  1. Measuring Principle of Human Flow Height
  • After the LiDAR start, set the installing height, height limit, lower limit.
  • When the people enter the detection area, the data will goes up, output number of people, every time this happens, number of people plus one, then output the number.
  • When the people enter the detection area, the data will wave around the height limit, compare it with Height, Height is the peak of the data wave
  • When people go out the detection area, the data goes down, output Height.

  1. program chart


The implementation of this routine requires at least two serial ports,a data receiving radaranother is used to output data to the computer for display. You can copy and paste the following code into the IDE program edit windowyou can also open the corresponding attachment file directly.

(Get the file? Email us via: bw@benewake.com)


#include<SoftwareSerial.h>// Soft string oral document

SoftwareSerial Serial1(2,3); // Define the name of the soft serial port Serial1,and pin2 is defined as RXpin3 is designated as TX /* For Arduino boards with multiple serial ports, such as DUE boards,comment out the above two pieces of code and use Serial 1 serial port directly. */ int dist;// Distance LiDAR detected

int strength;//LiDAR signal intensity,which is implausible if the data is under 100

int IH=230;//Height of  installing LiDAR(need to be set),need to adjust based on the black object in real

int H;//Height

int h=0;//last detected height

int check;//Check the stored data

int i;

int Number=0;//number of people

int Height=0;//Maxmium of height

int up=50;//height limit(Need to be set),height of the object is credible if is over the limit

int down=40;//lower limit(Need to be set),height lower than lower limit over the height limit will be counted, in case the height is equal to the height limit exactly which will case data waving and conduct errors.

int uart[9];//Store LiDAR detected data

const int HEADER=0x59;// pockets frame header

void setup()


Serial.begin(115200);// Set Baud Rate of Connecting Serial Port of Arduino and Computer

Serial1.begin(115200);//Set Baud Rate of Connecting Serial Port of Arduino and LiDAR


void loop()


if (Serial1.available())//Check SATA have data input or not


if(Serial1.read()==HEADER)// Decide pockets frame header 0x59



if(Serial1.read()==HEADER)//Decide pockets frame header 0x59



for(i=2;i<9;i++)//Store the data into array





if(uart[8]==(check&0xff))//Check the received number following the agreement {

dist=uart[2]+uart[3]*256;//calculate the distance

strength=uart[4]+uart[5]*256;//]calculate intensity of the signal

H=IH-dist;//calculate height

/*Detect number of people*/

/*theory: when data break through from lower limit to height limit, then number of people plus one */

if(H>=up&h<down)//when people enter the detecting area, the number of people plus one





Serial.print("Number = ");

Serial.print(Number);//Output the value



if(H>=up&h>=down)//When people are within the detecting area, compare the values to find the Maximum one.







if(H<down&h>=up)//When people walked out of the detecting area, the height outputted reach to peak, meanwhile it will be reset to zero.


Serial.print("Height = ");

Serial.print(Height);//Output the height





//                       Serial.print("H = ");

//                       Serial.print(H);//Output the height

//                       Serial.print('\t');

//                       Serial.print("dist = ");

//                       Serial.print(dist);//Output LiDAR detected distance

//                       Serial.print('\t');

//                       Serial.print("strength = ");

//                       Serial.print(strength);//Intensity of the output signal

//                       Serial.print('\n');






Upload the program to Arduino, open the serial monitor, then you can see the flowrate and height of the person. As the picture below:

  1. Notes
  • Installing height should based on the real black object to adjust, because different color have different reflectivity, so LiDAR will detect different signal. Installation height needs to be corrected according to actual black objects,Because different color objects have different reflectivity and different signals received by radar
  • When people are walking in a group, LiDAR can only detect one object, so this plan is suitable for detecting one person’s move. When many people walk together, the radar spot can only hit one object, and can only count plus one, which is suitable for single-person entry and exit scenarios.
  • If the facula didn’t hit on the head completely, then the height detected will be error. Considering the possible of mistake on height data while people walking, try to let the facula hit the feet, using the highest detected value to cut down error.
  • Buffer area is a "height limit - lower limit", which avoids the situation that the number of repetitions increases by 1 when the detection height happens to be a "height limit" object.

If you are interested, welcome to contact us: en.benewake.com

Views: 40

Reply to This

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service