# Use multiple VL53L1X sensor with I2C multiplexer 8086-X

**URL:** <https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412>\
**Category:** Support\
**Created:** [July 2, 2020, 3:10pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412 "2020-07-02T15:10:52Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 2, 2020, 3:10pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/1 "2020-07-02T15:10:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shoe](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shoe](https://forums.pimoroni.com/u/Shoe)\
**Post date:** [July 2, 2020, 3:35pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/2 "2020-07-02T15:35:25Z")

</div>

> 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](https://shop.pimoroni.com/products/i2c-multiplexer-phat-for-raspberry-pi)? 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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 2, 2020, 5:00pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/3 "2020-07-02T17:00:57Z")

</div>

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

````auto
#!/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
````

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 2, 2020, 5:16pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/4 "2020-07-02T17:16:22Z")

</div>

Hi,

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

Peter

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 6, 2020, 9:14am UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/5 "2020-07-06T09:14:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shoe](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shoe](https://forums.pimoroni.com/u/Shoe)\
**Post date:** [July 7, 2020, 10:00pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/6 "2020-07-07T22:00:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 8, 2020, 7:22am UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/7 "2020-07-08T07:22:38Z")

</div>

Hi,

hope to … no respond from Phil yet :-(

Peter

---

<div class="post-metadata">

**Author:** ![Shoe](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shoe](https://forums.pimoroni.com/u/Shoe)\
**Post date:** [July 9, 2020, 1:33pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/8 "2020-07-09T13:33:18Z")

</div>

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](https://github.com/pimoroni/vl53l1x-python/issues/33)

Phil has an experimental fix which [seems to work](https://github.com/pimoroni/vl53l1x-python/pull/34) 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](https://github.com/pimoroni/vl53l1x-python/tree/multiple-i2c-bus-support) and see if that works.

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 9, 2020, 2:54pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/9 "2020-07-09T14:54:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shoe](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shoe](https://forums.pimoroni.com/u/Shoe)\
**Post date:** [July 9, 2020, 4:43pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/10 "2020-07-09T16:43:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 10, 2020, 9:41am UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/11 "2020-07-10T09:41:18Z")

</div>

Hi,

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

> **[pimoroni/vl53l1x-python](https://github.com/pimoroni/vl53l1x-python/tree/multiple-i2c-bus-support)**
>
> Python library for the VL53L1X Laser Ranger. Contribute to pimoroni/vl53l1x-python development by creating an account on GitHub.

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](mailto: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

---

<div class="post-metadata">

**Author:** ![Shoe](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shoe](https://forums.pimoroni.com/u/Shoe)\
**Post date:** [July 10, 2020, 10:33am UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/12 "2020-07-10T10:33:29Z")

</div>

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

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

```

Then go into the directory and run the install script:

```auto
sudo ./install.sh

```

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 10, 2020, 12:30pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/13 "2020-07-10T12:30:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pete](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@pete](https://forums.pimoroni.com/u/pete)\
**Post date:** [July 11, 2020, 3:31pm UTC](https://forums.pimoroni.com/t/use-multiple-vl53l1x-sensor-with-i2c-multiplexer-8086-x/14412/14 "2020-07-11T15:31:58Z")

</div>

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
