TFS20-L can directly be connected with one of the serial ports of Pixhawk 6C or 6X from Holybro. There are four serial ports which can be used to interface LiDAR. The following port mapping shows hardware (left) and software (right) serial port mapping:
- TELEM1 > SERIAL1
- TELEM2 > SERIAL2 (used in this tutorial)
- TELEM3 (USART2) > SERIAL5
- GPS2 Port (UART8) > SERIAL4
TFS20-L can be interfaced with flight controller for the purpose of Altitude Holding or Obstacle Avoidance or Terrain Following. At the time of writing this document the flight controller used was PixHawk 6C from Holybro flashed with ArduCopter V4.3.3. However, this document can also be used with PixHawk 6X and other flight controllers running with different ArduCopter firmware versions with slight modification in parameter names and choosing the right port on flight controller. For choosing right port, refer to the hardware and software serial port mapping of flight controller. Please note that supported firmware of Ardupilot for PixHawk 6C and 6X is 4.2.3 stable release and later.

Figure-1: Pinout sequence of available ports on PixHawk 6C
NOTE: Pin 1 starts from the flight controllers "right side" like in the diagram shown above

Figure-2: Pinout description of available serial ports on PixHawk 6C
Example for connecting TFS20-L to PixHawk 6C:
Figure 3: Schematic Diagram of Connecting TFS20-L with TELEM 2 Interface (Serial Port 2) of PixHawk 6C
The same procedure can be followed for other serial ports like TELEM1/TELEM3/GPS2 by looking at the pin out details given in Figure-2.
Notes:
- Please pay attention to connect right wires to the right pins of flight controller. For pin sequence refer to Figure-2.
- Related connectors need to be purchased by the user, LiDAR connector is SMD HC-0.8-6PWT(PCB connector) and JST SUR 0.8mm Pitch (mating connector), while flight controller needs JST-GH with 1.25mm pitch.
- If LiDAR faces down, please take care of the distance between lens and ground, it should be larger than LiDAR’s blind zone (20cm).
- Power source should meet the product manual current and voltage requirements: peak current is 115mA @ 3.3V.
a) Mission Planner configuration description for TFS20-L used for Altitude Hold
Connect the flight control board to mission planar, Select [Full Parameter List] in the left from the below bar-[CONFIG/TUNING]. Find and modify the following parameters:
PRX1_TYPE = 0 [on equal to 4 also gives the value if RNGFND1_ORIENT = 25]
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 [TFS20-L/TFmini-Plus/TFmini-S 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 = 25 [expressed in cm, depending upon mounting height of the module and should be greater LiDAR than non-detection zone]
RNGFND1_ORIENT = 25 [facing down]

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?
How to see the altitude value from LiDAR sensor: double click the area of Mission Planner, looking at the following picture:

Select option sonarrange, see following picture:

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

b)Mission Planner configuration description for TFS20-L used for Obstacle Avoidance
Connect the flight control board to MP. Select [Full Parameter List] in the left from the below bar- [CONFIG/TUNING]. Find and modify the following parameters:
AVOID_ENABLE = 0 [If 0 = UseFence and UseProximitySensor doesn’t work in IIC then choose 1 = UseProximitySensor]
AVOID_MARGIN = 4 [Unit: m, set obstacle avoidance distance as required.]
PRX1_TYPE = 4 [Rangefinder should be selected for proximity sensor in obstacle avoidance mode]
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 [TFS20-L/TFmini-Plus/TFmini-S 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 details in MP]
AVOID_BEHAVE = 0 [This parameter will define what drone will do upon the encounter of obstacle (stop or slide to avoid the object) 0: Slide; 1: Stop]
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.

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:

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.79.
² c) If TELEM 2 port has been used, TELEM1/TELEM3/GPS2-Port interfaces can also be used, the other settings are same
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:
For TELEM1:
SERIAL1_PROTOCOL = 9 (LiDAR)
SERIAL1_BAUD = 115
For TELEM3:
SERIAL5_PROTOCOL = 9 (LiDAR)
SERIAL5_BAUD = 115
For GPS2:
SERIAL4_PROTOCOL = 9 (LiDAR)
SERIAL4_BAUD = 115
Upon setting of these parameters, the other parameters are same as Mission Planner configuration description of TFS20-L for the purpose of Obstacle Avoidance or Altitude Holding, then click [Write Params] on the right of the software to finish.
Important Note: If you have configured protocol type (SERIALX_PROTCOL: X can be 1, 2, 3, 4 etc.) for more than one UART ports as 9: Rangefinder but you have connected LiDAR to only single UART port then it will give Bad LiDAR Health error. So, you need to configure only those UART ports as 9: Rangefinder to which you will connect LiDAR. In other words, we can say that if the number of serial ports configured as 9: Rangefinder is greater than the number of connected LiDARs then Bad LiDAR Health error will occur.