Time of Flight


The Time of Flight sensor uses an invisible laser to measure distance with millimeter resolution.

Tested devices:

Configuration

To use the VL53L1X sensor in your installation, add to your configuration.yaml:

# Example configuration.yaml entry
sensor:
  - platform: tof

Configuration Variables

name

(string)(Optional)

Name of the sensor.

Default value:

VL53L1X

i2c_bus

(integer)(Optional)

I2c bus used.

Default value:

1, for Raspberry Pi 2 and 3.

i2c_address

(string)(Optional)

I2c address of the sensor.

Default value:

0x29

xshut

(integer)(Optional)

GPIO port used to reset device.

Default value:

16

Example

The distance is measured in millimeters, according to the VL53L1X specifications.

# Example of customized configuration.yaml entry
sensor:
  - platform: tof
    name: ToF sensor
    i2c_address: 0x29
    xshut: 16

Several devices may be attached and a GPIO port from Raspberry Pi is used for reset. XSHUT signal is generated pulsing LOW at initialization and after that, it is kept HIGH all time. This version uses VL53L1X long-range mode that may reach up to 4 meters.

Directions for installing i2c on Raspberry Pi

Enable the I2c interface with the Raspberry Pi configuration utility:

# pi user environment: Enable i2c interface
sudo raspi-config

Select Interfacing options->I2C choose <Yes> and hit Enter, then go to Finish and you’ll be prompted to reboot.

Install dependencies for use the smbus-cffi module and enable your homeassistant user to join the i2c group:

# pi user environment: Install i2c dependencies and utilities
sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev

# pi user environment: Add homeassistant user to the i2c group
sudo addgroup homeassistant i2c

# pi user environment: Reboot Raspberry Pi to apply changes
sudo reboot

Check the i2c address of the sensor

After installing i2c-tools, a new utility is available to scan the addresses of the connected sensors:

/usr/sbin/i2cdetect -y 1

It will output a table like this:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- 29 -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

So you can see the sensor address what you are looking for is 0x29 (there are more i2c sensors in this Raspberry Pi).