SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By 310weber
#179950
Hi all - since this is my first post on this forum I'll introduce myself first, then pose my question. I'm a mechanical engineer and electronics hobbyist from Ontario, Canada. I've used many different dev. platforms over the years but have spent the most time using Atmel microcontrollers and Arduino. I've recently taken up Python programming on the Raspberry Pi.

I've been trying to get the ST VL6180X ToF distance sensor working on Raspberry Pi for a robotics project I've been building with my kids. I started this before the Sparkfun board was available so I'm actually using the ST Explorer board (http://www.st.com/web/catalog/tools/FM1 ... 7/PF260896). This board uses the same ST part and similar 2.8V power supply and level shifter setup as the Sparkfun part so I would expect behaviour to be the same.

I ported the Sparkfun Arduino library to Python and it seems to be functioning for the most part. I can connect to the sensor and read the part number and revision, etc. but when I try to setup for ranging and ALS readings it always returns zero mm distance and zero lux. I can't figure out what's going wrong.

I've posted the code here (https://bitbucket.org/310weber/st_vl6180x). If anyone is interested in getting this sensor going on Raspberry Pi, this should be a good starting point. I'd appreciate any feedback anyone can offer.

Thanks.
By 310weber
#179984
A little more research this weekend and I found the problem. The ST VL6180X uses 16 bit register addresses and the Adafruit I2C library I was using (which calls smbus) was only sending 8 bit addresses even though I was passing in 16 bit values. I rewrote the code to remove references to the Adafruit library and now call smbus directly in a way that sends the full 16 bit register addresses. Some quick testing this evening shows that it is now working as expected.

The updated code is on Bitbucket (https://bitbucket.org/310weber/st_vl6180x). Hopefully someone finds this info helpful.

Cheers.