I am using an ESP32, and I have 2 IC2 sensors I want to use. The first works well using the default IC2 pins G21 and G22, but I have problems setting up the second (using GitHub - RobTillaart/AS5600: Arduino library for AS5600 magnetic rotation meter)
I am trying to work out what I have done wrong, and have got this far. The second I2C device does not connect to successfully.
#include "Adafruit_VL53L0X.h" // Laser distance measurment (VL53L0X)
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
#include "AS5600.h" // Hall Rotation Sensor (AS5600)
TwoWire I2Ctwo = TwoWire(1);
AS5600 as5600(&I2Ctwo);
void setup()
{
Serial.begin(115200);
// VL53L0X - Uses default SDA, SCL
while (!Serial)
{
delay(1);
}
Serial.println("Adafruit VL53L0X test");
if (!lox.begin())
{
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
Serial.println(F("Boot VL53L0X success"));
delay(1000);
// AS5600 - Uses my chosen SDA, SCL (since default is already used by VL53L0X)
as5600.begin(16,17); // My choice: SDA & SCL
delay(1000);
int b = as5600.isConnected();
Serial.print("Connect: ");
Serial.println(b); // I get a 0 (false) here :(
delay(1000);
}
void ReadVL53L0X() {
VL53L0X_RangingMeasurementData_t measure;
// Reading a measurement
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) // phase failures have incorrect data
{
Serial.print("Distance (mm): ");
Serial.println(measure.RangeMilliMeter);
}
else
{
Serial.println(" out of range ");
}
}
void loop()
{
ReadVL53L0X();
delay(10);
Serial.print(as5600.readAngle());
delay(10);
}
The output shows that as5600.isConnected() fails.
The AS5600 library offers this help(which I have tried to follow - unsuccessfully) -