Skip to content

Commit 638ff87

Browse files
Add missing files
1 parent a3bb774 commit 638ff87

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

VL53L0X_Mutli_Rpi3_bb.jpg

551 KB
Loading

VL53L0X_TCA9548A_Rpi3_bb.jpg

600 KB
Loading

python/VL53L0X_TCA9548A_example.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/python
2+
3+
# MIT License
4+
#
5+
# Copyright (c) 2017 John Bryan Moore
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
25+
import time
26+
import VL53L0X
27+
28+
# Create a VL53L0X object for device on TCA9548A bus 1
29+
tof1 = VL53L0X.VL53L0X(TCA9548A_Num=1, TCA9548A_Addr=0x70)
30+
# Create a VL53L0X object for device on TCA9548A bus 2
31+
tof2 = VL53L0X.VL53L0X(TCA9548A_Num=2, TCA9548A_Addr=0x70)
32+
33+
# Start ranging on TCA9548A bus 1
34+
tof1.start_ranging(VL53L0X.VL53L0X_BETTER_ACCURACY_MODE)
35+
# Start ranging on TCA9548A bus 2
36+
tof2.start_ranging(VL53L0X.VL53L0X_BETTER_ACCURACY_MODE)
37+
38+
timing = tof1.get_timing()
39+
if (timing < 20000):
40+
timing = 20000
41+
print ("Timing %d ms" % (timing/1000))
42+
43+
for count in range(1,101):
44+
# Get distance from VL53L0X on TCA9548A bus 1
45+
distance = tof1.get_distance()
46+
if (distance > 0):
47+
print ("1: %d mm, %d cm, %d" % (distance, (distance/10), count))
48+
49+
# Get distance from VL53L0X on TCA9548A bus 2
50+
distance = tof2.get_distance()
51+
if (distance > 0):
52+
print ("2: %d mm, %d cm, %d" % (distance, (distance/10), count))
53+
54+
time.sleep(timing/1000000.00)
55+
56+
tof1.stop_ranging()
57+
tof2.stop_ranging()
58+

0 commit comments

Comments
 (0)