Skip to content
Raspberry Pi library for the VL6180 i2c distance sensor
Branch: master
Clone or download
Pull request Compare This branch is 11 commits ahead, 6 commits behind leachj:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This library provides convenient access to distance measurements from the VL6180 i2c time of flight distance sensor on the raspberry pi. The sensor board I have been using is from SparkFun

Although it is designed for the Pi it is likely to work with most linux systems.

Code Example

The library is very simple to use, here is the basic code for getting distance measurements

#include <vl6180_pi/vl6180_pi.h>


vl6180 handle = vl6180_initialise(1);

int distance = get_distance(handle);

The integer passed into initialise is the i2c device number /dev/i2c-n

The distance returned will be in mm


Whilst there as already an existing Arduino library for the sensor there was nothing to allow it to work with the Pi. This project solves that.


To install the library download the code and then run

sudo make install

If you do not have the i2c device on your pi you need to enable i2c. This can be done by following the instructions here:

You may also need to install i2c-tools libi2c-dev

sudo apt-get install i2c-tools libi2c-dev


To test the basic functionality download the code and then run

make check


Contributions are welcome. This only implements a very simple usage of the VL6180, it has many other functions which could be added to this library.


This software is made available under the MIT license

You can’t perform that action at this time.