Failed to read from DHT sensor!

Hi,

I am trying to connect my DHT22 sensor to TTGO LoRa32 868MHz v1 (SX1276 without display). I connected the data pin of the DHT to GPIO 16, in the terminal i get an error Failed to read from DHT sensor! Or when i get the read its
[ “Subject: /DHTtoMQTT/dht1” N: Received json : {“hum”:3291,“tempc”:9.8,“tempf”:49.64}]
Any help from someone please.

Thanks

Hi,

Are you using the binaries, arduino ide or platformio, if one of the last two, may you share your configurations files that have been modified ?

Im using arduino ide code.
confing_DHT.h:
/----------------------------USER PARAMETERS-----------------------------/
/-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------/
#define DHTTOPIC "/DHTtoMQTT/dht1"
#define dht_always true // if false when the current value for temp or hum is the same as previous one don’t send it by MQTT
#define TimeBetweenReadingDHT 30000 // time between 2 DHT readings
/-------------DHT SENSOR TYPE-------------/
//#define DHT_SENSOR_TYPE DHT11 //uncomment for DHT11 Sensor
//#define DHT_SENSOR_TYPE DHT21 //uncomment for DHT21 Sensor
#define DHT_SENSOR_TYPE DHT22 //uncomment for DHT22 Sensor (default for backwards compatibility)
/-------------------PIN DEFINITIONS----------------------/
#ifndef DHT_RECEIVER_GPIO
# if defined(ESP8266)
# define DHT_RECEIVER_GPIO 5 //5 = D1 you can put 14 = D5 if you don’t use HCSR501 sensor and the RFM69
# elif defined(ESP32);
# define DHT_RECEIVER_GPIO 16
# else
# define DHT_RECEIVER_GPIO 8
# endif
;#endif

#endif

**In User_confing.h i have manually set up wifi and mqtt and **
** uncommented and defined modules **
//#define ZgatewayRF “RF” //ESP8266, Arduino, ESP32
//#define ZgatewayIR “IR” //ESP8266, Arduino, Sonoff RF Bridge
//#define ZgatewayLORA “LORA” //ESP8266, Arduino, ESP32
//#define ZgatewayPilight “Pilight” //ESP8266, Arduino, ESP32
//#define ZgatewayWeatherStation “WeatherStation” //ESP8266, Arduino, ESP32
#define ZgatewayBT “BT” //ESP8266, ESP32
//#define ZgatewayRF2 “RF2” //ESP8266, Arduino, ESP32
//#define ZgatewaySRFB “SRFB” // Sonoff RF Bridge
//#define Zgateway2G “2G” //ESP8266, Arduino, ESP32
//#define ZgatewayRFM69 “RFM69” //ESP8266, Arduino, ESP32
//#define ZactuatorONOFF “ONOFF” //ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZsensorINA226 “INA226” //ESP8266, Arduino, ESP32
//#define ZsensorHCSR04 “HCSR04” //ESP8266, Arduino, ESP32
//#define ZsensorHCSR501 “HCSR501” //ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZsensorADC “ADC” //ESP8266, Arduino, ESP32
//#define ZsensorBH1750 “BH1750” //ESP8266, Arduino, ESP32
//#define ZsensorTSL2561 “TSL2561” //ESP8266, Arduino, ESP32
//#define ZsensorBME280 “BME280” //ESP8266, Arduino, ESP32
//#define ZsensorHTU21 “HTU21” //ESP8266, Arduino, ESP32
#define ZsensorDHT “DHT” //ESP8266, Arduino, ESP32, Sonoff RF Bridge
#define ZsensorDS1820 “DS1820” //ESP8266, Arduino, ESP32
//#define ZsensorGPIOKeyCode “GPIOKeyCode” //ESP8266, Arduino, ESP32
//#define ZsensorGPIOInput “GPIOInput” //ESP8266, Arduino, ESP32
//#define ZmqttDiscovery “HADiscovery”//ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZactuatorFASTLED “FASTLED” //ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZboardM5STICKC "M5StickC"
//#define ZboardM5STICKCP "M5StickCP"
//#define ZboardM5STACK "ZboardM5STACK"
//#define ZradioCC1101 “CC1101” //ESP8266, ESP32
//#define ZactuatorPWM “PWM” //ESP8266, ESP32
//#define ZsensorSHTC3 “SHTC3” //ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZactuatorSomfy “Somfy” //ESP8266, Arduino, ESP32
//#define ZgatewayRS232 “RS232” //ESP8266, Arduino, ESP32

Or do you need full user_confing.h

Could you formqt your code properly please, it is difficult to read like that.

Are you using the exact libraries given with the release?

Im using ttgo-lora32-v1-libraries.zip
I don’t know if it’s the correct one but BT and OneWire works.

DHT.h

#ifndef config_DHT_h
#define config_DHT_h

extern void setupDHT();
extern void DHTtoMQTT();
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define DHTTOPIC              "/DHTtoMQTT/dht1"
#define dht_always            true // if false when the current value for temp or hum is the same as previous one don't send it by MQTT
#define TimeBetweenReadingDHT 30000 // time between 2 DHT readings
/*-------------DHT SENSOR TYPE-------------*/
//#define DHT_SENSOR_TYPE DHT11 //uncomment for DHT11 Sensor
//#define DHT_SENSOR_TYPE DHT21 //uncomment for DHT21 Sensor
#define DHT_SENSOR_TYPE DHT22 //uncomment for DHT22 Sensor (default for backwards compatibility)
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef DHT_RECEIVER_GPIO
#  if defined(ESP8266)
#    define DHT_RECEIVER_GPIO 5 //5 = D1 you can put 14 = D5 if you don't use HCSR501 sensor and the RFM69
#  elif defined(ESP32)
#    define DHT_RECEIVER_GPIO 16
#  else
#    define DHT_RECEIVER_GPIO 8
#  endif
#endif

#endif

And do you need full user config code or just some specific codes lines.