Hi,
I am trying to get multiple VL53L0X sensors to run in continuously while in the LONG_RANGE mode. I’ve set VcselPeriodPreRange and VcselPeriodFinalRange to 18 and 14 respectively for each sensor as I bring them online but once it gets into the main program, all the sensors are timed out and will not get readings.
I’ve been scratching my head over this issue for a little while now and can’t seem to find the issue.
Here is my code for the initialize procedure.
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor29;
VL53L0X sensor25;
VL53L0X sensor23;
//Define Wait Times
#define N_DELAY_TIME 10
// Sensor Sensor Pins
#define SEN23 12
#define SEN25 11
#define SEN29 10
void setup(){
Serial.begin(9600);
Wire.begin();
pinMode(SEN23, OUTPUT); //Setting pin modes for XSHDN pins on sensor.
pinMode(SEN25, OUTPUT);
pinMode(SEN29, OUTPUT);
Serial.println("Start");
Serial.println("Shutting Down Sensors");
//Bring sensors to shutdown mode
digitalWrite(SEN23, LOW);
digitalWrite(SEN25, LOW);
digitalWrite(SEN29, LOW);
delay(N_DELAY_TIME);
Serial.println("Turning on sensor 1 and setting to 0x23");
digitalWrite(SEN23, HIGH); //Bring sensor 0x23 out of shutdown
delay(100);
sensor23.setAddress(0x23); // Setting sensor 0x23 to address 0x23
delay(10);
digitalWrite(SEN25, HIGH); // Bringing sensor 0x25 out of shutdown
delay(100);
sensor25.setAddress(0x25); // Setting sensor 0x25 to address 0x25
delay(10);
digitalWrite(SEN29, HIGH); // Turning on sensor 0x29 and leaving at default address (0x29)
delay(100);
Serial.println("Sensor1 INIT");
sensor23.init();
sensor23.setTimeout(500);
sensor23.startContinuous();
Serial.println("Sensor2 INIT");
sensor25.init();
sensor25.setTimeout(500);
sensor25.startContinuous();
Serial.println("Sensor3 INIT");
sensor29.init();
sensor29.setTimeout(500);
sensor29.startContinuous();
Serial.println("Set Sensor to Long Range Mode");
sensor29.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor29.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
sensor25.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor25.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
sensor23.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor23.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
Serial.println("Initialization done! Moving to loop steps!");
delay(500);
}