Search This Blog

Wednesday, January 31, 2018

Raspberry Pi 3 and I2C issues with Pulsed Light v2 -- returning 0 from Lidar-Lite

Lidar-Lite v3 return always zero with raspberry pi 3


Trying to get an Adafruit servo hat to work on Raspberry Pi 3... and a PulsedLight Lidar-Lite v2 unit.

Using I2C for comms - servo hat on 0x40 and Lidar on 0x62.

Tried on Pi2 and the Lidar was fine but the same code returns 0 for distance/velocity on Pi3.

Running   sudo i2cdetect -y 1 returned the correct addresses (0x62 for the Lidar)
 (if I2C tools not installed then first  run these commands)
sudo apt-get install python-smbus
sudo apt-get install i2c-tools

Issue is that the latest Raspbian kernel is auto restarting the I2C and the LidarLite unit doesn't like this.. hence python code returns 0 for distance and 0 for speed - even though the I2C detect has demonstrated the device is connected correctly.


Solution:

Bump the kernel back to an earlier version - I'm using 4.4.38 which works.

https://github.com/Hexxeh/rpi-firmware/tree/af9cb14d5053f89857225bd18d1df59a089c171e  

You copy the hex code (in this case af9cb14d5053f89857225bd18d1df59a089c171e)  and run it like this:

If rpi-update not installed first run this:       sudo apt-get install rpi-update

sudo rpi-update af9cb14d5053f89857225bd18d1df59a089c171e 

... it'll take a while then ask you to reboot your Pi. If you get an error message then try running the command again (possibly a few times) as it could be a missing packet of data from the network corrupting the file - this happened to me twice - 3rd time it worked fine. 


Thanks to Isa Hatipoglu for the information on rpi-update:

https://isahatipoglu.com/2015/09/29/how-to-upgrade-or-downgrade-raspberrypis-kernel-servoblaster-problem-raspberry-pi2/


No comments: