Skip to main content
Associate II
April 29, 2024
Solved

ID Register to differentiate VL53L0x, VL53L1x, etc

  • April 29, 2024
  • 3 replies
  • 2080 views

Hello!

 

I am working on a project where I would like to be able to detect which type of sensor I have connected (via I2C). For example, I am currentky planning on using a VL53L0x, but would like to be able to detect on boot if I am still using the VL53L0x or have switched to a VL53L1Cx, etc. I recognize that the initialization and read processes are a bit different, and would simply set a flag so I know which to call. Basically, I would like to be able to swap sensors in the field and be able to detect those changes. Is there any sort of ID Register? Is there a different way? I looked through the VL53L0x data sheet but did not find any mention of anything like this. Thanks!

This topic has been closed for replies.
Best answer by John E KVAM

It can. 

Basically, these sensors have two parts - the ranging bit and the I2C communication bit. 

You power them up and read the Id registers. 

When you decide which one you are taking to, just initialize it. 

There is a small issue though...

The L0 has an 8-bit register addressing scheme with page register. 

The L1, L3 and L4s all have 16-bit register addresses. 

That might be a small issue you have to work out. 

If you issue a read with an 8-bit address, and the sensor expects 16 bits, it will just hang - I think. 

After a time out, if you get nothing, reset the sensor and try a different one.

- john

3 replies

Peter BENSCH
Technical Moderator
April 29, 2024

Welcome @mttdarko, to the community!

Maybe a check of the registers help, if you try to read and act accordingly:

  • VL53L0X_REG_IDENTIFICATION_MODEL_ID
  • VL53L1_IDENTIFICATION__MODEL_ID

You can find out how to access these registers in the respective API.

Hope that helps?

Regards
/Peter

mttdarkoAuthor
Associate II
April 29, 2024

Thanks for the suggestion! Can this be done before the sensor is initialized? Basically I am trying to avoid calling the initialization function for the wrong sensor and locking my microcontroller up.

Peter BENSCH
Technical Moderator
April 29, 2024

Maybe, let's ask our specialist @John E KVAM.

 

John E KVAM
John E KVAMBest answer
ST Employee
April 29, 2024

It can. 

Basically, these sensors have two parts - the ranging bit and the I2C communication bit. 

You power them up and read the Id registers. 

When you decide which one you are taking to, just initialize it. 

There is a small issue though...

The L0 has an 8-bit register addressing scheme with page register. 

The L1, L3 and L4s all have 16-bit register addresses. 

That might be a small issue you have to work out. 

If you issue a read with an 8-bit address, and the sensor expects 16 bits, it will just hang - I think. 

After a time out, if you get nothing, reset the sensor and try a different one.

- john