The problem I have is that whenever the SDA and SCL pins are connected, no serial communication takes place. So my serial monitor doesn't display anything and also the tx light on the board doesn't flash. The moment I remove the connection, however, the serial communication is back and I get the error code that the sensor isn't connected.
I think it is also worth mentioning that I am experiencing the same issue with other I2C sensors which have previously worked...
I don't think the SDA and SCl pins are damaged because I was able to perform the simple master slave tests between two UNOs
DO NOT use "Serial" for both device and PC communication - it just doesn't work that way.
If you have an Arduino with multiple serial ports, use one of the extra ports for device communication. If you don't, then I suggest buying one. If you can't buy one with extra ports, you can use one of the software serial libraries for device communication.
Oh, sorry, I misread your code. Either way, it would be a lot easier to look over your code if you posted it in tags in your OP (future reference). For now, here it is:
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
Serial.begin(115200);
// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}
Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) { // phase failures have incorrect data
Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
} else {
Serial.println(" out of range ");
}
delay(100);
}