hc sr04 sensor get stuck at zero.
Issue #3
resolved
The sensor get stuck at zero when aimed too far away or too close. It keeps listening in the echo pin for a pulse it will not get.
Comments (6)
-
repo owner -
repo owner - marked as trivial
- edited description
-
repo owner - edited description
-
repo owner - changed status to resolved
Not an issue with NewPing, defective sensor.
-
reporter I understand. Thank you for your fast reply. Your library is amazing. It has made my work a lot easier. Keep up the good work.
-
repo owner If you have a sensor that gets stuck like that, my suggestion is to only change the echo mode if the distance is zero. Something like this:
if (cm==0) { pinMode(echoPin, OUTPUT); digitalWrite(echoPin, LOW); pinMode(echoPin, INPUT); }
You may also need some type of delay in that IF statement. Doing this in the library wouldn't be ideal. So, if you do have a defective sensor that gets stuck at 0 adding something like this after each ping is probably the best solution (other than getting another sensor).
- Log in to comment
This is not an issue with NewPing. It's with a batch of defective sensors that's been going around. A properly working sensor doesn't get stuck when pointed out of range.