I'm using this code and It doesn't show me any sensor readings.
#include "Wire.h"
#include "DFRobot_VL53L0X.h"
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#define LED_1 2
#define LED_2 4
#define LED_3 15
LiquidCrystal_I2C lcd(0x27, 20, 4); // declaration display
DFRobot_VL53L0X sensor;
float x1; // variable sensor 1
float x2; // variable sensor 2
void TCA9548A(uint8_t bus)
{
Wire.beginTransmission(0x70);
Wire.write(1 << bus);
Wire.endTransmission();
}
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
Serial.begin(115200);
TCA9548A(0);
sensor.begin(0x29); // sensor #1
sensor.setMode(sensor.eContinuous, sensor.eHigh); //Set to Back-to-back mode and high precision mode
sensor.start(); //Laser rangefinder begins to work
TCA9548A(1);
sensor.begin(0x29); //sensor #2
sensor.setMode(sensor.eContinuous, sensor.eHigh); //Set to Back-to-back mode and high precision mode
sensor.start(); //Laser rangefinder begins to work
while (!Serial) { // wait until serial port opens for native USB devices
delay(1);
}
}
void loop() {
TCA9548A(0); // call sensor #1 and Get the distance
digitalWrite(LED_1, HIGH);
digitalWrite(LED_2, LOW);
digitalWrite(LED_3, LOW); // turn the LED off by making the voltage LOW
x1 = sensor.getDistance() ;
Serial.println("Axes X mm: ");
Serial.println(x1);
TCA9548A(1); // call sensor #2 and Get the distance
digitalWrite(LED_1, LOW);
digitalWrite(LED_2, HIGH);
digitalWrite(LED_3, LOW); // turn the LED off by making the voltage LOW
x2 = sensor.getDistance() ;
Serial.println("Axes Y mm: ");
Serial.println(x2);
delay(1000);
}