Interference I2C and Serial

Hi All,

I have an Adafruit ToF sensor (VL53L0X) which uses I2C protocol.

I tested it using a UNO and Adafruit's library and code (Arduino Code | Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout | Adafruit Learning System)

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.

The library can be found here: GitHub - adafruit/Adafruit_VL53L0X: Arduino library for Adafruit VL53L0X
And I attached the code below.

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

Thanks!

vl53l0x.ino (842 Bytes)

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.

I apologize if I was unclear. Serial is only between the Arduino UNO and my computer. The Arduino UNO and the sensor use I2C.

What do you mean exactly with both devices and PC?
Thanks!

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