Giter Site home page Giter Site logo

tfmini-i2c-python's Introduction

Reading the Benewake TFmini-I2C LIDAR Module in Python

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 (

TFmini

Only supports UART/serial

TFmini I2C

I2c enabled out of the box. The python code here is inteded for this model DigiKey Robotshop [Sparkfun(https://www.sparkfun.com/products/14786)

TFmini-S

Newer version of the TFmini, supports both serial and I2C. Slightly different measurement range, lower power consumption.

TFmini plus

Newer version of the TFmini, supports both serial and I2C. Slightly different measurement range, lower power consumption.

Hardware setup

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

Software setup

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

tfmini-i2c-python's People

Contributors

madewhatnow avatar wschmied avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.