From e1ed62af37d0deaa14360df52ce78bdf12bcefd7 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Fri, 8 Nov 2019 20:35:35 +0300 Subject: [PATCH] sensor/dht: set pin mode before digitalWrite --- code/espurna/sensors/DHTSensor.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/espurna/sensors/DHTSensor.h b/code/espurna/sensors/DHTSensor.h index 9084f81c..87720353 100644 --- a/code/espurna/sensors/DHTSensor.h +++ b/code/espurna/sensors/DHTSensor.h @@ -137,13 +137,14 @@ class DHTSensor : public BaseSensor { unsigned char byteInx = 0; unsigned char bitInx = 7; + pinMode(_gpio, OUTPUT); + // Send start signal to DHT sensor if (++_errors > DHT_MAX_ERRORS) { _errors = 0; digitalWrite(_gpio, HIGH); nice_delay(250); } - pinMode(_gpio, OUTPUT); noInterrupts(); digitalWrite(_gpio, LOW); if ((_type == DHT_CHIP_DHT11) || (_type == DHT_CHIP_DHT12)) {