cancel
Showing results for 
Search instead for 
Did you mean: 

VL6180X range measurement issue

MChla.1
Associate

Hello,

I have following issue.

For distance 0 mm - 60 mm the result of range measurement is always the same (0x20)

step by step code:

GPIO0 set High.

Range measurement start: write 1 to reg 0x0018

Wait 100ms

Read range status: read register 0x004D

Read range value: read resiter 0x0062

Range status is: 0x03

Range value is: 0x20

I tried to use as target white paper, black plastic and hand. The result is still the same.

I tried to change range offset (register 0x0024). Range value changes after offset change but again is constant for distance 0mm - 60mm.

Light conditions are regular office light.

Could you please help me solve this issue?

Thanks,

Mila

2 REPLIES 2
John E KVAM
ST Employee

It is impossible that the sensor will return the same number several times in a row. It's not that accurate.

So my guess is it's not running. Do you see the sensor light on?

850nm light is visable - but just barely. Use a cell phone camera.

There is a API available, and even if you don't use it, it's a handy reference.

VL6180X API (Application Programming Interface and Documentation)

https://www.st.com/content/st_com/en/products/embedded-software/proximity-sensors-software/stsw-img003.html

Reading register 4D tells you the condition of the last range, but that will not get updated until the next range is complete.

Check register 4F - basically the 'done' bit.

I have a guess though.

You brought the device out of reset and immediately set the start bit.

But your MCU is a lot faster than the sensor is.

Give the sensor one or two ms to boot, then tell the device to range. (I think it only takes 400usec, but a couple of ms is double safe.)

Or, to tell if the device is booted and you are communicating correctly, read the device ID at register 0.

Then tell it to start.

  • john

If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
MChla.1
Associate

Hi John,

thank you for promt response.

The issue was I did not apply tuning setting after each boot.

I found this information in application note: VL6180X range and ambient light sensor quick setup guide.

Now everything works perfectly.

Thanks,

Mila