Hi there. As part of a project, one of the tasks I have to do is to implement a VL53L1X-Satel on an Arduino Uno board. Currently the code I am running is this one:
VL53L1X sensor;
void setup()
{
Serial.begin(115200);
Wire.begin();
Wire.setClock(400000); // use 400 kHz I2C
SensorBegin();
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::Short);
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() {
}
void SensorBegin()
{
int i;
for (i= 0; i <= 100; i++){
Serial.print("\ test");
sensor.read();
Serial.print("range: ");
Serial.print(sensor.ranging_data.range_mm);
Serial.print("\tstatus: ");
Serial.print(VL53L1X::rangeStatusToString(sensor.ranging_data.range_status));
Serial.print("\tpeak signal: ");
Serial.print(sensor.ranging_data.peak_signal_count_rate_MCPS);
Serial.print("\tambient: ");
Serial.print(sensor.ranging_data.ambient_count_rate_MCPS);
Serial.println();
delay(1000);
}
}
The problem I am having is I have not been able to get any values read onto the serial, if I run the code as is, test is printed twice and nothing happens after that, if I comment out from sensor.read to Serial.println in the SensorBegin function, the serial works as expected and test is printed on to the serial every second which makes me believe the problem is either in that section of the code or more likely the setup itself.
I’ve attached a few pictures of one of the setups I have tried, I am very much not confident in it as to why one of the wires is shown unattached. From what I can tell based on the datasheet for the VL5L1X-Satel, the Vin(VDD) is the pin across from GND so I tried wiring it through the hole 5th on the left to connect it to row 16 but that didn’t produce any result.
I am very much a newbie when it comes to circuit design, especially with Arduino and I can’t seem to find any examples online which use a VL53L1X-Satel and a UNO board. I should hopefully be getting Male-Female cables soon but whether or not that has an effect on it I don’t know. Any advice on what I am doing wrong would be greatly appreciated.
Thanks,
Ross.