Open santosh9sanjeev opened 2 years ago
Seeing the same issue on a RPI4
Using this code will give 0 as output, and also other github repo like the Adafruit Blinka will cause another error of System Failure.
While working on LIDAR Lite V3 with RaspberryPi, I had RaspberryPi 3B+ with Raspian Stretch OS. The code in the above links do not work with this RapsberryPi model with this kernel version. It only works with Pixel and Raspian Jessie.
https://en.wikipedia.org/wiki/Raspberry_Pi_OS
This link mentions all the OS and the corresponding RaspberryPi model it can work with.
The I2C communication of LIDAR Lite V3 with RaspberryPi is very complicated. This is because It seems a recent patch forces repeated starts under I2C, which the LIDAR-Lite does not support.
Once the kernel is upgraded, this problem starts to arise.
Hence one option could be to downgrade the kernel version to 4.4.38 or the other could be to install the older kernel version from start.
This could cause problems to other applications.
The whole problem with few solutions is explained in detail in this https://www.robotshop.com/community/forum/t/lidar-lite-v3-return-always-zero-with-raspberry-pi-3/27656
To solve this problem and to work with existing, we further researched and came with a solution to solve the repeating problem in newer versions of Raspian OS or kernel.
The connections can be made similar to that of Arduino with Vcc and Gnd. SDA and SCL are GPIO 2 and GPIO3 in RapsberryPi 3B+.
For further information on connection with Pi can be seen in this https://mobiusstripblog.wordpress.com/2016/12/26/first-blog-post/
Python code for LIDAR Lite V3 with RaspberryPi:
import sys
import smbus
import time
bus = smbus.SMBus(1)
LIDAR_ADR=0x62
def measure():
bus.write_byte_data(LIDAR_ADR,0,4)
bus.write_byte(LIDAR_ADR, 1)
while bus.read_byte(LIDAR_ADR) & 1 != 0:
pass
bus.write_byte(LIDAR_ADR, 0xf)
d=bus.read_byte(LIDAR_ADR)<<8
bus.write_byte(LIDAR_ADR, 0x10)
d|=bus.read_byte(LIDAR_ADR)
return d
while True:
t0=time.time()
d=measure()
t1=time.time()
print "%3d %4d" % ((t1-t0)*1000,d)
This code works almost perfectly with our OS version and RapberryPi model.
I never got any of the python libraries working for RPI4 on Debian Bullseye (64bit). I did however find another solution that does work, https://github.com/garmin/LIDARLite_RaspberryPi_Library if you go to this repo and compile the binary (C++) you can then call that binary from within any script (Python in my case). Less than ideal but the end state works great.
Hi Did you guys find a solution? I too am facing the same issue of getting 0 as a value, when using raspberryPi 3B for distance and velocity...