2024-11-18 01:00 AM
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?
Solved! Go to Solution.
2024-11-20 10:45 PM
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.
2024-11-18 07:09 AM
UM2356: VL53L1X API user manual | User Manual | VL53L1X | 3 | ||
UM2510: A guide to using the VL53L1X ultra lite driver |
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
2024-11-18 08:52 AM
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?
2024-11-19 07:18 AM
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.
Running that will log ALL the data you can get from the sensor and will surely tell you what is wrong.
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.
2024-11-20 02:12 AM
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
2024-11-20 09:54 AM
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
2024-11-20 10:48 AM
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?
2024-11-20 11:20 AM
While there are 256 SPADs some are deliberately occluded. When the signal is extremely close and reflective, we need to cut the signal way down. for that we use those mostly covered SPADs.
So, 205 is about the max. Oddly every sensor is very slightly different. We allow some variability.
So let us discuss the one issue. "I didn't buy the evaluation kit."
that eval kit is $56 at Digikey or Mouser.
And I'm thinking the eval kit is going to save you way more than that.
For one, you can easily adjust parameters and get out a lot of raw data.
And using that software you cannot have an invalid configuration.
So, we can prove if it's your environment, or if it's your configuration.
I'd buy the P-Nucleo-53L1A2. It's officially for the VL53L1CB, but you can run the VL53L1X code on it.
And tell me where you got your software. That's not from the ST website is it?
- john
2024-11-20 11:59 AM
It’s actually from the STM website. I used the bare driver version: 2.4.5 (STSW-IMG007). Adjusted the vl53l1_platform.c The code runs on a ESP32.
I will have a serious look at it. Which STM32 Nucleo board is preferable?
2024-11-20 03:05 PM
Interesting. I've used the Ultra-lite version of that driver (STSW-IMG009) so often I'd forgotten what version the 007 was on.
Should be just fine though.
The P-Nucleo-53L1A1 is the sensor and the NucleoF401RE together. That and a mini-USB cable is all you need. Download the code from ST.com and you are all set.
Just for the heck of it, can you try that same experiment late in the day - or early in the morn.
I cannot imagine why you are getting less than 2Meters. In ideal conditions one can get 4M. 2 should be easy to a whitish ceiling. Something is very odd.
- john