LEGO Lidar Part 2: I2C Interface
The LIDAR-Lite V3 has two data outputs: a pulse width modulated (PWM) signals and an I2C signal. In a previous
post (LEGO Lidar) I described working with the PWM output, along with Python code for reading the data. While this technique
worked, I later found that the distance measurements had many centimeters of error. There seems to be a flaw in the Pi/Python
algorithm that I couldn’t solve.
Changing tactics, I decided to try the I2C interface. The results were much better. Figuring out the I2C
implementation on the Raspberry Pi was a battle with several false starts with code on GitHub, problems with 7-bit versus
8-bit addressing, and problems with Python 2 versus Python 3 (things didn’t work in Python 3). In the end the solution
was a few lines of code using the SMBus library. Python code for getting data from the LIDAR-Lite V3 is posted below.
The physical connection of the setup was as described in the LIDAR-Lite V3 documentation, as in page 3 at