Hi,
I have had this problem and found this solution with works very well.
It uses diode switching of the SCL (clock) line.
This is the code I was using on two VCNL4010 distance sensors.
#include <Wire.h>
#include "Adafruit_VCNL4010.h"
Adafruit_VCNL4010 vcnl;
int detectRightPin = 8;
int detectLeftPin = 9;
bool Select = true;
void setup()
{
Serial.begin(115200);
Serial.println("========================VCNL4010TEST_TGIMD_1=====================");
Serial.println("======================UNO========================================");
Serial.println("VCNL4010 test");
pinMode(detectRightPin, OUTPUT);
pinMode(detectLeftPin, OUTPUT);
//Select Left Sensor to initialise Sensor and I2C Library
digitalWrite(detectRightPin, LOW);
digitalWrite(detectLeftPin, HIGH);
delay(250);
if (! vcnl.begin()) {
Serial.println("Left Sensor not found :(");
while (1);
}
Serial.println("Left Found VCNL4010");
//Select Right Sensor to initialise Sensor and I2C Library
digitalWrite(detectLeftPin, LOW);
digitalWrite(detectRightPin, HIGH);
delay(250);
if (! vcnl.begin()) {
Serial.println("Right Sensor not found :(");
while (1);
}
Serial.println("Right Found VCNL4010");
}
void loop()
{
if (Select == true)
{ // Read Left Sensor
digitalWrite(detectRightPin, LOW);
digitalWrite(detectLeftPin, HIGH);
Serial.print("Left Ambient: ");
Serial.print(vcnl.readAmbient());
Serial.print("\tProximity: ");
Serial.print(vcnl.readProximity());
Select = false;
}
else
{ // Read Right Sensor
digitalWrite(detectLeftPin, LOW);
digitalWrite(detectRightPin, HIGH);
Serial.print(" \t\tRight Ambient: ");
Serial.print(vcnl.readAmbient());
Serial.print("\tProximity: ");
Serial.println(vcnl.readProximity());
Select = true;
}
}
Hope this helps..
Tom...