TFMini - Micro LiDAR Module Hookup Guide

Pages
Contributors: bboyho
Favorited Favorite 0

Introduction

The TFMini is a ToF (Time of Flight) LiDAR sensor capable of measuring the distance to an object as close as 30 cm and as far as 12 meters! The TFMini allows you to integrate LiDAR into applications traditionally reserved for smaller sensors such as the SHARP GP-series infrared rangefinders. In this tutorial, you will learn how to connect to the TFMini using an Arduino microcontroller.

TFMini - Micro LiDAR Module

SEN-14588
$39.95

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

SparkFun RedBoard - Programmed with Arduino

DEV-13975
$19.95
27
SparkFun Logic Level Converter - Bi-Directional

BOB-12009
$2.95
85
Breadboard - Self-Adhesive (White)

PRT-12002
$4.95
35
Break Away Headers - Straight

PRT-00116
$1.50
20
SparkFun USB Mini-B Cable - 6 Foot

CAB-11301
$3.95
2
Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)

PRT-11026
$1.95
20

Tools

You will need a soldering iron, solder, and general soldering accessories.

Solder Lead Free - 100-gram Spool

TOL-09325
$7.95
7
Weller WLC100 Soldering Station

TOL-14228
$44.95

Suggested Reading

If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.

Serial Communication

Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!

Installing an Arduino Library

How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

Hardware Overview

The sensor works by sending a modulated near-infrared light out. The light that is reflected from the object returns to the sensor’s receiver. The distance between the two can be converted using the sensor by calculating the time and phase difference. The distance measured may vary depending on the environment and the reflectivity of object.

Input Power

According to the datasheet (pg 4) the input voltage is between 4.5V-6V. In this tutorial, we will be applying 5V to the sensor.

Logic Levels

While the sensor can be powered at 5V, the serial UART pins are only 3.3V logic. Make sure to use a logic level converter when reading the sensor with a 5V microcontroller.

Pinout

There is a marking next to the polarized connector to indicate the polarity as “J1” as indicated in the image below. This is useful when referencing sensor’s pinout.

TFMini  Pinout

Pin Number TFMini Pinout Wire Color
1 UART_TX (3.3V TTL) Green
2 UART_RX (3.3V TTL) White
3 5V Red
4 GND Black

Hardware Hookup

For the purpose of this tutorial, we will be using a 5V Arduino. A microcontroller and logic level converter is required in order to read the sensor values through the serial UART pins. Make sure to solder the male header pins to the converter before making the connections on a breadboard. Begin by making a connection from an Arduino’s high side and following the connection to the TFMini. Then continue to make the rest of the connections by following the hookup table listed below.

5V Arduino w/ Atmega328P Logic Level Converter (High Side) Logic Level Converter (Low Side) TFMini
Software Serial RX
(Pin 10)
HV1 LV1 UART_TX (3.3V TTL)
(Pin 1)
Software Serial TX
(Pin 11)
HV4 LV4 UART_RX (3.3V TTL)
(Pin 2)
3.3V LV
5V HV Vin (4.5V-6V)
(Pin 3)
GND GND GND GND
(Pin 4)

Once we are finished, it should look like the image below.

Connecting the TFMini with Arduino

Example Code

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

Download and install Peter Jansen’s Arduino TFMini library using the library manager. You can also manually install it from the GitHub Repository by downloading the library from the button below.

Download TFMini Arduino Library (ZIP)

Grab a mini-USB cable and connect the Arduino to your computer. Upload the BasicReading.ino that was included in the library’s examples to your Arduino. Make sure to use the correct COM port and board selection.

Once uploaded, try moving an object in front of the sensor to test. In the example below, a third hand was used to hold the TFMini when detecting an object at a certain distance away from the sensor. Since the sensor is not able to detect an object when less than 11.8 inches (or 30cm = 0.3m) away, the object under test was placed at 20 inches and 30 inches.

TFMini Reading an Object at 20 Inches TFMini Reading an Object at 30 Inches

Opening the serial monitor at 115200, you may see an output similar to the values printed below. Using a yard stick, the values responded as expected when moving an object between 20 inches and 30 inches.

Initializing...
54 cm      sigstr: 457
54 cm      sigstr: 456
54 cm      sigstr: 456
54 cm      sigstr: 456
55 cm      sigstr: 456
54 cm      sigstr: 456
54 cm      sigstr: 456
54 cm      sigstr: 457
67 cm      sigstr: 340
70 cm      sigstr: 315
71 cm      sigstr: 315
77 cm      sigstr: 283
77 cm      sigstr: 283
77 cm      sigstr: 283
77 cm      sigstr: 283
77 cm      sigstr: 284
78 cm      sigstr: 281
78 cm      sigstr: 281
78 cm      sigstr: 282
78 cm      sigstr: 282
78 cm      sigstr: 283

Resources and Going Further

Now that you’ve successfully got your TFMini up and running, it’s time to incorporate it into your own project! For more on the TFMini, check out the links below:

Need some inspiration for your next project? Check out some of these related tutorials:

VL6180 Hookup Guide

Get started with your VL6180 based sensor or the VL6180 breakout board.

Building an Autonomous Vehicle: The Batmobile

Documenting a six-month project to race autonomous Power Wheels at the SparkFun Autonomous Vehicle Competition (AVC) in 2016.
New!

LIDAR-Lite v3 Hookup Guide

A tutorial for connecting the Garmin LIDAR-Lite v3 or the LIDAR-Lite v3HP to an Arduino to measure distance.

Qwiic Distance Sensor (RFD77402) Hookup Guide

The RFD77402 uses an infrared VCSEL (Vertical Cavity Surface Emitting Laser) TOF (Time of Flight) module capable of millimeter precision distance readings up to 2 meters. It’s also part of SparkFun’s Qwiic system, so you won’t have to do any soldering to figure out how far away things are.