Coder Social home page Coder Social logo

vl6180_pi's Introduction

Synopsis

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 https://www.sparkfun.com/products/12785

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

Code Examples

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

#include <vl6180_pi/vl6180_pi.h>

...

vl6180 handle = vl6180_initialise(1);

float ambient_light = get_ambient_light(handle, GAIN);

The ambient light returned will be in lx.

GAIN - predefined value from vl6180_pi.h. For factory calibrated sensor GAIN_1 is appropriate.

Motivation

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.

Installation

To install the library download the code and then run

make
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: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

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

sudo apt-get install i2c-tools libi2c-dev

Tests

To test the basic functionality download the code and then run

make check

Contributors

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.

License

This software is made available under the MIT license

vl6180_pi's People

Contributors

leachj avatar ybalrid avatar jdoubleu avatar tomekmalek avatar

Stargazers

NishimiyaShouko avatar Aniel Shri avatar Will Smith avatar Pedro Henrique S. Perrusi avatar Akira Kuroiwa avatar Andrew Zeller avatar Marco Estrella avatar James Restall avatar Zuo Rongzhi avatar Malefs avatar Marco avatar Jimmy Baker avatar  avatar Rachel Yang avatar  avatar Luka Vida avatar  avatar  avatar Alexei avatar E R avatar Macpaul Lin avatar Keith's Pi Tutorials avatar

Watchers

Macpaul Lin avatar James Cloos avatar E R avatar  avatar yutakau avatar Keith's Pi Tutorials avatar

vl6180_pi's Issues

Initial registers not set under some circumstances

In the vl6180 vl6180_initialise function if register 0x016 doesn't return a 1 the recommended registers don't get set. I have two of these sensors and neither ever seems to return a 1. Oddly enough it seems measure distance just fine without them getting set.

Missing -fPIC

Some newer compilers complain about missing -fPIC in the source file compile. Also, the typedef is outside of the C++ check, so if you build this from C++, it won't work. Patch attached as a .txt file.

build-fixes.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.