Hi,
I would like to ask if you have experienced communication problems with [LiDAR Lite V3HP over I2C bus?
More specifically, I have connected LiDAR to RasperryPi4 via [QWIICBus Kit and I can establish communication with the device.
The code I am using can be found here: https://pypi.org/project/LiDAR-Lite/#files.
Sometimes, however, I get an OSError error: [Errno 121] Remote I/O, which indicates that the device is not connected to the I2C bus.
The function that I use for measurements:
def get_distance(self, expected_measurements_count=40) -> int:
distance_sum = 0
actual_measurements_count = 0
while actual_measurements_count < expected_measurements_count:
self.wait_until_not_busy()
self.write_reg("ACQ_COMMAND", 0x04)
self.wait_until_not_busy()
sensor_status = self.read_reg("STATUS")
if not (sensor_status & (1 << 5)):
continue # Skip measurement, when fault on LiDAR sensor.
if not (sensor_status & (1 << 3)):
continue # Skip measurement, when no peak detected.
actual_measurements_count += 1
distance_sum += self.read_reg2("FULL_DELAY")
time.sleep(0.1)
return int(distance_sum / expected_measurements_count)
The sensor is configured with the following settings:
SIG_COUNT_VAL (register number: 0x02) - 0x1D
THRESHOLD_BYPASS (register number: 0x1C) - 0x00
ACQ_CONFIG_REG (register number: 0x04) - bits 2 and 4 are set to True
REF_COUNT_VAL (register number: 0x12) - 0xFF
Do you have any advice where the problem can be?
Might it be that LiDAR is getting stuck for some reason?
Or it is rather issue of subsystem installed on RP4, which is using I2C Bus to communicate with other devices?](SparkFun QwiicBus Kit - KIT-17250 - SparkFun Electronics)](https://www.sparkfun.com/products/14599)