Reputation: 1
I'm using a Cytron Maker Pi RP2040 Micropython
The sensors are VL53L1X from Adafruit
Sensor0 is connected to (SDA1)-GPIO26, (SCL1)-GPIO27 Sensor1 is connected to (SDA0)-GPIO16, (SCL0)-GPIO17
I found this in Github and I'm using the same library as them. The library in question
I am fairly new to this but I've managed to make one of the sensor work at a time. But whenever I try to use 2 the second one gives me OSError: [Errno 5] EIO I made sure both are in different channels.
This is my set of funtions
class distance:
def true_front(channel):
global front_distance
i2c = I2C(channel)
distance = VL53L1X(i2c)
front_distance = distance.read()
print(str(front_distance) + "mm")
sleep_ms(50)
def true_rear(channel):
global rear_distance
i2c = I2C(channel)
distance = VL53L1X(i2c)
rear_distance = distance.read()
print(str(rear_distance) + "mm")
sleep_ms(50)
And this is how I executed them
while True:
distance.true_front(0)
sleep(1)
distance.true_rear(1)
I looked into the library to see if there was a way to redo the handshake process everytime I call the funtions, but since this is still new to me I didn't manage to spot the solution.
Upvotes: 0
Views: 132