Hello.
I have an issue using VL53L5CX with Arduino ESP32 nano.
The SparkFun_VL53L5CX breakout board is used.
The ESP32 and VL53L5CX are wired with the SDA and SCL with 3.3V and Ground.
I have not wired any of the other pins.
The below code is from the example and results in:
"Data not ready"
Any ideas?
#include <Arduino.h>
//VL53L5CX
#include <Wire.h>
#include <SparkFun_VL53L5CX_Library.h>
SparkFun_VL53L5CX VL53L5CX_TOF;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM
int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output
void setup()
{
Serial.begin(115200);
delay(5000);
Serial.println("SparkFun VL53L5CX Imager Example");
Wire.begin(); //This resets to 100kHz I2C
Wire.setClock(400000); //Sensor has max I2C freq of 400kHz
Serial.println("Initializing sensor board. This can take up to 10s. Please wait.");
if (VL53L5CX_TOF.begin() == false)
{
Serial.println(F("Sensor not found - check your wiring. Freezing"));
while (1) ;
}
VL53L5CX_TOF.setResolution(8*8); //Enable all 64 pads
imageResolution = VL53L5CX_TOF.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
imageWidth = sqrt(imageResolution); //Calculate printing width
VL53L5CX_TOF.startRanging();
}
void loop()
{
//Poll sensor for new data
if (VL53L5CX_TOF.isDataReady() == true)
{
if (VL53L5CX_TOF.getRangingData(&measurementData)) //Read distance data into array
{
//The ST library returns the data transposed from zone mapping shown in datasheet
//Pretty-print data with increasing y, decreasing x to reflect reality
for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
{
for (int x = imageWidth - 1 ; x >= 0 ; x--)
{
Serial.print("\t");
Serial.print(measurementData.distance_mm[x + y]);
}
Serial.println();
}
Serial.println();
}
}
else
{
Serial.println(F("Data not ready"));
}
delay(1000); //Small delay between polling
}