Datasheet

vl.begin()
Reading Distance
Reading the range/distance is easy, just call readRange()
vl.readRange()
which will return the range in millimeters. If you get 0 or a value over 200 there's likely an error. Either way, before you
trust that reading make sure to ask the sensor if the last reading had an error:
uint8_t status = vl.readRangeStatus()
The status will be 0 on no error, anything else is an error. Here's a simple code chunk that will decode the error!
if ((status >= VL6180X_ERROR_SYSERR_1) && (status <= VL6180X_ERROR_SYSERR_5)) {
Serial.println("System error");
}
else if (status == VL6180X_ERROR_ECEFAIL) {
Serial.println("ECE failure");
}
else if (status == VL6180X_ERROR_NOCONVERGE) {
Serial.println("No convergence");
}
else if (status == VL6180X_ERROR_RANGEIGNORE) {
Serial.println("Ignoring range");
}
else if (status == VL6180X_ERROR_SNR) {
Serial.println("Signal/Noise error");
}
else if (status == VL6180X_ERROR_RAWUFLOW) {
Serial.println("Raw reading underflow");
}
else if (status == VL6180X_ERROR_RAWOFLOW) {
Serial.println("Raw reading overflow");
}
else if (status == VL6180X_ERROR_RANGEUFLOW) {
Serial.println("Range reading underflow");
}
else if (status == VL6180X_ERROR_RANGEOFLOW) {
Serial.println("Range reading overflow");
}
Reading Light / Lux
You can also read a light reading from the sensor with
vl.readLux(GAIN)
which will return a semi-calibrated Lux reading. You can use different Gain settings to get a different range. For better
results at low light, use higher gain. For better results at high light, use a lower gain.
© Adafruit Industries
https://learn.adafruit.com/adafruit-vl6180x-time-of-flight-micro-lidar-
distance-sensor-breakout
Page 15 of 27