cancel
Showing results for 
Search instead for 
Did you mean: 

ID Register to differentiate VL53L0x, VL53L1x, etc

mttdarko
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
John E KVAM
ST Employee

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


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.

View solution in original post

4 REPLIES 4
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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
ST Employee

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

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
John E KVAM
ST Employee

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


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.