From the datasheet: "The VL53L1X is a state-of-the-art, Time-of-Flight (ToF), laser-ranging sensor, enhancing the ST FlightSenseâ„¢ product family. It is the fastest miniature ToF sensor on the market with accurate ranging up to 4 m and fast ranging frequency up to 50 Hz."
The wiring is the same than any other I2C module. Most of the already available
modules also have pins for shutdown (SHUT
) and an interrupt (GPIO1
).
You need to wire up as follows:
Pin | Name | Espruino |
---|---|---|
1 | GPIO1 | N/C |
2 | SCL | I2C SCL (B6) |
3 | XSHUT | 3.3v |
4 | SDA | I2C SDA (B7) |
5 | VDD | 3.3v |
6 | GND | GND |
You can use the VL53L1X (About Modules) module with the VL53L1X as follows:
I2C2.setup({sda:B3,scl:B10});
digitalWrite(B4,1); // set XSDN -> turn the sensor on
var laser;
setTimeout(function() {
laser = require("VL53L1X").connect(I2C2);
// make one reading
console.log(laser.performSingleMeasurement().distance+" mm");
// or repeatedly measure
setInterval(function() {
// sets LED brightness depending on distance
var dist = laser.performSingleMeasurement().distance;
analogWrite(LED1, (300-dist)/300, { soft:true, freq:200 });
}, 50);
});
XSHUT isn't needed and can be connected to 3.3v. It is used for powering the device on and off (and you must leave a 2ms delay between powering the VL53L1X on and using it).
The API of the module is partially compatible with the VL53L0X module. Just
replace require("VL53L0X")
by require("VL53L1X")
in your code
and it should work. The function performSingleMeasurement
is
provided as an alias of readMeasurement
in order to keep the
backward compatibility.
VL53L1X.prototype.r16 = function (reg) { ... }
VL53L1X.prototype.r = function (reg, n) { ... }
VL53L1X.prototype.r8 = function (reg) { ... }
VL53L1X.prototype.w8 = function (reg, value) { ... }
VL53L1X.prototype.w16 = function (reg, value) { ... }
VL53L1X.prototype.w32 = function (reg, value) { ... }
VL53L1X.prototype.delayMicroseconds = function (us) { ... }
VL53L1X.prototype.init = function (options) { ... }
VL53L1X.prototype.calcMacroPeriod = function (vcsel_period) { ... }
VL53L1X.prototype.timeoutMicrosecondsToMclks = function (timeout_us, macro_period_us) { ... }
VL53L1X.prototype.encodeTimeout = function (timeout_mclks) { ... }
VL53L1X.prototype.setMeasurementTimingBudget = function (timingBudget) { ... }
/* Set the distance mode of the sensor
* @param {string} mode any of `short`, `medium` or `long` (default)
*/
VL53L1X.prototype.setDistanceMode = function (mode) { ... }
/* Start continuous ranging measurements, with the given inter-measurement
* @param {number} interMeasurementPeriod time between measurements in ms
*/
VL53L1X.prototype.startContinuous = function (interMeasurementPeriod) { ... }
/* Stop continuous measurements
*/
VL53L1X.prototype.stopContinuous = function () { ... }
VL53L1X.prototype.setupManualCalibration = function () { ... }
VL53L1X.prototype.updateDSS = function () { ... }
/* Read the distance in mm
* Note: This function hast a better performance than `readMeasurement().distance`.
* @returns {number} distance in mm
*/
VL53L1X.prototype.getDistance = function () { ... }
VL53L1X.prototype.getRangingData = function () { ... }
VL53L1X.prototype.readResults = function () { ... }
VL53L1X.prototype.getMeasurementTimingBudget = function () { ... }
VL53L1X.prototype.timeoutMclksToMicroseconds = function (timeout_mclks, macro_period_us) { ... }
VL53L1X.prototype.decodeTimeout = function (reg_val) { ... }
VL53L1X.prototype.read = function () { ... }
/* Read a measurement.
* Note: The module should be continuously reading (by default)
* @returns {Object} Object with the properties `status`, `distance`,
* `signalRate`, `ambientRate`, `effectiveSpadRtnCount`
*
* @example
* {
* "status": "RangeValid",
* "distance": 1821,
* "signalRate": 6.96875,
* "ambientRate": 0.171875,
* "effectiveSpadRtnCount": 215.5625
* }
*/
VL53L1X.prototype.readMeasurement = function () { ... }
VL53L1X.prototype.readDistance = function () { ... }
// Export function
exports.connect = function (i2c, options) { ... }
The cheapest way to get a VL53L1X at the moment seems to be from eBay
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.