TFMini - Micro LiDAR Module Hookup Guide

Pages
Contributors: bboyho
Favorited Favorite 2

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.

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