I have looked at many examples trying to get the VL53L1X with a Pico using the code shown with circuit python examples. I continue to encounter errors win the initial part of the code:
# Simple demo of the VL53L1X distance sensor.
# Will print the sensed range/distance every second.
import time
import board
import adafruit_vl53l1x
i2c = board.I2C()
vl53 = adafruit_vl53l1x.VL53L1X(i2c)
One example referred to the fact that the line "i2c = board.I2C()" would have to be changed for the Pico, but all attempts have failed. If I use busio instead of boards it faults at the next line.
Any help would be highly appreciated
vl53l1x with raspberry pi pico in cirquit python
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- arucano
- Posts: 2
- Joined: Fri Jan 21, 2022 12:45 am
- tannewt
- Posts: 3304
- Joined: Thu Oct 06, 2016 8:48 pm
Re: vl53l1x with raspberry pi pico in cirquit python
There are instructions on initializing I2C on the Pico here: https://learn.adafruit.com/getting-star ... on/pinouts
If you still have issues, please post the exact code you have and the error message that goes with it.
If you still have issues, please post the exact code you have and the error message that goes with it.
- arucano
- Posts: 2
- Joined: Fri Jan 21, 2022 12:45 am
Re: vl53l1x with raspberry pi pico in cirquit python
I used the following code, cobbled up from some examples. I am able to detect the address of the VL53L1X but hit a roadblock at line 16. Below are the code and error messages.
CODE:
ERROR MESSAGE
I2C addresses found: ['0x29']
Traceback (most recent call last):
File "<stdin>", line 16, in <module>
TypeError: 'scl' argument required
CODE:
Code: Select all
import busio
import board
import adafruit_vl53l1x
import time
i2c = busio.I2C(board.GP1, board.GP0)
# added for detection
# Lock the I2C device before we try to scan
while not i2c.try_lock():
pass
# Print the addresses found once
print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()])
# Unlock I2C now that we're done scanning.
i2c.unlock()
#
vl53 = adafruit_vl53l1x.VL53L1X(busio.I2C())
while True:
print("range: mm ", vl53.read())
time.sleep_ms(50)
I2C addresses found: ['0x29']
Traceback (most recent call last):
File "<stdin>", line 16, in <module>
TypeError: 'scl' argument required
Last edited by tannewt on Mon Jan 24, 2022 6:34 pm, edited 1 time in total.
Reason: added code block
Reason: added code block
- tannewt
- Posts: 3304
- Joined: Thu Oct 06, 2016 8:48 pm
Re: vl53l1x with raspberry pi pico in cirquit python
Code: Select all
vl53 = adafruit_vl53l1x.VL53L1X(busio.I2C())
Code: Select all
vl53 = adafruit_vl53l1x.VL53L1X(i2c)
Please be positive and constructive with your questions and comments.