-
Notifications
You must be signed in to change notification settings - Fork 7.7k
-
hi all,
i'm struggling with a little projetct. I use Firebase ESP client to open some streams with callbacks and to send DHT22 Sensor Data to a specific topic every minute.
Sensor Data is refreshing every 5s:
if(millis() > sensorSyncMillis + 5000){ sensorSyncMillis = millis(); float rawTemp = dht.readTemperature(); float rawHum = dht.readHumidity(); if (!isnan(rawTemp) || !isnan(rawHum)){ hum = rawHum; //Global values to store valid readings temp = rawTemp; } }
i use the adafruit library <DHT.h> and found some blocking code in there, it also seems that DHT22 is quite slow. Additionaly i log outputs on a SD card for information and debugging. The combination of using firebase and the blocking code of DHT22 seem to sporadically trigger a Interrupt wdt timeout
logging function (does not seem to have an effect on wdt timeout)
void log(const char* format, ...) { if(!SERIAL_DEBUG) return; va_list args; va_start(args, format); int formatted_length = vsnprintf(nullptr, 0, format, args); if (formatted_length < 0) { Serial.println("Formatting error"); va_end(args); return; } va_end(args); char* formatted_message = (char*)malloc(formatted_length + 1); // +1 für das Nullzeichen if (formatted_message) { vsnprintf(formatted_message, formatted_length + 1, format, args); time_t now; struct tm timeinfo; time(&now); localtime_r(&now, &timeinfo); char timestamp[11]; // [hh:mm:ss] mit Nullterminierung snprintf(timestamp, sizeof(timestamp), "[%02d:%02d:%02d]", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); Serial.print(timestamp); Serial.print(" "); Serial.println(formatted_message); if(SD_DEBUG && SD_STATUS){ logfile = SD.open("/log.txt", FILE_APPEND); if(logfile){ logfile.print(timestamp); logfile.print(" "); logfile.println(formatted_message); logfile.close(); SD_FAILURE_COUNT = 0; } else{ SD_FAILURE_COUNT++; Serial.printf("SD Failure no: %i\n", SD_FAILURE_COUNT); if(SD_FAILURE_COUNT > 2){ Serial.println("LOGFILE CANNOT BE OPENED DEACTIVATE SD"); //SD.end(); <-- Führt zu crash wenn SD nicht mehr da ist //File konnte drei mal nicht geöffnet werden... SD_STATUS = false; } } } free(formatted_message); } else { Serial.println("Memory allocation error"); free(formatted_message); } }
i debugged the Backtrace and PC with following information:
PC:
0x400fb465: DHT::expectPulse(bool) at E:\.../.pio/libdeps/esp32doit-devkit-v1/DHT sensor library/DHT.cpp:382
Backtrace:
0x400ff8c9: loopTask(void*) at C:/Users/.../.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
0x400d3bf5: loop() at E:\.../src/main copy.cpp:456
0x400fb5dd: DHT::readTemperature(bool, bool) at E:\.../.pio/libdeps/esp32doit-devkit-v1/DHT sensor library/DHT.cpp:88
0x400fb54d: DHT::read(bool) at E:\.../.pio/libdeps/esp32doit-devkit-v1/DHT sensor library/DHT.cpp:306
0x400fb462: DHT::expectPulse(bool) at E:\.../.pio/libdeps/esp32doit-devkit-v1/DHT sensor library/DHT.cpp:382
versions:
PACKAGES:
- framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
- tool-esptoolpy @ 1.40501.0 (4.5.1)
- tool-mkfatfs @ 2.0.1
- tool-mklittlefs @ 1.203.210628 (2.3)
- tool-mkspiffs @ 2.230.0 (2.30)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Firebase Arduino Client Library for ESP8266 and ESP32 @ 4.4.9
|-- DHT sensor library @ 1.4.6
|-- Adafruit Unified Sensor @ 1.1.14
|-- ESP32Ping @ 1.7.0
|-- SD @ 2.0.0
|-- SPI @ 2.0.0
|-- WiFi @ 2.0.0
Error:
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
so what would be the best solution for this issue? Of course i could just use a faster and more reliable sensor, but i would like to use the hardware i have for now..
Maybe just raise the time for timeout, how could i do this?
Feed the watchdog before and after trying to get DHT22 data?
And another big problem is this Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1). does not trigger a reset of the ESP which means it gets completley stuck, how to solve this? I think that one came with the update from framwork 2.0.11 to 2.0.14 but I'm not 100% sure..
br
Beta Was this translation helpful? Give feedback.