|
@@ -48,7 +48,8 @@ float UltraSonicDistanceSensor::measureDistanceCm(float temperature, float humid
|
|
|
// Measure the length of echo signal, which is equal to the time needed for sound to go there and back.
|
|
// Measure the length of echo signal, which is equal to the time needed for sound to go there and back.
|
|
|
unsigned long durationMicroSec = pulseIn(echoPin, HIGH, maxDistanceDurationMicroSec); // can't measure beyond max distance
|
|
unsigned long durationMicroSec = pulseIn(echoPin, HIGH, maxDistanceDurationMicroSec); // can't measure beyond max distance
|
|
|
|
|
|
|
|
- time_t t_diff = 60 - (millis() - t0);
|
|
|
|
|
|
|
+ // Wait at least 60 ms (datasheet value)
|
|
|
|
|
+ time_t t_diff = HCSR04_MEASURE_DELAY - (millis() - t0);
|
|
|
|
|
|
|
|
if (t_diff > 0)
|
|
if (t_diff > 0)
|
|
|
{
|
|
{
|