The TFmini I2C sensor module is termed a 'LIDAR' module, but really a fast TOF (time of flight) sensor based on a 850nm IR diode. The more common version of the sensor has a serial (UART) interface, but an I2C-only version exists. The TFmini-I2C module can read a distance between 30 cm to 1200 cm at up to 1000hz (standard: 100 Hz). The range and precision depends somewhat on lighting (shorter maximum range in bright sunlight) and reflectivity of the target (shorter maximum range for dark surfaces).
On a Raspberry Pi, I2c is often the more attractive option communication option, as it allows more sensors to be used in parallel. Unfortunately, as of May 2020, no python library or implementation to read the sensor via python was available online. This repository contains a compact proof of concept that allows reading the sensor values using the smbus2 library in Python, and will hopefully be expanded into a compact library.
The Benewake TFmini product line unfortunately (?) contains several models, with rather different characteristics and communication protocol. The script described here is ONLY intended for the TFmini I2c model (
Only supports UART/serial
I2c enabled out of the box. The python code here is inteded for this model DigiKey Robotshop [Sparkfun(https://www.sparkfun.com/products/14786)
Newer version of the TFmini, supports both serial and I2C. Slightly different measurement range, lower power consumption.
Newer version of the TFmini, supports both serial and I2C. Slightly different measurement range, lower power consumption.
The TFmini-I2C module runs on 5V (with a peak current of 80mA!), so make sure the power supply can support the sensor. THe SCL and SDA lines run on 3.3V logic level, and can therefor be directly interfaced with a Raspberry Pi.
Potential concerns: the sensor might use clock stretching, which is broken on Raspberry Pis (supposedly fixed on the Raspberry Pi 4). Reducing the I2C bus speed, or creating a device tree overlay / software I2C bus should fix any problems.
See here for details:
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/i2c-clock-stretching https://github.com/fivdi/i2c-bus/blob/master/doc/raspberry-pi-software-i2c.md
Use raspi-config to enable i2c, reboot. Install smbus2 via pip3
See here for details:
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c