Table of Contents

LamaPLC: VL6180X STMicroelectronics Time-of-Flight (ToF) sensor with I²C communication

VL6180X The VL6180X is a small optical sensor from STMicroelectronics that uses Time-of-Flight (ToF) technology to measure distance and ambient light. Unlike conventional IR sensors, it determines absolute distance regardless of the object's color or reflectivity.

Laser distance sensors:
Laser sensors, similar to IR sensors, use triangulation to measure distance. The sensor emits a laser beam that reflects off the measured surface and passes through a lens onto the CCD or CMOS sensor. As the surface moves closer or farther away, the projected point shifts position on the sensor. The electronics analyze this shift to calculate the distance.

If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.

Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.

2026/02/14 23:38

VL6180X Pinout

Pin NameTypeDescription
VINPowerMain power supply input (typically 2.7V to 5.5V).
GNDPowerCommon ground for power and logic.
SCLI²C ClockI²C serial clock line. Logic level matches VIN.
SDAI²C DataI²C serial data line. Logic level matches VIN.
GPIO0 / SHDNControlShutdown/Chip Enable. Pulling this pin LOW puts the sensor into standby mode. It is usually pulled HIGH by default.

The VL6180X operates natively at 2.8V. Most breakout modules (such as those from Adafruit or Pololu) include a voltage regulator and level shifters, making them compatible with 3.3V or 5V Arduinos.

Arduino code

To interface the STMicroelectronics VL6180X (a 3-in-1 Time-of-Flight sensor for distance and ambient light) with an Arduino, the Pololu VL6180X library is a popular, lightweight choice.

#include <Wire.h>
#include <VL6180X.h>
 
VL6180X sensor;
 
void setup() {
  Serial.begin(9600);
  Wire.begin();
 
  sensor.init();
  sensor.configureDefault(); // Sets recommended settings for standard operation
 
  // Set a 500ms timeout for I2C communication
  sensor.setTimeout(500);
}
 
void loop() {
  // Read distance in millimeters (typically accurate up to 100mm, max 200mm)
  uint8_t range = sensor.readRangeSingleMillimeters();
 
  // Read ambient light in Lux
  float lux = sensor.readAmbientLightSingle();
 
  Serial.print("Range: ");
  Serial.print(range);
  Serial.print(" mm | Ambient Light: ");
  Serial.print(lux);
  Serial.println(" lux");
 
  if (sensor.timeoutOccurred()) {
    Serial.println(" !!! TIMEOUT !!!");
  }
 
  delay(500);
}

I²C topics on lamaPLC

PageDateTags
2026/04/23 21:51, , , , , , ,
2025/09/23 21:25, , , , , ,
2026/03/22 03:14, , , , , , ,
2026/04/23 21:52, , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/03/28 23:50, , , , , , ,
2026/04/12 00:34, , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , ,
2026/03/22 00:08, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2025/05/31 23:32, , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2025/11/22 00:07, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
2023/07/01 17:29, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
2026/03/22 01:44, , , , , , , , ,
2026/04/23 21:52, , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , , , ,
2026/04/23 21:51, , , ,
2026/04/23 21:52, , , , , , , , , , , , , , , , , , , , , , , , ,
2026/04/11 19:54, , , , , , , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/02/14 18:27, , , , , , , , , ,
2026/04/23 21:52, , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/04/15 19:41, , , , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2026/02/14 23:47, , , ,
2026/02/14 23:51, , , , , ,
2026/02/14 18:26, , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/03/05 21:19, , , , , , , , , , , , , , , , ,
2026/02/14 18:27, , , , , , ,



This page has been accessed for: Today: 4, Until now: 6