2024-04-29 06:29 AM - last edited on 2024-04-29 10:33 AM by Peter BENSCH
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!
Solved! Go to Solution.
2024-04-29 10:53 AM
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
2024-04-29 09:46 AM
Welcome @mttdarko, to the community!
Maybe a check of the registers help, if you try to read and act accordingly:
You can find out how to access these registers in the respective API.
Hope that helps?
Regards
/Peter
2024-04-29 10:24 AM
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.
2024-04-29 10:35 AM - edited 2024-04-29 10:35 AM
Maybe, let's ask our specialist @John E KVAM.
2024-04-29 10:53 AM
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