Hello Everyone!
I recently bought Xiao ESP32S3 which has inbuilt 8MB PSRAM. I am working on a project to store adc values at 2KSps for 2mins, thus wanted to store all these values to PSRAM. I tried to find on internet but it didnt help. Is there any easy way like EEPROM.h functions to access PSRAM same as EEPROM at higher speeds.
Thanks in advance.
Hi there, Anish_Bhurke and Welcome
You see this link
How to Use Psram
basically it’s
"The ESP32/Arduino platform exposes a couple of methods to find out how much RAM you have in total and how much you can use.
#include <Arduino.h>
void setup() {
log_d("Total heap: %d", ESP.getHeapSize());
log_d("Free heap: %d", ESP.getFreeHeap());
log_d("Total PSRAM: %d", ESP.getPsramSize());
log_d("Free PSRAM: %d", ESP.getFreePsram());
}
void loop() {}
Running the code shows us the following lines in the Serial Monitor:
[D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled
[D][PSRAMTestArduino.ino:4] setup(): Total heap: 393356
[D][PSRAMTestArduino.ino:5] setup(): Free heap: 367948
[D][PSRAMTestArduino.ino:6] setup(): Total PSRAM: 4194252
[D][PSRAMTestArduino.ino:7] setup(): Free PSRAM: 4194252
HTH
GL PJ
BTW , AI say’s this:
To write to PSRAM in Arduino with ESP32S3, you can use the following steps:
Include the esp_psram.h header file.
Call the psramInit() function to initialize the PSRAM.
Use the ps_malloc() function to allocate memory in the PSRAM.
Use the ps_free() function to free memory in the PSRAM.
Call the psramDone() function to deinitialize the PSRAM.
Here is an example of how to write to PSRAM in Arduino with ESP32S3:
#include <esp_psram.h>
void setup() {
Serial.begin(115200);
// Initialize the PSRAM.
psramInit();
// Allocate memory in the PSRAM.
uint8_t *data = (uint8_t *)ps_malloc(1024);
// Write data to the PSRAM.
for (int i = 0; i < 1024; i++) {
data[i] = i;
}
// Free the memory.
ps_free(data);
// Deinitialize the PSRAM.
psramDone();
}
void loop() {}
This code will allocate 1024 bytes of memory in the PSRAM and write the values from 0 to 1023 to that memory. The memory will then be freed and the PSRAM will bedeinit.
Here are some additional tips for writing to PSRAM in Arduino with ESP32S3:
The PSRAM is not as fast as the internal memory of the ESP32S3, so you should avoid writing large amounts of data to the PSRAM.
The PSRAM is volatile, so you should use the psramDone() function to deinitialize the PSRAM when you are finished using it.
You can use the ESP.getFreePsram() function to get the amount of free memory in the PSRAM.
Thank you for your reply. I came across this and tried but it did not help. It gives a library not found error. I tried numerous ways on ChatGPT but was not able to find functions that interact with ESP32s3.
I bought this module since it has an internal 8MB PSRAM, but now I am unable to use it.