Skip to main content
Associate
November 18, 2024
Solved

VL53L1 accurate up to 40cm max

  • November 18, 2024
  • 3 replies
  • 3416 views

I hope someone can help me with the accuracy of my VL53L1 sensor. I can’t get the sensor working accurately above 40cm. 
I am working on a hobby project and want to use the sensor to avoid obstacles. 
The board I use is not an VL53L1-SATEL. It’s from an other manufacturer. I tried different api’s. The most recent full api and the ULD from ST. I even tried the Adafruit api for this sensor. All the api’s are producing more or less the same results. 

Is there something I could test to figure out what’s going on?

 

Best answer by janvdsar

Hi John,

 

@7:20 AM European time

 

VL53L1_DISTANCEMODE_SHORT

 

Distance: 1233 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.19 SigmaMilliMeter: 4.75 AmbientRateRtnMegaCps: 0.06

Distance: 1228 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 4.50 AmbientRateRtnMegaCps: 0.05

Distance: 1222 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 4.75 AmbientRateRtnMegaCps: 0.06

Distance: 1234 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 4.75 AmbientRateRtnMegaCps: 0.06

Distance: 1223 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 4.50 AmbientRateRtnMegaCps: 0.05

Distance: 1213 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 5.00 AmbientRateRtnMegaCps: 0.06

Distance: 1224 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.18 SigmaMilliMeter: 5.25 AmbientRateRtnMegaCps: 0.06

Distance: 1220 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 4.75 AmbientRateRtnMegaCps: 0.06

Distance: 1209 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 4.25 AmbientRateRtnMegaCps: 0.05

Distance: 1225 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 4.50 AmbientRateRtnMegaCps: 0.05

Distance: 1222 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 4.50 AmbientRateRtnMegaCps: 0.05

Distance: 1225 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 4.75 AmbientRateRtnMegaCps: 0.05

Distance: 1226 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 5.00 AmbientRateRtnMegaCps: 0.06

Distance: 1225 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 4.50 AmbientRateRtnMegaCps: 0.05

 

VL53L1_DISTANCEMODE_MEDIUM

 

Distance: 1229 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 4.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 5.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.19 SigmaMilliMeter: 6.25 AmbientRateRtnMegaCps: 0.06

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.06

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 5.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.24 SigmaMilliMeter: 5.00 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 5.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 5.25 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 5.75 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 5.75 AmbientRateRtnMegaCps: 0.06

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 5.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 5.75 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.06

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 5.25 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 5.25 AmbientRateRtnMegaCps: 0.05

 

VL53L1_DISTANCEMODE_LONG

 

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 5.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 6.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 6.25 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.19 SigmaMilliMeter: 7.25 AmbientRateRtnMegaCps: 0.06

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 6.75 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 6.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 6.25 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.05

Distance: 1132 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.26 SigmaMilliMeter: 5.50 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 6.00 AmbientRateRtnMegaCps: 0.05

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 6.50 AmbientRateRtnMegaCps: 0.05

Distance: 1035 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 6.50 AmbientRateRtnMegaCps: 0.05

 

At least the ambient value is smaller than the signal value

 

Sometimes I get the following error:

Distance: -1185 Status: (5) Hardware Fail

Disconnecting the USB cable doesn't help.

Disconnecting the power to the sensor while the MCU is running solves the problem.

 

This is a snippet of the init code:

 

ret = VL53L1_WaitDeviceBooted(Dev);

if (ret != ESP_OK) {

ESP_LOGE(TAG, "%s",esp_err_to_name(ret));

return ret;

}

 

ret = VL53L1_DataInit(Dev);

if (ret != ESP_OK) {

ESP_LOGE(TAG, "%s",esp_err_to_name(ret));

return ret;

}

 

ret = VL53L1_StaticInit(Dev);

if (ret != ESP_OK) {

ESP_LOGE(TAG, "%s",esp_err_to_name(ret));

return ret;

}

 

I have never had this problem before with the vl53l0x.

 

3 replies

John E KVAM
ST Employee
November 18, 2024

Here are 2 documents you can find on ST.com.

The trick is to read about calibration. 

There are 2 kinds. 

Offset - every measurement is wrong by the same amount. 

Range on a known distance a lot, find the difference, put it in the offset register at boot. 

Crosstalk - near measurements look OK, but get worse as the distance increases. 

If you have a coverglass, then you need to know how many photons hit that glass and return immediately. 

if you have a million photons bouncing off the glass, and 20Million off your target, you will only be off a little when you average those times. 

But if you have a million from your glass and a half million from your target you will under range by a lot.

Crosstalk calibration determines the number of zero-distance photons you have by ranging on a target that is 10 - 20% under its true distance. By knowing the true distance, the measured distance and the number or total photons, the crosstalk calibration works out the number of zero-distance photons. 

If you actually bought the VL53L1CB, I'd run it in L1X mode. You only need 40cm and the L1X mode is a lot easier - and smaller. 

(Calibration applies to both however.)

- john

 

janvdsarAuthor
Associate
November 18, 2024

Hi John, thanks for your reply.

How can I figure out which type I have?

If I pass the 40cm the range status is not equal to zero and the range is all over the place. I need the sensor to read far beyond the 40 cm. 
I don’t use a cover glass. 
Increasing the timing budget to 500ms doesn’t solve the problem. 
At the moment I’m not worried about the offset calibration. Crosstalk is zero by default. 
Is there something else I can check?

 

John E KVAM
ST Employee
November 19, 2024

If you have a long integration time, and your distances are "all over the place" then you either have motion or you have a very complicated scene. 

  • Did you buy the P-Nucleo-53L1A2 evaluation kit? 

Running that will log ALL the data you can get from the sensor and will surely tell you what is wrong. 

  • Are you near a window, where the sunlight is coming in? A high ambient can limit your distance and affect the accuracy. 
  • If you don't have the eval kit, you can still get and print out all the return data. Status, distance, signal strength, sigma, and ambient are all useful clues

No coverglass ==> no crosstalk. So that is easy. 

If all your measurements were 1 or 2 cm short or long, you would use the offset correction.

But first we have to get consistent numbers. Point your sensor up at a flat ceiling. Does that number look right - and consistent? Try it without sunlight!!  

If you want the best long distance single zone sensor, it's the VL53L1CB. It uses something called histograms to allow your MCU to dig out the best number. (As a test you can download the VL53L1CB code and run it on your VL53L1X - don't go into production like this, but for testing it's ok.)

No matter which version you use take the data - and a picture of your scene. 

Then I'll have a better idea of what is going on. 

Note that the FoV is a 27 degree cone, you get the average of that distance. 

 

janvdsarAuthor
Associate
November 20, 2024

To answer your questions:

I didn't buy the evaluation kit

There is absolutely no sunlight coming in. We have a rainy day.

 

Using bare driver version: 2.4.5

I took 2 different measurements. Short and Long distance mode:

Name: VL53L1 cut1.1

Type: VL53L1

ProductId:

ProductType: cc

ProductRevisionMajor: 1

ProductRevisionMinor: 1

 

MeasurementTimingBudgetMicroSeconds: 500000

inter_measurement_period_ms: 505

 

VL53L1_DISTANCEMODE_LONG

 

Distance: 603 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 26.25 AmbientRateRtnMegaCps: 0.48

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 27.75 AmbientRateRtnMegaCps: 0.48

Distance: 1163 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.29 SigmaMilliMeter: 16.50 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.15 SigmaMilliMeter: 43.50 AmbientRateRtnMegaCps: 0.48

Distance: 1186 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.18 SigmaMilliMeter: 33.00 AmbientRateRtnMegaCps: 0.48

Distance: 1219 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 29.75 AmbientRateRtnMegaCps: 0.48

Distance: 1205 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.26 SigmaMilliMeter: 19.50 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 28.00 AmbientRateRtnMegaCps: 0.48

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.25 SigmaMilliMeter: 20.25 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.09 SigmaMilliMeter: 88.00 AmbientRateRtnMegaCps: 0.48

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.25 SigmaMilliMeter: 20.25 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 23.50 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.16 SigmaMilliMeter: 40.75 AmbientRateRtnMegaCps: 0.48

Distance: 875 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 25.75 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.12 SigmaMilliMeter: 62.25 AmbientRateRtnMegaCps: 0.48

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 29.50 AmbientRateRtnMegaCps: 0.48

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 26.25 AmbientRateRtnMegaCps: 0.48

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.30 SigmaMilliMeter: 15.50 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.28 SigmaMilliMeter: 17.00 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 22.25 AmbientRateRtnMegaCps: 0.47

Distance: 1030 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.25 SigmaMilliMeter: 20.50 AmbientRateRtnMegaCps: 0.47

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 23.75 AmbientRateRtnMegaCps: 0.48

Distance: 1067 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.16 SigmaMilliMeter: 41.25 AmbientRateRtnMegaCps: 0.48

 

VL53L1_DISTANCEMODE_SHORT

 

Distance: 1229 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.18 SigmaMilliMeter: 28.25 AmbientRateRtnMegaCps: 0.58

Distance: 1176 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.19 SigmaMilliMeter: 26.50 AmbientRateRtnMegaCps: 0.57

Distance: 1216 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.19 SigmaMilliMeter: 26.50 AmbientRateRtnMegaCps: 0.58

Distance: 1199 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 25.00 AmbientRateRtnMegaCps: 0.58

Distance: 1204 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 19.00 AmbientRateRtnMegaCps: 0.57

Distance: 1222 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.16 SigmaMilliMeter: 35.25 AmbientRateRtnMegaCps: 0.59

Distance: 1169 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 25.00 AmbientRateRtnMegaCps: 0.58

Distance: 1169 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 25.00 AmbientRateRtnMegaCps: 0.58

Distance: 1200 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 18.75 AmbientRateRtnMegaCps: 0.57

Distance: 1205 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.27 SigmaMilliMeter: 15.75 AmbientRateRtnMegaCps: 0.57

Distance: 1172 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.23 SigmaMilliMeter: 20.25 AmbientRateRtnMegaCps: 0.58

Distance: 1193 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 21.25 AmbientRateRtnMegaCps: 0.58

Distance: 1205 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.18 SigmaMilliMeter: 29.00 AmbientRateRtnMegaCps: 0.59

Distance: 1223 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.19 SigmaMilliMeter: 27.25 AmbientRateRtnMegaCps: 0.59

Distance: 1203 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 23.50 AmbientRateRtnMegaCps: 0.58

Distance: 1191 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 21.25 AmbientRateRtnMegaCps: 0.58

Distance: 1194 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 23.00 AmbientRateRtnMegaCps: 0.59

Distance: 1200 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 21.50 AmbientRateRtnMegaCps: 0.58

Distance: 1189 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.22 SigmaMilliMeter: 21.25 AmbientRateRtnMegaCps: 0.58

Distance: 1214 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 25.25 AmbientRateRtnMegaCps: 0.59

Distance: 1235 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 25.75 AmbientRateRtnMegaCps: 0.59

Distance: 1200 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.21 SigmaMilliMeter: 22.75 AmbientRateRtnMegaCps: 0.59

Distance: 1204 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.17 SigmaMilliMeter: 30.75 AmbientRateRtnMegaCps: 0.59

 

 

John E KVAM
ST Employee
November 20, 2024

That status tells you everything that's going wrong. 

Status 2 - is lack of signal. Not enough light is coming back to give you a good range. In all your 'short' ranges the signal is below 0.5 so you get the error. Your distance is probably right - but inaccurate due to lack of signal

Status 4 - phase fail - In order to detect 'Radar aliasing' sometimes called 'wrap around' we use two different pulse repetition intervals. And they should give the same result. they are not. This can happen when the target it too far away. Short means you can only go to 1.3meters - after that you get a wrap error.

Sigma - We attempt to give you the standard deviation of your range 30mm is too high. It means, roughly that the right answer is 1204 +/- 30mm. And although that might be true, it's getting pretty iffy. 

You tried both short and long. We find the best results are with medium. 

In short mode, the pulses are closer together (we don't have to wait as long for the light to return) so you get more pulses, therefore more signal. 

You need more SPADS. 

and ambient IS an issue - even on a rainy day. Notice in your last line you got a signal of 0.17 and an ambient of 0.59. Meaning the ambient light is 3 times larger then the signal. That makes accuracy really difficult. 

Distance: 1204 Status: (2) Signal Fail SignalRateRtnMegaCps: 0.17 SigmaMilliMeter: 30.75 AmbientRateRtnMegaCps: 0.59

 

janvdsarAuthor
Associate
November 20, 2024

Hi John,

I tried the medium range. Strangely enough medium gives the folowing:

Distance: 0 Status: (4) Phase Fail SignalRateRtnMegaCps: 0.20 SigmaMilliMeter: 9.25 AmbientRateRtnMegaCps: 0.16

I found out that the ceiling is +/- 160cm from the sensor.

The VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 register gives 205. That's 51 SPADs short?

janvdsarAuthor
Associate
November 29, 2024

I call it quits. Whatever I try. The sensor will not give an accurate reading beyond 40cm. I guess that the sensor is faulty or maybe a Chinese clone. 
John, thank you so much for your time en information. I will order the development board and see how that will work out for me.