cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L4CD

eclemmon
Associate II

Hello!

I am using the VL53L4CD TOF Sensor as sold by Adafruit. I am running it with the circuit patched together as described in the example file VL53L4CD_Sat_HelloWorld.ino, also with the exact code (the only change being the port number). I am using an Arduino R4 WiFi. When I start the unit up, it runs normally for a bit (<1 min), and then stops.

Starting...
Status =   0, Distance =    37 mm, Signal =    232 kcps/spad
Status =   0, Distance =    38 mm, Signal =    234 kcps/spad
Status =   0, Distance =    35 mm, Signal =    233 kcps/spad
Status =   0, Distance =    36 mm, Signal =    230 kcps/spad
Status =   0, Distance =    39 mm, Signal =    236 kcps/spad
Status =   0, Distance =    35 mm, Signal =    234 kcps/spad
...

I have an Arduino R3 Uno, and tested the TOF sensor using that, and it seemed to run endlessly.

Based on reading around, I am guessing this has something to do with the resistors required for I2C connections and some builtin difference between the R4 WiFi and the R3 UNO, but I am not sure where I should start here.

Any help would be much appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Zhiyuan,

Thanks for the response. I had asked the same question over on the adafruit forums and got a response there that seems to have fixed the issue. It was not a power issue, but an I2C issue. Apparently the R4 WiFi defaults to a clock speed too fast for the I2C (400kHz), setting the clock speed to 100 kHz fixed the issue:

By adding this code to the top of the helloworld file, the sensor now runs seamlessly with this unit.

  Wire.begin();
  Wire.setClock(100000);      // << force 100 kHz

  Credit to mikeysklar for the easy solution.

View solution in original post

3 REPLIES 3
Zhiyuan.Han
ST Employee

Hi 

This is really an interesting issue, about the issue you are facing on Arduino R4 WiFi, could be HW issue, either power supply or I2C link issue. 

You can measure the power supply during your test to check if the power is stable.

about the I2C, you can measure the I2C signal with an oscilloscope, analyze the I2C signal compare with the I2C SPEC.

Hope this can help on your question. 

 

Br

Zhiyuan.Han


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.

Hi Zhiyuan,

Thanks for the response. I had asked the same question over on the adafruit forums and got a response there that seems to have fixed the issue. It was not a power issue, but an I2C issue. Apparently the R4 WiFi defaults to a clock speed too fast for the I2C (400kHz), setting the clock speed to 100 kHz fixed the issue:

By adding this code to the top of the helloworld file, the sensor now runs seamlessly with this unit.

  Wire.begin();
  Wire.setClock(100000);      // << force 100 kHz

  Credit to mikeysklar for the easy solution.

John_Kvam
Associate III

When the sensor, 'just stops', get out your voltage meter.

You either dropped power for a bit, dropped the XShut line, or noise glitched the I2C. 

Assuming the voltage is good, and the Xshut is fine, have a look at the I2C. 

Line-stuck-low is an absolutely classic symptom of an i2C error. It means there was a glitch on the line, which clocked a ghost bit, and now the sensor and the host are out of sync. The host can fix this by clocking a bunch of clocks, but it's best to just avoid the issue.

First thing to do is shorten the wires if you can. If you cannot, then thicker wires, twisted pair or god-forbid change the caps for stronger ones. 

if you have a scope, make sure the rises and falls are sharp without too much over or under shoot. 

And beef up the caps on your Xshut and power rails. That cannot hurt.  

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.