3.2 KiB

title description ha_category ha_release ha_iot_class ha_domain ha_platforms
Time of Flight Instructions on how to integrate a VL53L1X ToF sensor into Home Assistant.
DIY
Sensor
0.90 Local Polling tof
sensor

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 %} name: description: Name of the sensor. required: false default: VL53L1X type: string i2c_bus: description: I2c bus used. required: false default: 1, for Raspberry Pi 2 and 3. type: integer i2c_address: description: I2c address of the sensor. required: false default: "0x29" type: string xshut: description: GPIO port used to reset device. required: false default: 16 type: integer {% endconfiguration %}

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).