I keep getting a distance timeout error. This was discussed in github back in March and May with people having similar problems. Tried the fix but the code would not validate.
The default value for timeout is 2m but the sensors I’m using have a maximum of 4m. I’ve noticed that I have to include timeout: 4.0m or I’ll get time outs above any value greater than 2. Looks like you’re still using 2.0m in your config.
@SpikeyGG That is so incredible helpful for me. I was pulling my hair out wondering if I had a bad connection, poor power supply, and even went and ordered replacement ultransonic sensor before reading this. I added a distance timeout and now my sensor is working exactly as I wanted!
Put Timeout variable on more than 2 meters. timeout (Optional, float): The number of meters for the timeout. Most sensors can only sense up to 2 meters. Defaults to 2 meters.
Try also adding inverted: true to the definition of the trigger pin. Some sensors are leading-edge, some are trailing-edge.
Also, as mentioned previously, the timeout distance should be set near the published limit for the sensor device. Too short (or long) can also cause unexpected results.
I struggled for a year one week to get one of these working, and it turned out that the code is fine, but the cohesion with the device is low. I attribute that to poor documentation that came with the device(s) I saw. They don’t explain well enough the semantics of the signals, and worse, describe the timings very badly.
…just an addition to the discussion, prompted by the post above.
I was having the same timeout issue with a sensor in my garage. After changing the Timeout setting to “10m”, and increasing the "pulse time to 30us, I stopped getting timeouts, and I now have a continuous distance readout.
However I have another issue I have not been able to figure out. The actual measured distance the sensor should be returning is half of the “average” it is returning as measurements – seems the sensor is not “calibrated” properly ? Is there a way to calibrate, or alter the measurements like say dividing by 2 ?
here is a plot of what it looks like, notice, it all started looking good at about 9:40
EDIT: …duh, my bad. The reported distance from the sensor reflects the “over-and-back” distance the sound traveled, so it will be twice the actual distance to the object. However the variability still seems like quite a lot even so. Also found there is no way to “calibrate the sensor itself”. Code could be written within the “device” to do so, but at this point it is beyond my skills.