# Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART)

Configuring TFmini-Plus with UART Interface on Ardupilot Flight Stack using PixHawk1 Flight Controller

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 1, figure 1](https://ai.benewake.com/uploads/images/0963eabd-205e-491a-bd9f-581c26718564.png)

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 1, figure 2](https://ai.benewake.com/uploads/images/e63a4498-7b51-4bcd-9083-d9fea11ce59b.png)

TFmini-Plus can directly be connected with the serial port of PixHawk1. TFmini-Plus can be interfaced with flight controller for the purpose of Altitude Holding or Obstacle Avoidance. At the time of writing this document the controller used was PixHawk1 flashed with ArduCopter V4.0.4. But this document can be used with other flight controllers running with different ArduCopter firmware versions with slight modification in parameter names and choosing the right port on flight controller.

Example for connecting to PixHawk1:

Figure 1 Schematic Diagram of Connecting TFmini-Plus with TELEM 2 Interface (Serial Port 2) of PixHawk1

Note: Standard output mode of LiDAR should be used instead of PIX mode in the latest firmwares. PIX mode was only required for the firmware versions older than Arducopter V3.6.2.

a） Mission Planner configuration description of TFmini-Plus for the purpose of altitude hold

Connect the flight control board to Mission Planar. Attention: the installation height should be larger than non-detection/blind zone of LiDAR. Select [CONFIG/TUNING] and then click on [Full Parameter List] in the left from the below bar. Find and modify the following parameters:

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 2, figure 1](https://ai.benewake.com/uploads/images/01c1d0c8-36d7-4e48-89f0-6e5194acbaeb.png)

SERIAL2_PROTOCOL = 9 [Rangefinder option]

SERIAL2_BAUD = 115 [Choose the current LiDAR baud rate, if haven’t been changed, the default baud rate 115200 should be selected, that is 115]

RNGFND1_TYPE = 20 [TFmini-Plus UART option]

RNGFND1_MIN_CM = 30 [It could be changed according to real application requirement and should be greater LiDAR than non-detection zone, unit is cm]

RNGFND1_MAX_CM = 300 [It could be changed according to real application requirement and should be smaller than effective measure range of LiDAR, unit is cm]

RNGFND1_GNDCLEAR = 15 [expressed in cm, depending upon mounting height of the module and should be greater LiDAR than non-detection zone]

RNGFND1_ORIENT=25 [facing down]

PRX_TYPE=0

Upon setting of these parameters, click [Write Params] on the right of mission planner to finish. After writing the parameters you need to power off the controller and then turn it on to apply the setting changes.

If the error message “Bad LiDAR Health” appears, please check if the connection is correct, the power supply is normal and have you restarted the controller? Also check it whether you have changed the

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 3, figure 1](https://ai.benewake.com/uploads/images/4fc8357b-db67-4f4b-a544-7bb522700a2f.png)

mode from Standard mode to Pix mode while the firmware is 3.6.2 or higher if yes then the same error will encounter.

How to see the altitude value from LiDAR sensor: double click the area of the Mission Planner, look at the following picture:

Select option sonarrange, see following picture:

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 4, figure 1](https://ai.benewake.com/uploads/images/50876fba-9d06-4ac0-a618-0fed1e468ffa.png)

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 4, figure 2](https://ai.benewake.com/uploads/images/ea3fd144-21a1-4d62-9ab2-d1f6490b7481.png)

The altitude distance from the LiDAR will be displayed in Sonar Range (meters), see the following picture:

B） Mission Planner configuration description of TFmini-Plus for the purpose of Obstacle Avoidance

Connect the flight control board to MP. Attention: distance between UAV margin and LiDAR should be larger than LiDAR non-detection zone. Select [Full Parameter List] in the left from the below bar- [CONFIG/TUNING]. Find and modify the following parameters:

AVOID_MARGIN=2 [Unit: m, set obstacle avoidance distance as required]

SERIAL2_PROTOCOL = 9 [Rangefinder option]

SERIAL2_BAUD = 115 [Choose the current LiDAR baud rate, if haven’t been changed, the default baud rate 115200 should be selected, that is 115]

RNGFND1_TYPE = 20 [TFmini-Plus UART option]

RNGFND1_MIN_CM = 30 [It could be changed according to real application requirement and should be greater LiDAR than non-detection zone, unit is cm]

RNGFND1_MAX_CM = 300 [It could be changed according to real application requirement and should be smaller than effective measure range of LiDAR, unit is cm]

RNGFND1_ORIENT = 0 [It depends on the LiDAR’s real installation direction, 0~7, 24=Up and 25=Down (total ten) are supported up till now, see detail in MP]

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 5, figure 1](https://ai.benewake.com/uploads/images/57c9e05d-d834-4814-9744-8d2a7d2901b1.png)

PRX_TYPE=4 [Rangefinder should be selected for proximity sensor in obstacle avoidance mode]

AVOID_ENABLE= 3 [if 3 = UseFence and UseProximitySensor doesn’t work in IIC then choose 2 = UseProximitySensor]

Upon setting of these parameters, click [Write Params] on the right of the software to finish. After writing the parameters you need to power off the controller and then turn it on to apply the settings.

If the error message “PreArm: check the proximity sensor” appears, please check if the connection is correct, the power supply is normal and have you restarted the controller. Also check it whether you have changed the mode from Standard mode to Pix mode while the firmware is 3.6.2 or higher if yes then the same error will encounter.

How to see the target distance measured by the LiDAR: (distance from LiDAR in obstacle avoidance can’t be displayed in sonarrange option) press Ctrl+F button in keyboard, the following window will pop out:

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 6, figure 1](https://ai.benewake.com/uploads/images/04fff9b1-dfbb-40a2-9d5a-4708e1de18a6.png)

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 6, figure 2](https://ai.benewake.com/uploads/images/8c23abc0-2ad5-47ad-bff0-37da5dcc278b.png)

Click button Proximity, the following window will appear:

The number in green color means the distance from LiDAR in obstacle avoidance mode（it doesn’t mean the real time distance from LiDAR and will not be influenced in Mission Planner. The mission planner version at the time of writing this tutorial was v1.3.69.

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 7, figure 1](https://ai.benewake.com/uploads/images/16b5b695-b626-4b43-be3f-a470de60b216.png)

 Attach: If TELEM 2 port has been used, SERIAL4/5 interface can be used, the other setting are same

Figure 2: Schematic Diagram of Connecting TFmini-Plus with SERIAL4/5 Interface of PixHawk1

Configuration Descriptions on Mission Planner:

Connect flight control board to MP, Select [Full Parameter List] in the left from the below bar [CONFIG/TUNING]. Find and modify following parameters:

SERIAL4_PROTOCOL = 9 (LiDAR)

SERIAL4_BAUD = 115

Upon setting of these parameters, the other parameters are same as Mission Planner configuration description of TFmini-Plus for the purpose of Obstacle Avoidance or Altitude Holding, then click [Write Params] on the right of the software to finish.

![Configuring TFmini-Plus on Ardupilot using PixHawk1 (UART) — source page 8, figure 1](https://ai.benewake.com/uploads/images/2832f3d8-5651-48fb-96ec-cf4f7bebc217.png)
