[SOLVED] distance sensor VL6180

Please do not post requests
User avatar
RogerClark
Posts: 7498
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: distance sensor VL6180 [SOLVED]

Post by RogerClark » Thu Jul 13, 2017 6:34 am

Thanks for letting us know.

User avatar
RogerClark
Posts: 7498
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: distance sensor VL6180 [SOLVED]

Post by RogerClark » Sat Jul 15, 2017 11:17 am

Umm

My sensor is a VL53L0XV2 and doesnt seem to work with that lib :-(

I will try this lib

https://github.com/pololu/vl53l0x-arduino

Edit.
That lib didnt compile, I probably need to add some functions to Wire as the compiler didnt know how to handle a Wire.write being passed a 32 bit int

I did quick hack in the library but it only seems to work for values < 1024

Also I don't get any value below 45.

And I don't think the number the lib is outputting is mm

User avatar
zoomx
Posts: 541
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: distance sensor VL6180 [SOLVED]

Post by zoomx » Fri Aug 04, 2017 7:51 pm

I checked the Adafruit library
https://github.com/adafruit/Adafruit_VL53L0X
and loaded the only one example: it compiles.

I used a core that has some months, 8 April 2017.

Since there is a thread about VL53L0X I posted there too.

FiveO
Posts: 14
Joined: Mon Oct 16, 2017 6:41 am

Re: [SOLVED] distance sensor VL6180

Post by FiveO » Tue Dec 05, 2017 9:32 am

Hi

How do You got VL6180 working with Adafruit? I am using stm32f103 "Bluebill" with ST-Link. I know it compiles, but in the setup there is vl.begin(). If I delete this my other code works, if I don't nothing works (blink test and ssd1306 oled). If I tested with oled, then in setup oled code works until vl.begin() is called, after that oled freezes.

FiveO
Posts: 14
Joined: Mon Oct 16, 2017 6:41 am

Re: [SOLVED] distance sensor VL6180

Post by FiveO » Wed Dec 06, 2017 12:13 pm

I think the problem is my Bluepill. I made another tests:

STM32F103, uploaded with ST-Link, Serial monitor over usb - 893 counts(72Mhz), 882 counts(48Mhz)
Arduino Nano, uploaded with usb, Serial monitor over usb - 980 counts
Arduino Mega, uploaded with usb, Serial monitor over usb - 1033 counts

VL6180 sensor is 30mm away from black surface
test code:

Code: Select all

#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() {
  unsigned long startCounting = millis();
  int count = 0;

  while (millis() - startCounting <= 10000)
  {
    if (vl.readRange())
    {
      count++;
    }
  }
  Serial.println(count);
}
My Bluepill is slow and hangs time after time.

stevestrong
Posts: 1837
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [SOLVED] distance sensor VL6180

Post by stevestrong » Wed Dec 06, 2017 12:58 pm

It may be an issue with the Adafruit lib.
It seems that in function read8() line 246 is missing a Wire.available() check which is there in function read16() line 267.
So it may happen that readRange() returns an invalid value 0 (before any data is received from the sensor), that is why your sketch is not counting.
This could also explain why different platform gives different results, because each of them runs with different speed.
F1 seems can be the quickest, so it misses the most bytes.

FiveO
Posts: 14
Joined: Mon Oct 16, 2017 6:41 am

Re: [SOLVED] distance sensor VL6180

Post by FiveO » Wed Dec 06, 2017 3:10 pm

stevestrong wrote:
Wed Dec 06, 2017 12:58 pm
It may be an issue with the Adafruit lib.
It seems that in function read8() line 246 is missing a Wire.available() check which is there in function read16() line 267.
So it may happen that readRange() returns an invalid value 0 (before any data is received from the sensor), that is why your sketch is not counting.
This could also explain why different platform gives different results, because each of them runs with different speed.
F1 seems can be the quickest, so it misses the most bytes.
I also tested F4. The VL6180 works with STM32GENERIC PB6 and PB7

STM32F407, uploaded with ST-Link, Serial monitor over usb - 898 counts

I bought these stm32 units for quicker sensor reading :D . But my main problem will be running vl6180 and ssd1306 oled together and I can't get them to work together. I will try this tomorrow on F4.

stevestrong
Posts: 1837
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [SOLVED] distance sensor VL6180

Post by stevestrong » Thu Dec 07, 2017 9:23 am

Have you tried to insert the line as I indicated above?

FiveO
Posts: 14
Joined: Mon Oct 16, 2017 6:41 am

Re: [SOLVED] distance sensor VL6180

Post by FiveO » Thu Dec 07, 2017 12:16 pm

stevestrong wrote:
Thu Dec 07, 2017 9:23 am
Have you tried to insert the line as I indicated above?
Yes, and it didn't make a change

Post Reply