Giter Site home page Giter Site logo

josemotta / vl53l1x-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nagyattila/vl53l1x-python

3.0 2.0 0.0 243 KB

Python library for the VL53L1X Laser Ranger

Home Page: https://shop.pimoroni.com/products/vl53l1x-breakout

Makefile 0.07% C 97.21% C++ 1.66% Shell 0.07% Python 0.98%

vl53l1x-python's Introduction

vl53l1x-python

Revised Python library for the VL53L1X Laser Ranger.

Installing

sudo pip3 install VL53L1X2  

Usage

'''See tests/use_sensor_pypi.py for details.'''

import VL53L1X2

  ...

# I2C addresses for each sensor
ADDRESS_1 = 0x29

# GPIO pins connected to the sensors SHUTX pins
SHUTX_PIN_1 = 16

# Arbitrary sensor id-s, should be unique for each sensor
sensor_id_1 = 1111

GPIO.setwarnings(False)

# Setup GPIO for shutdown pins on
GPIO.setmode(GPIO.BCM)
GPIO.setup(SHUTX_PIN_1, GPIO.OUT)

# Reset sensor
GPIO.output(SHUTX_PIN_1, GPIO.LOW)
time.sleep(0.01)
GPIO.output(SHUTX_PIN_1, GPIO.HIGH)
time.sleep(0.01)

# Init VL53L1X sensor
tof = VL53L1X2.VL53L1X()
tof.open()
tof.add_sensor(sensor_id_1, ADDRESS_1)

tof.start_ranging(sensor_id_1, 1)

for _ in range(0,20):
distance_mm_1 = tof.get_distance(sensor_id_1)
print("Time: {}\tSensor 1: {} mm".format(datetime.utcnow().strftime("%S.%f"), distance_mm_1))
time.sleep(0.001)
tof.stop_ranging(sensor_id_1)

# Clean-up
tof.close()

GPIO.output(SHUTX_PIN_1, GPIO.LOW)

vl53l1x-python's People

Contributors

gadgetoid avatar josemotta avatar nagyattila avatar urbie-mk2 avatar

Stargazers

Jürgen Hahn avatar  avatar Marc Erdmann avatar

Watchers

 avatar James Cloos avatar

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.