ESP32 PSRAM Not Detected or Not Usable
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 PSRAM Not Detected or Not Usable. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 external PSRAM (SPIRAM) is not detected or crashes when accessed.
Quick Fix
Wrong
// PSRAM not configured in menuconfig
// Or wrong PSRAM type selected
heap_caps_malloc(size, MALLOC_CAP_SPIRAM) returns NULL.
Right
// Enable in menuconfig:
// CONFIG_SPIRAM=y, CONFIG_SPIRAM_USE_CAPS_ALLOC=y
if (psramFound()) {
size_t psramSize = ESP.getPsramSize();
size_t freePsram = ESP.getFreePsram();
Serial.printf("PSRAM: %d KB total, %d KB free\n",
psramSize/1024, freePsram/1024);
// Allocate from PSRAM
void* buf = heap_caps_malloc(32768, MALLOC_CAP_SPIRAM);
if (buf) Serial.println("PSRAM allocation OK");
} else {
Serial.println("PSRAM not found");
}
PSRAM: 4096 KB total, 3896 KB free
PSRAM allocation OK
Prevention
Enable PSRAM support in menuconfig (SPIRAM). Set correct PSRAM type (quad/ octal). Use heap_caps_malloc() with MALLOC_CAP_SPIRAM for PSRAM. Check psramFound() before using PSRAM. Test with psram test sketch.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro