VL53L0X

Library for controlling VL53L0X distance sensor

Install command

curl -o src/libs/VL53L0X.ts https://c2coder.github.io/Jaculus-libraries/data/VL53L0X/VL53L0X.ts

Basic usage

import { I2C1 } from "i2c";
import { VL53L0X } from "./libs/VL53L0X.js"
import { stdout } from "stdio";

I2C1.setup({sda: 17, scl: 9, bitrate: 400000});
const vl = new VL53L0X(I2C1);

async function main() {
    while (true) {
        const m = await vl.read();
        console.log("Distance: " + m.distance + " mm  \tSignal: " + m.signalRate + "\tAmb: " + m.ambientRate + "\tSPAD: " + m.effectiveSpadRtnCount);
    }
}

main().catch(console.error);

Source code: