mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
Replace delay with delayMicroseconds to let it work while interruppts are disabeled.
In multihreaded environment (I used NilRTOS) its usefull to disable interruppts while reading the sensors. However delay() requires interrupts to be enabled. If you read more than one sensor in a sequence the 2nd one gets spurious DHTLIB_ERROR_CONNECT errors. Timing issues with the wakeup delay(). They don't used to happen it interrupts are enabled. Replacing delay() with delayMicroseconds() solved this issue.
This commit is contained in:
parent
bd5f923158
commit
174a065598
@ -124,7 +124,7 @@ int8_t dht::_readSensor(uint8_t pin, uint8_t wakeupDelay, uint8_t leadingZeroBit
|
||||
// REQUEST SAMPLE
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, LOW); // T-be
|
||||
delay(wakeupDelay);
|
||||
delayMicroseconds(wakeupDelay*1000);
|
||||
digitalWrite(pin, HIGH); // T-go
|
||||
pinMode(pin, INPUT);
|
||||
|
||||
@ -197,4 +197,4 @@ int8_t dht::_readSensor(uint8_t pin, uint8_t wakeupDelay, uint8_t leadingZeroBit
|
||||
}
|
||||
//
|
||||
// END OF FILE
|
||||
//
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user