I am trying to read data from 3 vl53l0x sensors on the i2c bus. I am using the xshut pins to shut the other sensors off during address setting. I have tried to use the VL53L0X_SetDeviceAddress from the vl53l0x_api.h, and i can change the address with that code but how do i read data from the sensors?
if i connect three sensors and enter this code:
#include “Seeed_vl53l0x.h”
Seeed_vl53l0x VL53L0X;
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SERIAL SerialUSB
#else
#define SERIAL Serial
#endif
void setup() {
pinMode(6, OUTPUT); //xshut pins
pinMode(7, OUTPUT);
pinMode(8, INPUT);
delay(100); //allow sensor 3 to power -up
VL53L0X_SetDeviceAddress(1, 48);
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
SERIAL.begin(115200);
Status = VL53L0X.VL53L0X_common_init();
if (VL53L0X_ERROR_NONE != Status) {
SERIAL.println("start vl53l0x mesurement failed!");
VL53L0X.print_pal_error(Status);
while (1);
}
VL53L0X.VL53L0X_continuous_ranging_init();
if (VL53L0X_ERROR_NONE != Status) {
SERIAL.println("start vl53l0x mesurement failed!");
VL53L0X.print_pal_error(Status);
while (1);
}
}
void loop() {
VL53L0X_RangingMeasurementData_t RangingMeasurementData;
VL53L0X.PerformContinuousRangingMeasurement(&RangingMeasurementData);
if (RangingMeasurementData.RangeMilliMeter >= 2000) {
SERIAL.println("out of ranger");
} else {
SERIAL.print("distance::");
SERIAL.println(RangingMeasurementData.RangeMilliMeter);
}
delay(100);
}
the code runs and i can see the data from one sensor
how do i read the data from the other sensors? How do i specify that for instance ‘init’ should be performed for sensor 2 and 3
In the library there is a variable called ‘VL53L0X_DEV’, this is the device number. I suppose i have to set this to 1, 2, 3, for sensor 1 2 and 3 but I dont know how