Wie bestimmt man, wie viel Prozent des Speichers (Heap) auf dem ESP32 frei sind?
English
Deutsch
Dieser Ansatz funktioniert für Arduino / PlatformIO sowie ESP-IDF-Projekte.
esp32_heap_percentage_example.cpp
#include <esp_heap_caps.h>
uint32_t freeHeapBytes = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
uint32_t totalHeapBytes = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
float percentageHeapFree = freeHeapBytes * 100.0f / (float)totalHeapBytes;
// Print to serial
Serial.printf("[Memory] %.1f%% free - %d of %d bytes free\n", percentageHeapFree, freeHeapBytes, totalHeapBytes);Siehe auch Anzahl der freien Bytes im ESP32-Speicher / Heap finden?
Check out similar posts by category:
ESP8266/ESP32
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow