VL6180X: Three sensors don't work together

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.

Are the sensors on different I2C addresses?
Run the I2C scan program ( I2C scan ) with one sensor connected at a time. Are there three different addresses found?

Strange things can happen when you connect unpowered devices to an MCU.
Phantom-powering through signal pins and possible pin/MCU damage.
Leo..

Hi, Wawa
Thank you very much for your observation.
I have connected all the TMC2130 to their respective power source, but it didn't solve the problem.

Hi, Grumpy_Mike,

Thank you very much for your help.

First, I connected all the TMC2130 to their power source, as the user Wawa suggested.

I connected every sensor individually, then I ran the I2C scan program, it showed every sensor has its default I2C address (0x29). I know every sensor must have an unique I2C address, that's why the sensor are disabled at the beginning, then the first thing I do is to run the code within case 'S': and try to assign different addressees to every sensor.

It is worse now, now two sensors don't work together.

I have an Analog Discovery 2 (AD2), it has a function to spy on I2C. When I connect only one sensor, the AD2 shows the transmission is OK, but when I connect two sensors, the AD2 doesn't show anything, there is not even I2C output from Arduino.

I think it is time to post a proper schematic of the circuit you have. Maybe you are miss understanding something about how this sensor works.

Thank you very much.
Here is the circuit.

Hi,
Can you see if each of the 6180 have 4k7 pullup resistors on their SDA and SCL lines?

Do you have a DMM?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi, Tom,
Only one of the sensors has a 10k resistor on the SCL and SDA lines. I removed the 10k resistors from the other two sensors.

Yes, I have a DMM. I also have an Analog Discovery 2.

Thank you very much for your help.

Hi,
When you have the three sensors connected and your code failing to see them all, measure the power supply at the sensor.

Tom.... :smiley: :+1: :coffee: :australia:

Hi,

I did as you said, the power supply was fine.
I decided to buy three new sensors, maybe the sensors I am using now are faulty.
When I get the new sensors I will post an update.

Thank you very much.

I decided to buy four new sensors and also a new Arduino Due.
It didn't work.
I ran the I2C scan, but it didn't find any sensor.
I decided to use an old Arduino Mega Adk I have. I connected five sensors, and it worked perfectly.

So, Can't I use these sensors with a 3.3v Arduino board?

Has anyone used several VL6180X sensors with a 3.3v Arduino board?

Thank you very much

Did you get the new ones from the same place?
It is important to understand you are not using these sensors, you are using a board that contains those sensors.

The sensors themselves can't be run from 3V3. This bit from the sensor's data sheet shows you need a lower voltage 2V7 to 2V9 to run them.

So the board you have the sensors on might include a regulator to bring the voltage down to the optimum range.

However it is not unlikely that if you power the board with 3V3 the then regulator fitted might not have enough excess voltage to allow the regulators to regulate, it could be passing 3V3 onto them which could damage them.

This is the typical I2C setup for the sensor, from the data sheet:-

Again the board the sensor is on might adjust the I2C lines to pull up to 5V which would damage a 3V3 processor.

So it might well not function on a 3V3 environment.

This illustrates the danger of buying stuff that you have no information on.

Hi, Grumpy_Mike,
Yes, I got the sensors from the same place.
I understand I am not using the sensors directly, I know I am using a breakout board with a VL6180x sensor on it. I also understand that the breakout board must regulate the voltage.

I think it was my mistake: I thought when we are using a breakout board that can be used with a 3.3v or a 5v Arduino, we can power it using either 3.3v or 5v regardless of the board. But I WAS SO WRONG, YOU ARE RIGHT, these breakout boards have a pull-resistor to Vin, so I think I damaged the I2C circuit on the board.

Well, I paid for my newbie mistake. :frowning_face: :frowning_face:

Thank you very much for all your help.

I got a new Arduino Mega 2560. All the sensors (breakout board) work fine with this board, so I guess this brand of breakout board don't work with 3.3v boards.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.