Why you probably haven't used the 4MiB PSRAM available on some ESP32 Boards.
When you look at your ESP32 Boards, you have two options, either it's a shielded one, or its an unshielded, where you can look directly at the chips. I recently bought some cheap ESP32 "TTGO" which got an ESP32, SD-Card Slot, 18650 Battery holder and one nice button "wheel" with press/up/down. There is no schematics available. I also haven't found something online about this design, I don't know if it's a cheap 'knock-off' or who really designed this board.
I've been playing around with this board, and it works quite well (for my purposes). I really like the SD-Card slot and the button-thing-press-wheel. The seller on Aliexpress wrote it has 4MiB-Flash and 4MiB-PSRAM. The Flash on the board is an standard Winbond SPI-Flash. (Winbond w25q32jvssiq). The 32 stands for 32M-Bit. You got 16,384 Pages, with an 256Byte page size. This is 4194304 Byte, or 4096k Bit which is 4MiB. But we're here for the PSRAM.
ESP-PSRAM32, which is a 1.8V 32-Mbit of SPI/QPI
(serial/quad parallel interface) Pseudo SRAM device.
The PSRAM is calld Pseudo SRAM, because it's an DRAM with an refresh circuit. So on the DRAM the Data would perish even if it's powered on. It behaves like an SRAM but in reality it's an DRAM. On both of these, the data is lost if you cut the power.
There is an guide from Espressif how to connect your PSRAM to your ESP32. (click)
And there are some limitations for external RAM but I won't address them here. You can look them up at the Espressif website.
Enable PSRAM in PlatformIO
So how can you enable the PSRAM in PlatformIO? Actually if you dive into the documentation you can find the lines you need in your
build_flags = -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
These are the compiler flags you would pass along. If you use your compiler with the command line.
So a call to:
ESP.getFreeHeap() would without the compiler flags would give you:
Free Heap: 263904
and with the PSRAM enabled:
Free Heap: 4458056
You can look up which official module has PSRAM available on Wikipedia. Basically all offical modules from Espressif named WROVER have the PSRAM installed.
If you've liked this article or if I helped you in any way, leave some comments below :) Thank You