Skip to main content
Associate II
February 3, 2026
Question

error in vl53l8cx_check_data_ready

  • February 3, 2026
  • 1 reply
  • 223 views

 

I am currently trying to control a VL53L8CX sensor via SPI communication from the microcontroller mounted on a Crazyflie drone.

However, inside vl53l8cx_check_data_ready(), the values in temp_buffer became as follows. Indices [0] to [2] look correct, but at temp_buffer[3], the condition

 

 
((p_dev->temp_buffer[3] & (uint8_t)0x10) == (uint8_t)0x10)

evaluates to false.

What exactly is this comparison checking?

When temp_buffer[3] returns an incorrect value like this, which specific part of the communication or control process is likely failing?

  • temp_buffer[0]: 0x0
  • temp_buffer[1]: 0x5
  • temp_buffer[2]: 0xC5
  • temp_buffer[3]: 0xC1

1 reply

Associate
February 3, 2026

If your sensor is running the value in temp_buffer[0] will change. First frame it's 255 then it counts from 0 to 127, then repeats. A temp_buffer[0] being 0 looks wrong to me. 

I'm going to guess that you failed to start your sensor. 

Check the status of every call. There's lots of initialization and something went wrong. 

One thing you can do to verify the sensor is running is to look at the sensor with a camera. (Don't use a IPhone though. The IR filter is too good on that device.) You should see it either flashing or a constant 'on' depending on how you set up the mode. No light means it's not running. 

- john

 

 

"If this or any post solves your issue, please mark them as ""Accept as Solution"". It really helps the next guy.And if you notice anything wrong do not hesitate to ""Report Inappropriate Content"".I am a recently retired ST Employee. My former username was John E KVAM."
Associate II
February 5, 2026

Thenk you for your reply.

After executing vl53l8cx_is_alive, vl53l8cx_init, and vl53l8cx_set_ranging_frequency_hz, I called vl53l8cx_start_ranging. I confirmed that the sensor appears to start, because when I observed it with a PC camera, I saw a single IR flash.

I am also printing the return status of every API call, and so far I have not found any errors.

Are there any other possible causes you can think of for this issue?

Also, in vl53l8cx_check_data_ready(), what do temp_buffer[1] to temp_buffer[3] specifically represent?

Associate
February 5, 2026

To be honest I don't know what temp_buffer[1] to [3] mean. This being retired has it's issues.

But if you see a single flash and and then get a failure return that should be a clue. The sensor does a flash when it's first calibrating, and perhaps stopped after that for some reason. 

What was the return value from the check data ready call?

            status |= p_dev->temp_buffer[2];    /* Return GO2 error status */
And did you put that check in a loop and keep checking until you get a success?
The range takes about 30ms by default, and that's forever for your MCU.
Summarize the calls you made and the status you got from the check data ready call, and I'll force one of my old co-workers to have a look.
 
"If this or any post solves your issue, please mark them as ""Accept as Solution"". It really helps the next guy.And if you notice anything wrong do not hesitate to ""Report Inappropriate Content"".I am a recently retired ST Employee. My former username was John E KVAM."