TOF53400 distance sensor, L2C communication

Hello everyone!

I had a project involving a distance sensor, I ended up choosing this TOF53400 which as far as I understand is identical to a VL53L1X. Using an ESP32 to send the data to a cellphone via bluetooth serial monitor

Amazon.ca link

Using the Adafruit_VL53L1X (simpletest) exemple sketch I cannot get a valid reading, serial monitor just repeat "Couldn't get distance: 0" and if I try to display the value of distance I just get "-1" so an error value

#include "Adafruit_VL53L1X.h"

#define IRQ_PIN 2
#define XSHUT_PIN 3

Adafruit_VL53L1X vl53 = Adafruit_VL53L1X(XSHUT_PIN, IRQ_PIN);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println(F("Adafruit VL53L1X sensor demo"));

  Wire.begin();
  if (! vl53.begin(0x29, &Wire)) {
    Serial.print(F("Error on init of VL sensor: "));
    Serial.println(vl53.vl_status);
    while (1)       delay(10);
  }
  Serial.println(F("VL53L1X sensor OK!"));

  Serial.print(F("Sensor ID: 0x"));
  Serial.println(vl53.sensorID(), HEX);

  if (! vl53.startRanging()) {
    Serial.print(F("Couldn't start ranging: "));
    Serial.println(vl53.vl_status);
    while (1)       delay(10);
  }
  Serial.println(F("Ranging started"));

  // Valid timing budgets: 15, 20, 33, 50, 100, 200 and 500ms!
  vl53.setTimingBudget(50);
  Serial.print(F("Timing budget (ms): "));
  Serial.println(vl53.getTimingBudget());

  /*
  vl.VL53L1X_SetDistanceThreshold(100, 300, 3, 1);
  vl.VL53L1X_SetInterruptPolarity(0);
  */
}

void loop() {
  int16_t distance;

  if (vl53.dataReady()) {
    // new measurement for the taking!
    distance = vl53.distance();
    if (distance == -1) {
      // something went wrong!
      Serial.print(F("Couldn't get distance: "));
      Serial.println(vl53.vl_status);
      return;
    }
    Serial.print(F("Distance: "));
    Serial.print(distance);
    Serial.println(" mm");

    // data is read out, time for another reading!
    vl53.clearInterrupt();
  }
}

As a troubleshooting step, I ran this L2C adress scanner, but instead of giving me just 1 address, the one of my device, it would give me many, and not always the same ones, but 0x29 would be there at least, which is the one used by the sketch

L2C scanner

Scanning...
I2C device found at address 0x03
I2C device found at address 0x06
I2C device found at address 0x09
I2C device found at address 0x0D
I2C device found at address 0x11
I2C device found at address 0x14
I2C device found at address 0x16
I2C device found at address 0x17
I2C device found at address 0x1B
I2C device found at address 0x1C
I2C device found at address 0x20
I2C device found at address 0x21
I2C device found at address 0x25
I2C device found at address 0x26
I2C device found at address 0x29
I2C device found at address 0x2A
I2C device found at address 0x2B
I2C device found at address 0x2F
I2C device found at address 0x30
I2C device found at address 0x34
I2C device found at address 0x35
I2C device found at address 0x39
I2C device found at address 0x3A
I2C device found at address 0x3E
I2C device found at address 0x3F
I2C device found at address 0x70
I2C device found at address 0x74
I2C device found at address 0x76
I2C device found at address 0x78
I2C device found at address 0x7C
I2C device found at address 0x7D
done

I also tried setting the SDA and SCL pins to 32 and 33 on the ESP32, but it gave me the same results both with the scanner sketch and the adafruit vl53l1x sketch

So is this a bad sensor? am I doing something wrong?

Do yo have pull up resistors on the I2C pins?
You should have read the pinned post re 'How to get the most from the forum'. We can't see what you see, so posting ALL the code in code tags including the scanner code. Make a drawing by hand of where every wire goes. For not common items a link to a datasheet is needed.

I see you are using the Random Nerds site, but maybe you missed this part

Thanks, the vl53l1x is supposed to have integrated pull-up resistors, I will try to contact the seller to know if it is the case as this sensor has little information and I cannot find datasheet for tof53400, the wiring diagram on the product page I linked to amazon shows no pull-up resistors between on sda scl lines

So what pins were you using before that?
You do need those pullups.
Some other TOF-modules based on VL53L need to be set on I2C-mode by modbus command over serial interface...
If vendor is not able to provide datasheet, I would simply return it.

using the Pololu VL53L1X library running the VL53L1X_Continuous example
orginial ESP32 SDA to GPIO21 and SCL to GPIO22

/*
This example shows how to take simple range measurements with the VL53L1X. The
range readings are in units of mm.
*/

#include <Wire.h>
#include <VL53L1X.h>

VL53L1X sensor;

void setup()
{
  Serial.begin(115200);
  delay(2000);
  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C
  sensor.setTimeout(500);
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1);
  }

  // Use long distance mode and allow up to 50000 us (50 ms) for a measurement.
  // You can change these settings to adjust the performance of the sensor, but
  // the minimum timing budget is 20 ms for short distance mode and 33 ms for
  // medium and long distance modes. See the VL53L1X datasheet for more
  // information on range and timing limits.
  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);

  // Start continuous readings at a rate of one measurement every 50 ms (the
  // inter-measurement period). This period should be at least as long as the
  // timing budget.
  sensor.startContinuous(50);
}

void loop()
{
  Serial.print(sensor.read());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.println();
  delay(2000);
}

I get

121
180
164
190
183
190
244
277
296
331
143
117
121
104
193
1800
1750
1805

1805 is distant to ceiling

to check I2C connection I use

#include <Wire.h>
#include <i2cdetect.h>

#define I2C_SDA 21
#define I2C_SCL 22

void setup() {
  Wire.begin(I2C_SDA, I2C_SCL);
   Wire.setTimeout(0);//3000);// /* us /, true / reset_on_timeout */); // 
   Wire.setClock ( 400000L ) ; 
  //Wire.begin();
  Serial.begin(115200);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
  
}

void loop() {
  i2cdetect();
  delay(2000);
}

gives

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Module OP uses, has MCU onboard...