adafruit / Adafruit_CircuitPython_VL53L4CD

CircuitPython helper library for the VL53L4CD time of flight distance sensor.
MIT License
3 stars 6 forks source link

TimeoutError running vl53l4cd_simpletest.py #1

Closed ChuckVanzant closed 2 years ago

ChuckVanzant commented 2 years ago

Encountering TimeoutError while running vl53l4cd_simpletest.py The environment being used is listed in the code below.

On the aside, the I2C address is 0x29 (41), it's even printed on the Adafruit device, but the technical specification indicates it's I2C address is 0x52. On arduino, 0x52 works, but its driver does a one bit shift right converting 0x52 to 0x29 before using. I don't understand the reasoning. The VL6180X proximity sensor also has address of 0x29.

Adafruit CircuitPython 7.2.3 on 2022-03-16; Adafruit QT Py ESP32S2 with ESP32S2
>>>
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 18, in <module>
  File "adafruit_vl53l4cd.py", line 79, in __init__
  File "adafruit_vl53l4cd.py", line 179, in _sensor_init
  File "adafruit_vl53l4cd.py", line 378, in _start_vhv
  File "adafruit_vl53l4cd.py", line 340, in start_ranging
TimeoutError: Time out waiting for data ready.

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Device

caternuson commented 2 years ago

Also don't know why STM shows 0x52 for the address and then does the shift internally. But for CircuitPython usage, use the same address that would show up in a scan:

Adafruit CircuitPython 7.2.3 on 2022-03-16; Adafruit QT Py ESP32S2 with ESP32S2
>>> import board
>>> i2c = board.I2C()
>>> i2c.try_lock()
True
>>> i2c.scan()
[41]
>>> hex(41)
'0x29'
>>>  

The library uses 0x29 as the default, so generally do not need to specify it.

How do you have the VL53L4CD connected to the Qt Py? Don't forget the I2C on the header pins is different than I2C on the STEMMA QT connector. To use the library example as is, you'd want to use the header connectors.

Just tested that and it worked OK here:

Adafruit CircuitPython 7.2.3 on 2022-03-16; Adafruit QT Py ESP32S2 with ESP32S2
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
VL53L14CD Simple Test.
--------------------
Model ID: 0xEB
Module Type: 0xAA
Timing Budget: 199
Inter-Measurement: 0
--------------------
Distance: 36.5 cm
Distance: 12.4 cm
Distance: 19.5 cm
Distance: 18.3 cm
Distance: 32.8 cm
ChuckVanzant commented 2 years ago

OK, I must have had a bad connection. I was using the STEMMA QT connectors of the sensor device connected to the I2C bus connected to the breakout pins and not the STEMMA QT connector on the QtPy. I disconnected/reconnected everything and I too see it working when connected to either I2C bus (with the appropriate code changed). Thanks, and sorry for taking your time to validate that it works.