The Adafruit VL6180X Time of Flight Distance Sensor is a state-of-the-art sensor that utilizes time-of-flight (ToF) measurements of infrared light to determine the distance between the sensor and a target object. This technology allows for precise and accurate distance measurements, making it an ideal choice for a wide range of applications such as robotics, user interface controls, and obstacle detection systems.
Pin Number | Name | Description |
---|---|---|
1 | VIN | Power supply (2.6V to 3.5V) |
2 | GND | Ground connection |
3 | SCL | I2C clock line |
4 | SDA | I2C data line |
5 | GPIO1 | General purpose I/O (optional use) |
6 | GPIO0 | General purpose I/O (optional use) |
#include <Wire.h>
#include <Adafruit_VL6180X.h>
Adafruit_VL6180X vl = Adafruit_VL6180X();
void setup() {
Serial.begin(9600);
// Wait for serial port to connect (necessary for Leonardo only)
while (!Serial) {
delay(1);
}
Serial.println("Adafruit VL6180X test");
if (!vl.begin()) {
Serial.println("Failed to find sensor");
while (1);
}
Serial.println("Sensor found!");
}
void loop() {
float lux = vl.readLux(VL6180X_ALS_GAIN_5);
Serial.print("Lux: "); Serial.println(lux);
uint8_t range = vl.readRange();
uint8_t status = vl.readRangeStatus();
if (status == VL6180X_ERROR_NONE) {
Serial.print("Range: "); Serial.println(range);
}
// Some error occurred, print it out!
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 underflow");
}
else if (status == VL6180X_ERROR_RANGEOFLOW) {
Serial.println("Range overflow");
}
delay(50);
}
Q: What is the maximum range of the sensor? A: The maximum range is up to 200mm, but this can vary based on object reflectivity and environmental conditions.
Q: Can the sensor be used outdoors? A: The sensor can be used outdoors but should be shielded from direct sunlight and extreme weather conditions for accurate measurements.
Q: Is the sensor compatible with 5V systems? A: The sensor operates between 2.6V and 3.5V. A level shifter is required for use with 5V systems.
Q: How can I extend the range of the sensor? A: The range cannot be extended beyond its maximum capability; however, ensuring a clear path and minimal interference can help achieve the best possible range within its limits.