diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-02-04 18:29:55 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-02-04 18:29:55 +0300 |
commit | 65d3e753d0dbc8755ecb6b5bbb06ad2f1a6c39b4 (patch) | |
tree | b8e356189ab99ba7d40c423509fc0f4b1b160723 /src/Heating | |
parent | b9f636286a7552856e6986abfc410d361d4f6609 (diff) |
Fixed DHT sensors on MB6HC
Diffstat (limited to 'src/Heating')
-rw-r--r-- | src/Heating/Sensors/DhtSensor.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Heating/Sensors/DhtSensor.cpp b/src/Heating/Sensors/DhtSensor.cpp index cefacfb5..02ceb0c6 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, INTERRUPT_MODE_CHANGE, this); + delayMicroseconds(2); // give the interrupt time to occur lastPulseTime = 0; numPulses = 0; // tell the ISR to collect data } |