I translated the Arduino C++ lib to a simple C-lib for this sensor. You still need to adapt the I2C and the millis() functions to your µ. I use this with the STM32 F100 discovery board. The sensor seems to work OK, indoor with the standard settings the range is 1200 mm on a White wall. There is a setting "Long Range", which would give you a 2000 mm range.
Initialisation (VL53_0 is the choosen I2C-adress, B0/B2 are the XShutdown-pins of the VL53) :
B0_OFF;B2_OFF;delay(10); //VL53_2 actief XSDN hoog maken !!!
VL53L0X_setAddress(VL53_0); //VL53_0 adres veranderen naar 0Xterwijl VL53_1/2 in reset zijn
B0_ON;delay(10);//VL53_1 adres VL53_1 veranderen en daarna init
VL53L0X_setAddress(VL53_1);//VL53_1 nieuw adres geven
B2_ON;delay(10);//VL53_2 inschakelen, deze houdt 0X52 als adres !!
//VL53_0 init
VL53L0X_Active_slave(VL53_0);
VL53L0X_init(true);
VL53L0X_setTimeout(250);
VL53L0X_startContinuous(0);
//VL53_1 init
VL53L0X_Active_slave(VL53_1);
VL53L0X_init(true);
VL53L0X_setTimeout(250);
VL53L0X_startContinuous(0);
//VL53_2 init
VL53L0X_Active_slave(VL53_2);
VL53L0X_init(true);
VL53L0X_setTimeout(250);
VL53L0X_startContinuous(0);
Read out in the loop :
void Task_VL53L0X(void){
if(VL53_timer>=VL53_timing_budget){
VL53_timer=0;
VL53L0X_Active_slave(VL53_0);
vl53_2=VL53L0X_readRangeContinuousMillimeters();//opgelet, blocking indien meting niet klaar !!!
VL53L0X_Active_slave(VL53_1);
vl53_1=VL53L0X_readRangeContinuousMillimeters();//opgelet, blocking indien meting niet klaar !!!
VL53L0X_Active_slave(VL53_2);
vl53_0=VL53L0X_readRangeContinuousMillimeters();//opgelet, blocking indien meting niet klaar !!!
}
Op vrijdag 8 september 2017 15:06:45 UTC+2 schreef Jean-Daniel Nicoud: