This is my first time using an I2C system, so sorry if this is a dumb question, but… I am attempting to connect a set of 2 daisy-chained VL53L1X distance sensor breakout boards to an Arduino Uno. They are connected via a Qwiic shield and everything works fine with one, and when I plug 2 in I get readings from both just jumbled up. to differentiate between the two sensors, I attempted to change the address of one to 0x44 (default is 0x52) using this code.
#include <Wire.h>
#include "SparkFun_VL53L1X.h" //Click here to get the library: http://librarymanager/All#SparkFun_VL53L1X
//Optional interrupt and shutdown pins.
#define SHUTDOWN_PIN 2
#define INTERRUPT_PIN 3
SFEVL53L1X distanceSensor1;
SFEVL53L1X distanceSensor2;
uint8_t address2 = 0x44;
//Uncomment the following line to use the optional shutdown and interrupt pins.
//SFEVL53L1X distanceSensor(Wire, SHUTDOWN_PIN, INTERRUPT_PIN);
void setup(void)
{
Serial.begin(115200);
Serial.println("VL53L1X Qwiic Test");
distanceSensor2.setI2CAddress(0x44);
if (distanceSensor2.begin(0x44) != 0) //Begin returns 0 on a good init
{
Serial.println("Sensor2 failed to begin. Please check wiring. Freezing...");
while (1)
;
}
if (distanceSensor1.begin() != 0) //Begin returns 0 on a good init
{
Serial.println("Sensor1 failed to begin. Please check wiring. Freezing...");
while (1)
;
}
Serial.println("Sensor online!");
}
When I did that I got the following error
C:\Users\Benja\AppData\Local\Temp\.arduinoIDE-unsaved2023521-7964-yeeu0m.8atf\Example1_ReadDistance\Example1_ReadDistance.ino: In function 'void setup()':
C:\Users\Benja\AppData\Local\Temp\.arduinoIDE-unsaved2023521-7964-yeeu0m.8atf\Example1_ReadDistance\Example1_ReadDistance.ino:40:33: error: no matching function for call to 'SFEVL53L1X::begin(int)'
if (distanceSensor2.begin(0x44) != 0) //Begin returns 0 on a good init
^
In file included from C:\Users\Benja\AppData\Local\Temp\.arduinoIDE-unsaved2023521-7964-yeeu0m.8atf\Example1_ReadDistance\Example1_ReadDistance.ino:17:0:
C:\Users\Benja\Documents\Arduino\libraries\SparkFun_VL53L1X_4m_Laser_Distance_Sensor\src/SparkFun_VL53L1X.h:67:7: note: candidate: bool SFEVL53L1X::begin()
bool begin(); //Initialization of sensor
^~~~~
C:\Users\Benja\Documents\Arduino\libraries\SparkFun_VL53L1X_4m_Laser_Distance_Sensor\src/SparkFun_VL53L1X.h:67:7: note: candidate expects 0 arguments, 1 provided
C:\Users\Benja\Documents\Arduino\libraries\SparkFun_VL53L1X_4m_Laser_Distance_Sensor\src/SparkFun_VL53L1X.h:68:7: note: candidate: bool SFEVL53L1X::begin(TwoWire&)
bool begin(TwoWire &i2cPort); //Initialization of sensor
^~~~~
C:\Users\Benja\Documents\Arduino\libraries\SparkFun_VL53L1X_4m_Laser_Distance_Sensor\src/SparkFun_VL53L1X.h:68:7: note: no known conversion for argument 1 from 'int' to 'TwoWire&'
exit status 1
Compilation error: no matching function for call to 'SFEVL53L1X::begin(int)'
Can someone help me understand what I’m doing wrong here? I think that it is just a syntax error, but how are you supposed to set the address in the .begin command?