VL53L0X not working (I2C issue?)

I'm trying to use the TOF sensor VL53L0X with an arduino uno. Wiring (VL53L0X module to arduino uno): VIN - 5v pin, GND - GND, SDA - A4, SCL - A5. The documentation can be found here. When you install the library, there are pre-written example codes. I've selected the one called "Continuous". When I run the code, nothing is displayed in the serial port.
code:

/* This example shows how to use continuous mode to take
range measurements with the VL53L0X. It is based on
vl53l0x_ContinuousRanging_Example.c from the VL53L0X API.

The range readings are in units of mm. */

#include <Wire.h>
#include <VL53L0X.h>

VL53L0X sensor;

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

  sensor.setTimeout(500);
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1) {}
  }

  // 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();
}

So I run the following code to scan the I2C.

// --------------------------------------
// i2c_scanner
//
// Modified from https://playground.arduino.cc/Main/I2cScanner/
// --------------------------------------

#include <Wire.h>

// Set I2C bus to use: Wire, Wire1, etc.
#define WIRE Wire

void setup() {
  WIRE.begin();

  Serial.begin(9600);
  while (!Serial)
     delay(10);
  Serial.println("\nI2C Scanner");
}


void loop() {
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    WIRE.beginTransmission(address);
    error = WIRE.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

The following is printed in the serial port
"I2C Scanner
Scanning..."
I have run this code with the wiring shown previously and on a bare arduino, both times, I get the same result. Can someone help, what do I do? Thanks

Feeding Vin with 5 volt is a mistake. Feed it to the 5 volt pin.

What result did You get?

Please post documentation here when possible. Links are not appreciated.

Please post code here. Links are not accepted.

As I read your post, you're feeding the sensor's VIN with 5V. If it's a 5V sensor, that's fine.

The IDE comes with an I2C scanner, as well. Have you tried it?
Examples|Wire|i2c scanner, I think.

?
All VL53LOX modules I see (Adafruit, ebay etc.) come with a voltage regulator and I2C level shifter.
The sensor itself runs on 2.8volt, but V-in can be anything between 3.3volt and 5volt.

Maybe it's wise to post a picture of the build.
How long is the I2C wiring. Did you solder the pinheaders.
Leo..

I am feeding the vin with the 5 volt pin, I'll edit the post to make it more clear. So same result. And unfortunately I can't post the documentation because it's several pages long

I just tried it right now, same result
"I2C Scanner
Scanning..."

I'm testing the I2C scanner code on a bare arduino (no components attached). Didn't work. I've also tried all the code mentioned with the VL53L0X attached using jumper wires (length 120mm). And the pinheaders have been soldered. Don't you think it's a problem with I2C since when I run the scan it gets stuck?

can you post a link to the vl53l0x sensor or at least a photo
I have a couple of vl53l0x TOF sensors

  1. vl53l0x is stated as 3.3V Supply Voltage
  2. the Pololu VL53L0X is 2.6 to 5.5V

never attempted to use either with 5V logic microcontrollers such as the UNO - always used 3.3V devices such as the Arduino Due or ESP32

Sensor. So I'm guessing I was meant to use it with 3.3v. On the link it says the the VL53L0X is rated for 3.3v but the videos I've watch such as this one (skip to 7:11), the VL53L0X is connected to 5v. So did I damage the hardware? Don't you think the problem could be with I2C since the code gets stuck at "Scanning"?

5V is correct, you did not damage it.
Yes the problen is with the I2C.
To debug he problem, disconnect the SCL wire and run the Scanner program and see what happens.

SCL wire disconnected, still gets stuck at "scanning". What should it show when nothing is connected to the arduino uno? Because even when I disconnect every wire, I get the same problem?

With nothing connected, my UNO says "No I2C devices found".
Do you have anything else connected to the UNO

nothing. I can send a picture if you want, but nothing is connected

connect the unbranded vl53l0x to a UNO and ran the following I2C scanner

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  // activate internal pullups for twi.
  digitalWrite(SDA, 1);
  digitalWrite(SCL, 1);
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 2; i < 120; i++)
  {
    Wire.beginTransmission (i);
      Serial.print (" 0x");
      Serial.print (i, HEX);

    if (Wire.endTransmission () == 0)
      {
      Serial.print ("\nFound address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (100);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

the serial monitor diplays - first scan nothing connected second scan vl53l0x connected to UNO SCL and SDA pins (VCC connected to either 3.3V or 5V works)

I2C scanner. Scanning ...
 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77Done.
Found 0 device(s).

I2C scanner. Scanning ...
 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29
Found address: 41 (0x29)
 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77Done.
Found 1 device(s).

No, pic not needed.
If the SCL line is pulled LOW the scanner program gets stuck.
You may have damaged the UNO somehow.

Still gets stuck at scanning, maybe damaged arduino UNO as suggested by jim-p

if I connect UNO SCL to GND the scanner displays

I2C scanner. Scanning ...
 0x2

when I remove GND the scan completes

To figure out if the UNO is broken, run the "ReadAnalogVoltage" example program but change A0 to A5.
Connect a 1K ohm resistor beween 5V and A5. It should print out something close to 5V.
If not, it's bad.

I assume Dupond wires.
Did you already replace those, or at least measure them.
The cheap ones do fail open circuit.
Leo..

It prints 5v, so what else could be the issue?