adafruit / DHT-sensor-library

Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
https://learn.adafruit.com/dht
MIT License
1.99k stars 1.42k forks source link

Unable to read data on esp32c3 #202

Open flex380 opened 1 year ago

flex380 commented 1 year ago

Failed to read from DHT sensor!

phybros commented 1 year ago

I have the same issue with an ESP32-C3-WROOM-02 module. I did find this person's repo (https://github.com/mkjanke/ESP32-C3-Fanspeed) which mentions that a change to the InterruptLock class is required to make the DHT readings work, but I haven't tried it:

class InterruptLock {
#if defined(ESP32)
  portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
#endif

public:
  InterruptLock() {
#if !defined(ARDUINO_ARCH_NRF52)
    noInterrupts();
#endif
#if defined(ESP32)
    portENTER_CRITICAL(&mutex);
#endif
  }
  ~InterruptLock() {
#if !defined(ARDUINO_ARCH_NRF52)
    interrupts();
#endif
#if defined(ESP32)
    portEXIT_CRITICAL(&mutex);
#endif

  }
};

Maybe we could just PR this to the library?

phybros commented 1 year ago

I tried this ^^^ and it just makes the esp crash and dump