adafruit / Adafruit_VL53L0X

Arduino library for Adafruit VL53L0X
150 stars 118 forks source link

Connecting Multiple Sensors #4

Closed anoukzib closed 6 years ago

anoukzib commented 6 years ago

Hello,

I try to connect multiple sensors but it retourn me just one fixe value when I connect the second sensor... Do you have an idea ? Thanks

include

include "Adafruit_VL53L0X.h"

define SHUT_LOX 2

define SHUT_LOX2 5

define LOX_Adr 0x29

define LOX2_Adr 0x30

Adafruit_VL53L0X lox = Adafruit_VL53L0X(); Adafruit_VL53L0X lox2 = Adafruit_VL53L0X();

void setup() {

// INIT SERIAL Serial.begin(9600); while (! Serial) { delay(1); } Serial.println("Serial init ==> OK");

// INIT SENSORS DISTANCE pinMode(SHUT_LOX,OUTPUT); pinMode(SHUT_LOX2,OUTPUT);

delay(500); Wire.begin();

Serial.println("Reset BOTH"); digitalWrite(SHUT_LOX,LOW); digitalWrite(SHUT_LOX2,LOW); delay(10); // Reset all sensors by setting all of their XSHUT pins low for delay(10), then set all XSHUT high to bring out of reset digitalWrite(SHUT_LOX,HIGH); digitalWrite(SHUT_LOX2,HIGH); digitalWrite(SHUT_LOX,LOW); digitalWrite(SHUT_LOX2,LOW); Serial.println("Reset OK");

Serial.println("Init VL53L0X _ LOX"); //digitalWrite(SHUT_LOX2, LOW); digitalWrite(SHUT_LOX, HIGH); delay(10);

Serial.println("InitLOX....."); lox.setAddress(LOX_Adr); pinMode(SHUT_LOX, INPUT); if (!lox.begin(LOXAdr)) { Serial.println(F("Failed to boot VL53L0X LOX")); //while (1); } else { Serial.println(F(" ==> OK")); }

delay(2000);

// init LOX2 Serial.println("InitLOX 2....."); Serial.println("Init VL53L0X _ LOX2"); //digitalWrite(SHUT_LOX, LOW); digitalWrite(SHUT_LOX2,HIGH);

delay(1); lox2.setAddress(LOX2_Adr); pinMode(SHUT_LOX2, INPUT); if (!lox2.begin(LOX2Adr)) { Serial.println(F("Failed to boot VL53L0X LOX2")); //while (1); } else { Serial.println(F(" ==> OK")); } //delay(1);

//digitalWrite(SHUT_LOX, HIGH); // END INIT SENSORS

}

void loop() {

//capteur distance VL53L0X_RangingMeasurementData_t measure; lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout! Serial.println(measure.RangeMilliMeter); Serial.print(" ");

}

ladyada commented 6 years ago

hiya for tech support please post in the forums!