Use multiple VL53L1X sensor with I2C multiplexer 8086-X

Hi,

I’m using a I2C multiplexer from 8086-X, because the VL53L1X sensor are not able to change the i2c address x29 permanently.
I after installation I see the following:
pi@raspberrypi:~ i2cdetect -y 7 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: UU -- -- -- -- -- -- -- and pi@raspberrypi:~ i2cdetect -y 8
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – 29 – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: UU – -- – -- – -- –
pi@raspberrypi:~ $

in the examples git there is a line

tof = VL53L1X.VL53L1X(i2c_bus=1, i2c_address=0x29)
tof.open()

so I tried to change it in

tof1 = VL53L1X.VL53L1X(i2c_bus=7, i2c_address=0x29)
tof1.open()

and add

tof2 = VL53L1X.VL53L1X(i2c_bus=8, i2c_address=0x29)
tof2.open()

starting the program I’ve got the error message:

pi@raspberrypi:~/thunderborg $ sudo python dist2.py
distance.py

Display the distance read from the sensor.

Uses the “Short Range” timing budget by default.

Press Ctrl+C to exit.

VL53L1X Start Ranging Address 0x29

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID :
ProductRevisionMajor : 1
ProductRevisionMinor : 15
Traceback (most recent call last):
File “dist2.py”, line 28, in
tof2 = VL53L1X.VL53L1X(i2c_bus=8, i2i_address=0x29)
TypeError: init() got an unexpected keyword argument ‘i2i_address’

I assumed, that using different i2c busses solve the problem, but import VL53L1X seems not to support several i2c busses? Or are there further functions available to bring it up and running.
I saw something like this for python

bus14 = smbus.SMBus(14)
bus15 = smbus.SMBus(15)

this doesn’t fit in the tof-statement tof1 = VL53L1X.VL53L1X(i2c_bus=7, i2c_address=0x29)above?
Any ideas.

Many thx

Peter

got an unexpected keyword argument ‘i2i_address’

i2i_address is a typo, it should be i2c_address.

When you say the 8086-x multiplexer, I take it you mean this one? I’ve not used it and the instructions are quite vague but it implies that it sets up alternate i2c busses, so your idea sounds right:

tof1 = VL53L1X.VL53L1X(i2c_bus=7, i2c_address=0x29)
tof2 = VL53L1X.VL53L1X(i2c_bus=8, i2c_address=0x29)

(By the way, if you’re posting large amounts of code add three back-ticks (`) to the start, and three at the end. The forum will format text inside those as code and make it much easier to read.)

EDIT: Sorry, just realised I misread your post.Deleted a lot of irrelevant stuff.

Hi,

you are right, (beaten with blindness :-(). Now I don’t get errors starting the code. My problem now is, that ToV1 sensor measures nonsense. Mostly very short distances. I already replaced booth sensor, no change in behavior. So the sensor itself should not be the problem.
Will now replace my cabling see if its a physical problem.
This is my code (simple enhenced one of the GIThub examples):

#!/usr/bin/env python

import time
import sys
import signal

import VL53L1X


print("""distance.py

Display the distance read from the sensor.

Uses the "Short Range" timing budget by default.

Press Ctrl+C to exit.

""")

tof1 = VL53L1X.VL53L1X(i2c_bus=7, i2c_address=0x29)
tof1.open()
tof2 = VL53L1X.VL53L1X(i2c_bus=8, i2c_address=0x29)
tof2.open()

tof1.start_ranging(1)  # Start ranging
                      # 0 = Unchanged
                      # 1 = Short Range
                      # 2 = Medium Range
                      # 3 = Long Range

tof2.start_ranging(1)

running = True


def exit_handler(signal, frame):
    global running
    running = False
    tof1.stop_ranging()
    tof2.stop.ranging()
    print()
    sys.exit(0)

while running:
    distance_in_mm1 = tof1.get_distance()
    print("Distance ToF1: {}mm".format(distance_in_mm1))
    time.sleep(5)
    distance_in_mm2 = tof2.get_distance()
    print("Distance ToF2: {}mm".format(distance_in_mm2))
    time.sleep(5)
```
regardly

Peter

Hi,

in the exit handler stop statement there is a mistake, but this has no influence to the sensor, sorry, cut&paste error.

Peter

Hi,

I changed all all possible hardware wiring etc. I got no errors, but the the measurment of the two ToF sensors are most wrong. Massively to short, sometimes ToV2 show the same values as ToV1. I assume that the seperation of the two i2c-busses are not working probably.
Any ideas.

Peter

I honestly have no idea why that would happen. I saw that you opened an issue on Github, hopefully Phil has some suggestions.

Hi,

hope to … no respond from Phil yet :-(

Peter

I get the impression that Phil is very busy these days.

However, I’ve just glanced through the Github page again and noticed someone else has already brought this up:

Multiple VL53L1X on RPi with software I2C not working #33

Phil has an experimental fix which seems to work but hasn’t been folded into the main repository of code yet. You could try uninstalling the sensor module, and reinstalling the fork with the experimental fix and see if that works.

Hi,

my thx for your hints, I bought a TCA9548A i2c mux in the meanwhile, just soldered it :-), but I check your hint and will test it too because the handling with the 8086 one using different smb buses for me is more straight forward …As soon as I have the result, I will post it here.
Many thx again an have a nice evening …

Peter

If I remember right the 8086 mux uses the TCA9548A, and the conversation about this bug suggested it was an issue on the Raspberry Pi’s end, so I’m not sure a different version of the breakout will do you much good.

Hi,

many thx for your hint… I have a question installing the fork version. I think this is the right github side:

Could I simply use the ```
sudo pip install vl53l1x
command on this side below or do I have install the code manually. I tried to use
git@github.com:pimoroni/vl53l1x-python.git
but this doesn’t work on the my raspi zero. Or do I have intall it manually and if yes, is there an instruction how to do this?
Many thx in advance.

Peter

Honestly, I’ve not used branches before but try:

git clone https://github.com/pimoroni/vl53l1x-python.git -b multiple-i2c-bus-support

Then go into the directory and run the install script:

sudo ./install.sh

Hi unfortunatelly, it seems, that it’s not probably installed. Not all neceessary files installed. Now one is requested, which I couldn’t find on the raspi (not matter using find, locate etc.)
I tried several hints from PIP install, but I always get any errors …

Peter

Hi,

I tried to install it in different ways … but I suck by this message:

pi@raspberrypi:~/robi/vl53l1x-python-multiple-i2c-bus-support/examples $ sudo ./dis2.py
Traceback (most recent call last):
File “./dis2.py”, line 7, in
import VL53L1X
File “/home/pi/robi/vl53l1x-python-multiple-i2c-bus-support/examples/VL53L1X.py”, line 80, in
raise OSError(‘Could not find vl53l1x_python.so’)
OSError: Could not find vl53l1x_python.so

It seems a shared Phyton lib, but I can’t find a solution for it.

Peter