https://github.com/olemchls/nerves_vl53l0x
A library to interface with the VL53L0X laser time-of-flight sensor
https://github.com/olemchls/nerves_vl53l0x
elixir nerves sensor
Last synced: 7 months ago
JSON representation
A library to interface with the VL53L0X laser time-of-flight sensor
- Host: GitHub
- URL: https://github.com/olemchls/nerves_vl53l0x
- Owner: OleMchls
- Created: 2021-03-28T21:45:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-30T20:34:31.000Z (over 4 years ago)
- Last Synced: 2025-03-08T19:01:49.825Z (8 months ago)
- Topics: elixir, nerves, sensor
- Language: Elixir
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nerves_VL53L0X
A library to interface with the VL53L0X laser time-of-flight sensor.
[](https://www.adafruit.com/product/3317)
This is the 'big sister' of the VL6180X ToF sensor, and can handle about 50mm to 1200mm of range distance. If you need a smaller/closer range, check out the VL6180X which can measure 5mm to 200mm and also contains a light sensor.
## Installation
The package can be installed by adding `nerves_vl53l0x` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:nerves_vl53l0x, "~> 0.1.0"}
]
end
```Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc). Once published, the docs can be found at [https://hexdocs.pm/nerves_vl53l0x](https://hexdocs.pm/nerves_vl53l0x).
## Usage
```elixir
# Open the I2C bus, optionally you can also bas the device address
{:ok, ref} = VL53L0X.open("i2c-1")
# => {:ok, %VL53L0X{bus: #Reference<0.1403664192.269090823.21917>, device: 41, stop_variable: nil}}# Initialize the sensor
{:ok, ref} = VL53L0X.init(ref)
# => {:ok, %VL53L0X{bus: #Reference<0.1403664192.269090823.21917>, device: 41, stop_variable: 0x29}}# Optionally, the VL53L0X supports custom measuring time budgeting,
# the more time you allow the sensor for a measurement
# the more accurate the result will be.
# For example a higher speed but less accurate timing budget of 20ms:
VL53L0X.set_measurement_timing_budget(ref, 20_000)
# Or a slower but more accurate timing budget of 200ms:
VL53L0X.set_measurement_timing_budget(ref, 200_000)
# The default timing budget is 33ms, a good compromise of speed and accuracy.# Read distance
distance_in_mm = VL53L0X.range(ref)
# => 147
```## Acknowledgements
This library is basically a port of the [Adafruit python driver](https://github.com/adafruit/Adafruit_CircuitPython_VL53L0X) :heart: which in turn is based on the amazing work of [@pololu](https://github.com/pololu) on the arduino library [vl53l0x-arduino](https://github.com/pololu/vl53l0x-arduino).