I want it to measure distance but i can't because duration is 0 Please Help me(Board: Arduino MKR 1010 Wifi with MKR Carrier Explore IOT Kit)(Use on IOT Cloud)
Please READ the documentation on the pulseLn() function call. It always returns ZERO when the time-out occurs! Since you did not specify a time-out value, one second is used by default.
Did you read the pulseLn() documentation to see why zero is returned? It is returned because the pulse has not ended by the time the time-out period has occurred. That is caused by the device not detecting an echo return for ANY reason!
this is correct, but which reason it might be?
1 distance was too large for this particular setting of timeout, default 1000000µs is travel of 343m;
2 it was no trigger signal at all, for any reason;
3 trigger signal is too weak and/or absorbed on obstacles.
do i forget something?
Yes, you did. The object MUST be able to reflect the sound pulse back to the sensor. Using a pencil or a blanket, or your hand or any other soft material could be the reason. Or the reflection is NOT directly back to the sensor.