2025-08-19 2:24 PM
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!
Solved! Go to Solution.
2025-08-20 9:04 AM
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.
2025-08-20 4:04 AM
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
2025-08-20 9:04 AM
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.
2025-08-21 10:18 AM
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.