cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L0X_PerformOffsetCalibration program example

Iknig.1
Associate II

Hello,

Well i have read the documentation on the VL53L0X and it is a clear as MUD with respect to the usage of the function VL53L0X_PerformOffsetCalibration how to use it and why i should use it. I thought these devices where factory calibrated, but i have four of them, three are ok but one is way off by some 100mm at test distance of 100mm eg reads 200mm. So i am wondering if ST or anyone has a VL53L0X Calibration program example they would like to share please. Or do i simple measure what it returns under normal read working and add or subtract to error in my application Many thanks imk

2 REPLIES 2
John E KVAM
ST Employee

STSW-IMG005 - VL53L0X API (Application Programming Interface and documentation)

When you reflowed your sensor onto the PCB there is the possibility that the factory offset calibration changed..

In the software API downloadable from ST.com, there is an offset calibration function.

You can just call that.

Or if you want to roll your own it's not difficult.

Just range on a nice white target at 140mm (or 100, or 200) It doesn't matter too much. But you need to know the exact distance.

Then range a bunch of times and get the difference between the exact distance and the measured range.

This is your offset.

There is a register where you can put this data, so the results you get have that offset applied.

Or you can do the subtraction yourself.

But if you let the sensor do it, and you use interrupt thresholds the offset will be applied before the threshold is calculated.

  • 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.
Iknig.1
Associate II

Hello John and many thanks for your reply.

After a bit of experimentation i have come up with a nice solution that gives good accuracy over a wide range.

Take a sample every 0.1s in continuous mode, then take the rolling average of five sample and use the https://www.arduino.cc/reference/en/language/functions/math/map/

function, haven made two calibration data sets at 100mm and 300mm.

This results is a range of good accuracy between 20mm to 500mm

I have a little more experimenting to do.

Again Many thanks imk