[SOLVED] distance sensor VL6180

acronis
Tue Jun 27, 2017 7:05 am
Hello. Tell me which library is better to use and how to physically connect STM32F103 distance sensor VL6180 https://ru.aliexpress.com/item/1PCS-VL6 … 0.0.t4kPJc

zoomx
Tue Jun 27, 2017 7:17 am
mmmm I bought a VL53L0X and used the first library I found, maybe these sensors use the same protocol.

acronis
Tue Jun 27, 2017 8:20 am
How to connect the PIN SCL and SDA VL6180 Breakout to the STM32F103?
They are tolerant only to 2.8 V

https://cdn.sparkfun.com/datasheets/Sen … ut_v10.pdf

https://learn.sparkfun.com/tutorials/vl … okup-guide


zoomx
Tue Jun 27, 2017 10:51 am
If you have only the sensor you have to build a circuit similar to the sparkfun one.
For example this one
Image
Wiring Diagram for VL6180 Breakout and 3.3v Pro-Mini
that you can find in the second link of your first post.

Since the promini is the 3.3V version, values are the same for the STM32 board


acronis
Tue Jun 27, 2017 2:08 pm
NOTE: To use this diagram make sure the two pull-up resistors on the Pro-Mini are NOT populated.

such a connection possible if not soldered the resistors on the PRO MINI.
And how it on STM32 ?


stevestrong
Tue Jun 27, 2017 2:24 pm
Which STM32 board do you use?
In general, on STM32 boards there are no resistors mounted on non-reserved IO pins.

acronis
Tue Jun 27, 2017 2:36 pm
https://ru.aliexpress.com/item/2-STM32F … 0.0.D46SwF

I’m doing a direct connection of pins SCL and SDA ? but what about the maximum voltage 2,8 V ?


stevestrong
Tue Jun 27, 2017 3:13 pm
[acronis – Tue Jun 27, 2017 2:36 pm] –
I’m doing a direct connection of pins SCL and SDA ?

Yes.

BreakoutAnnotated[1].png
BreakoutAnnotated[1].png (189.96 KiB) Viewed 1041 times

RogerClark
Tue Jun 27, 2017 9:41 pm
How much current does it take?

Perhaps you can drop 3.3v to 2.7 with 2 diodes in series


acronis
Thu Jul 13, 2017 5:28 am
https://github.com/adafruit/Adafruit_VL6180X

This library works fine on STM32.


RogerClark
Thu Jul 13, 2017 6:34 am
Thanks for letting us know.

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


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
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
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:
#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);
}


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
Wed Dec 06, 2017 3:10 pm
[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.

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
Thu Dec 07, 2017 9:23 am
Have you tried to insert the line as I indicated above?

FiveO
Thu Dec 07, 2017 12:16 pm
[stevestrong – 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


Leave a Reply

Your email address will not be published. Required fields are marked *