[SR04] fix mode 1 detection

Detection of sensors running in mode 1 fixed.
This commit is contained in:
SteWers 2022-02-17 19:16:24 +01:00 committed by GitHub
parent 06c33d34ef
commit bcf2bc5cf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,6 +136,7 @@ void Sr04TModeDetect(void) {
sonar_serial = nullptr;
}
sonar = new NewPing(sr04_trig_pin, sr04_echo_pin, SR04_MAX_SENSOR_DISTANCE);
delay(100); // give time to inizialise, preventing ping_median fails
if (!sonar || !sonar->ping_median(5)) {
SR04.type = SR04_MODE_NONE;
}