Distance measurement, multiple VL6180X with TCA9548a multiplexer

Resurrecting an unstarted project...... I want to measure the volume of bread dough in a 3 litre plastic container and monitor the increase in volume as the dough rises over a period of hours.

The plan is to fix 8 off VL6180X ToF sensor into the lid of the container and point them downwards to measure the height of the dough surface.

The surface can be bumpy and uneven, hence the plan to use 8 sensors. I would take an average of the 8 readings, do some offset tweaks and then ideally put the value into a lookup table of height v volume to display dough volume using a Nano and LCD display.

Since my programming knowledge would fit on the back of a postage stamp, I was hoping there would be some ready made example sketches of multiple VL6180X with multiplexer to get me started, but I have found none. I found one with VL53L0X, but that didn't work, because apparently the api is different.

So any help on coding my project would be much appreciated. I already have the sensors and other hardware, so I'm not looking at alternative solutions.

Lance

Have you been able to get one sensor working without the mux?

If so, it should be pretty straightforward to transplant the VL6180X code into the mux sketch that you found.

first off, WHICH VL6180X ? the Adafruit, Pololu ? generic AliExpress ?

at a quick glance of the data sheet, it seems the I2C address is fixed.
device address of 0x52.

There is some discussion on how to change the address.

https://learn.sparkfun.com/tutorials/vl6180-hookup-guide/discuss

you could also get a couple I2C expander [multiplexor] boards that allows you to read up to 4 I2C devices that share the same address : TCA9548A I2C Multiplexer

or you can put each chip on a separate GPIO pin, if you have spares.

Have you been able to get one sensor working without the mux?

Thanks - yes I did get that far. I’ll have a look along those lines. This was the VL53L0X example I found.

albacore:
Have you been able to get one sensor working without the mux?

Thanks - yes I did get that far. I'll have a look along those lines. This was the

VL53L0X example

I found.

do you have that multiplexer connected ?
the multiplexer is independent of the chip used, so you don't have to use the code from a different sensor.
if you have read how to use 'code tags' then post your code

dave-in-nj:
do you have that multiplexer connected ?
the multiplexer is independent of the chip used, so you don't have to use the code from a different sensor.
if you have read how to use 'code tags' then post your code

The problem is that I don't have any code! There are several sketches available for single VL6180x sensors, but I can't find any for multiplexed ones - only the one for VL53L0X that I linked to.
I did also find this example (German text), but it seems to be specific for ESP32 and doesn't work with nano - some error about Twowire...
BTW, you asked about sensors, they are the cheapo AliExpress versions.
Lance

you posted that you were able to get one unit to work.
you did not post what library you used. but it would be for the VX6180, not the VX53

the multiplexor code you linked uses the VX53 library, so the task is to take the multiplexor bits and keep them,
then take the VC53 bits and replace them with the VX6180 bits.

so, post the code you do have that you were able to read one distance.

dave-in-nj:
you posted that you were able to get one unit to work.

so, post the code you do have that you were able to read one distance.

Here is one working example from Adafruit using the Adafruit sensor library. It’s very simple, but does prove that I have a working sensor. It includes lux, which I am not interested in.

#include <Wire.h>
#include "Adafruit_VL6180X.h"

Adafruit_VL6180X vl = Adafruit_VL6180X();

void setup() {
  Serial.begin(115200);

  // wait for serial port to open on native usb devices
  while (!Serial) {
    delay(1);
  }

  Serial.println("Adafruit VL6180x test!");
  if (! vl.begin()) {
    Serial.println("Failed to find sensor");
    while (1);
  }
  Serial.println("Sensor found!");
}

void loop() {
  float lux = vl.readLux(VL6180X_ALS_GAIN_5);

  Serial.print("Lux: "); Serial.println(lux);

  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  if (status == VL6180X_ERROR_NONE) {
    Serial.print("Range: "); Serial.println(range);
  }

  // Some error occurred, print it out!

  if  ((status >= VL6180X_ERROR_SYSERR_1) && (status <= VL6180X_ERROR_SYSERR_5)) {
    Serial.println("System error");
  }
  else if (status == VL6180X_ERROR_ECEFAIL) {
    Serial.println("ECE failure");
  }
  else if (status == VL6180X_ERROR_NOCONVERGE) {
    Serial.println("No convergence");
  }
  else if (status == VL6180X_ERROR_RANGEIGNORE) {
    Serial.println("Ignoring range");
  }
  else if (status == VL6180X_ERROR_SNR) {
    Serial.println("Signal/Noise error");
  }
  else if (status == VL6180X_ERROR_RAWUFLOW) {
    Serial.println("Raw reading underflow");
  }
  else if (status == VL6180X_ERROR_RAWOFLOW) {
    Serial.println("Raw reading overflow");
  }
  else if (status == VL6180X_ERROR_RANGEUFLOW) {
    Serial.println("Range reading underflow");
  }
  else if (status == VL6180X_ERROR_RANGEOFLOW) {
    Serial.println("Range reading overflow");
  }
  delay(500);
}

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