diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-02-04 18:43:15 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-02-04 18:43:15 +0300 |
commit | ed3b2306a7df90ece49d6640bbf1aee3de7491f5 (patch) | |
tree | d460cb90bc44443315ef365ce14309f724bfeb29 /src/Heating | |
parent | 191f3e7d72a445e51a956805d2fc6fb1901327af (diff) | |
parent | 60ed67b33dff503fba35dd9e0979b0d2bc566471 (diff) |
Merge branch '3.3-dev' into wil-convert-same70-to-coren2g
Diffstat (limited to 'src/Heating')
-rw-r--r-- | src/Heating/Sensors/DhtSensor.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Heating/Sensors/DhtSensor.cpp b/src/Heating/Sensors/DhtSensor.cpp index 001a2d83..5f52394c 100644 --- a/src/Heating/Sensors/DhtSensor.cpp +++ b/src/Heating/Sensors/DhtSensor.cpp @@ -147,7 +147,8 @@ void DhtTemperatureSensor::TakeReading() noexcept // End the start signal by setting data line high. the sensor will respond with the start bit in 20 to 40us. // We need only force the data line high long enough to charge the line capacitance, after that the pullup resistor keeps it high. - port.WriteDigital(true); // this will generate an interrupt, but we will ignore it + numPulses = ARRAY_SIZE(pulses); // tell the ISR not to collect data yet + port.WriteDigital(true); // this may generate an interrupt, but we will ignore it delayMicroseconds(3); // Now start reading the data line to get the value from the DHT sensor @@ -155,8 +156,8 @@ void DhtTemperatureSensor::TakeReading() noexcept // It appears that switching the pin to an output disables the interrupt, so we need to call attachInterrupt here // We are likely to get an immediate interrupt at this point corresponding to the low-to-high transition. We must ignore this. - numPulses = ARRAY_SIZE(pulses); // tell the ISR not to collect data yet - port.AttachInterrupt(DhtDataTransition, InterruptMode::change, this); + port.AttachInterrupt(DhtDataTransition, INTERRUPT_MODE_CHANGE, this); + delayMicroseconds(2); // give the interrupt time to occur lastPulseTime = 0; numPulses = 0; // tell the ISR to collect data } |