VL53L0X Time-of-Flight Ranging Sensor

@ScruffR, it works!

I manually added the .cpp and .h files from the Github repo, so I deleted the #define for the Particle Build. So my coe looks like this:

#include "VL53L0X.h"

#if !defined(PARTICLE)
#  include <Wire.h>
#endif


VL53L0X sensor;

void setup()
{
  Serial.begin(9600);
  Wire.begin();

  sensor.init();
  sensor.setTimeout(500);

  // Start continuous back-to-back mode (take readings as
  // fast as possible).  To use continuous timed mode
  // instead, provide a desired inter-measurement period in
  // ms (e.g. sensor.startContinuous(100)).
  sensor.startContinuous();
}

void loop()
{
  Serial.print(sensor.readRangeContinuousMillimeters());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.println();
}

Photon is powered via USB. I’m using the Adafruit sensor and my connections from the sensor to the Photon are as follows:
Sensor pin to Photon pin mapping
VIN - VIN
GND - GND
SDA - D0
SCL - D1

I get reading on the Serial window and they change as I move my hand closer and further away from the sensor. They seem to be similar to what I would get on the UNO.

This is fantastic! Thank you!!

2 Likes