Using one VL6180X 20cm Time-of-Flight proximity sensor with Arduino

Project Video
Project Details

This is the Arduino code for VL6180X proximity sensor with 20cm range. Sensor explaiend in this video, wiring shown for 1 sensor and for 2 or more sensor. Adafruit Library is used. Code updated to be used easity with for real application for 1 sensor or 2 or more sensors.

Using 2 or more VL6080X Distance Proximity Sensor

Chapters of this video

  • 00:56 Introduction
  • 04:30 VL6080V Datasheet viewed
  • 06:58 Wiring shown
  • 07:32 Wiring for two or more sensors
  • 09:22 Installing library
  • 10:30 Arduino code explained (1 sensor)
  • 12:57 Code for 2 or more sensors
  • 19:35 Demonstration 1 sensor
  • 22:05 Demonstration with 2 sensors
Project Code

 *  Arduino code 
Using single VL6180X 20cm Time-of-Flight proximity sensor with Arduino

View code for using single VL6180X sensors:

 * Original code and library by
 * Written/updated by Ahmad Shamshiri for Robojax
 * on Mar 10, 2021  in Ajax, Ontario, Canada
 Watch the video instruction for this sketch:

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon
or make donation using PayPal

 * Code is available at

 * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see . 

#include "Adafruit_VL6180X.h"

Adafruit_VL6180X vl = Adafruit_VL6180X();

void setup() {

  // wait for serial port to open on native usb devices
  while (!Serial) {
  Serial.println("Adafruit VL6180x test!");
  if (! vl.begin()) {
    Serial.println("Failed to find sensor");
    while (1);
  Serial.println("Sensor found!");

void loop() {

  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  if (status == VL6180X_ERROR_NONE) {
    Serial.print("Range: "); Serial.print(range);
//  if(range <=76)
//  {
//    //do something
//  }

  // 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 reading underflow");
  else if (status == VL6180X_ERROR_RANGEOFLOW) {
    Serial.println("Range reading overflow");

If you found this Arduino course helpful, please support me so I can continue creating content like this. support me via PayPal