pololu / vl53l0x-arduino

Pololu Arduino library for VL53L0X time-of-flight distance sensor
https://www.pololu.com/product/2490
Other
346 stars 162 forks source link

Can't initialize VL53L0/1XV2 sensor on ESP32 (lolin32) #43

Closed pcboy closed 4 years ago

pcboy commented 4 years ago

I tried all examples but I my sensor never achieve to init() itself.
The sensor is detected with an i2c scanner (address 0x29) but beside that I can never init() properly. Sensor VIN is plugged to 3V3, GND to my esp32 GND, SDA/SCL to SDA/SCL on my esp32 board (pin 21 & 22).
Code is as simple as:

#define I2C_SDA 21
#define I2C_SCL 22

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

VL53L0X sensor;
void setup()
{
    Serial.begin(9600);

    // wait until serial port opens for native USB devices
    while (!Serial) {
        delay(1);
    }

    Wire.begin(I2C_SDA, I2C_SCL);

    //sensor.setAddress((uint8_t)0x29);
    sensor.setTimeout(500);
    if (!sensor.init()) {
        Serial.println("Failed to detect and initialize sensor!");
        while (42);
    }
}

I always get "Failed to detect and initialize sensor!" on my serial console.
An i2c scanner returns:

Found address: 41 (0x29)
Done.
Found 1 device(s).

Any idea why that happens?
My sensor is labeled VL53L0/1XV2.

pcboy commented 4 years ago

I just found that I should use the vl53l1x library instead of the vl53l0x!

https://github.com/pololu/vl53l1x-arduino

It works perfectly with this one. Thanks.