I’ve been trying to trigger this sensor every 10ms and it often results in a bunch of I2C errors. Some deeper investigation determined that at 10ms the ultrasonic pulse has only traveled ~3.4m (so it would have returned only of there was an object 1.7m away), so it’s likely that the device was still waiting for a previous echo to return when I triggered it again.
After unplugging the device and resetting the polling rate to 20ms it performs more smoothly but still occasionally locks up.
I’ve looked at the product page, but I haven’t found any docs explaining what the max polling rate is or if there’s any way to control the timeout. Are there SparkFun employees on this forum who might be able to provide the answers?
Relevant product page: https://www.sparkfun.com/sparkfun-ultrasonic-distance-sensor-tct40-qwiic.html
If you’d be so kind, I’d also like to know exactly how “triggerAndRead” works, because it seems to return instantly, but as demonstrated above it takes some ms for a pulse to return so clearly there’s something going on under the hood. Is the device continuously polling and just returning the last known value?