Hello everyone, and thank you very much in advance.
I have three VL6180X sensors (I don't know what company is the manufacturer, I bought them on line in Taiwan).
I already removed the SCL and SDA resistors from Sensor02 and Sensor03.
Sensor01 and Sensor02 together work fine.
Sensor01 and Sensor03 together work fine.
The three sensors together don't work, I only get 510 reading from the three sensors.
Before I removed the resistors from Sensor02 and Sensor03, I tested them individually and they worked fine.
I am using an Arduino Due, the sensors are connected to 5V (5V pin above pin 23, and GND below pin 53).
Here is the circuit.
(The VL6180X are the three black breakout boards in from, the green breakout board behind are TMC2130, they are connected to several pin on the Due, but they are not connected to any power source now).
Here is the code.
#include <Wire.h>
#include <VL6180X.h>//Polulu
VL6180X Sensor01;
VL6180X Sensor02;
VL6180X Sensor03;
String InputStr = "";
char Cmd = 'Z'; //Nothing
#define Sensor01Pin 2
#define Sensor02Pin 3
#define Sensor03Pin 4
#define Sensor01Add 0x20
#define Sensor02Add 0x22
#define Sensor03Add 0x24
void setup()
{
Serial.begin(115200);
Wire.begin();
pinMode(Sensor01Pin, OUTPUT);
pinMode(Sensor02Pin, OUTPUT);
pinMode(Sensor03Pin, OUTPUT);
delay(100);
digitalWrite(Sensor01Pin, HIGH);
digitalWrite(Sensor02Pin, HIGH);
digitalWrite(Sensor03Pin, HIGH);
delay(100);
digitalWrite(Sensor01Pin, LOW);
digitalWrite(Sensor02Pin, LOW);
digitalWrite(Sensor03Pin, LOW);
delay(100);
}
void loop()
{
if (Serial.available() > 0) {
InputStr = Serial.readStringUntil('\n');
Cmd = InputStr.charAt(0);
switch (Cmd) {
case 'A': //Read Address
{
Serial.println(Sensor01.getAddress(), HEX);
Serial.println(Sensor02.getAddress(), HEX);
Serial.println(Sensor03.getAddress(), HEX);
}
break;
case 'S': //Set up
{
Serial.println("Set up");
//Sensor01
digitalWrite(Sensor01Pin, HIGH);
delay(50);
Sensor01.init();
Sensor01.configureDefault();
Sensor01.setAddress(Sensor01Add);
delay(50);
Sensor01.setTimeout(500);
Sensor01.stopContinuous();
Sensor01.setScaling(2); // configure range or precision 1, 2 oder 3 mm
delay(300);
//Sensor02
digitalWrite(Sensor02Pin, HIGH);
delay(50);
Sensor02.init();
Sensor02.configureDefault();
Sensor02.setAddress(Sensor02Add);
delay(50);
Sensor02.setTimeout(500);
Sensor02.stopContinuous();
Sensor02.setScaling(2); // configure range or precision 1, 2 oder 3 mm
delay(300);
//Sensor03
digitalWrite(Sensor03Pin, HIGH);
delay(50);
Sensor03.init();
Sensor03.configureDefault();
Sensor03.setAddress(Sensor03Add);
delay(50);
Sensor03.setTimeout(500);
Sensor03.stopContinuous();
Sensor03.setScaling(2); // configure range or precision 1, 2 oder 3 mm
delay(300);
}
break;
case 'R'://Read Sensors
{
Serial.print("S01: ");
Serial.print(Sensor01.readRangeSingleMillimeters());
if (Sensor01.timeoutOccurred()) {
Serial.println("Sensor01 TIMEOUT");
}
Serial.print(" | S02: ");
Serial.print(Sensor02.readRangeSingleMillimeters());
if (Sensor02.timeoutOccurred()) {
Serial.println("Sensor02 TIMEOUT");
}
Serial.print(" | S03: ");
Serial.println(Sensor03.readRangeSingleMillimeters());
if (Sensor03.timeoutOccurred()) {
Serial.println("Sensor03 TIMEOUT");
}
}
break;
}
}
}
Thank you very much for your help.