Skip to content

Basic Vector Usage

Phil Schatzmann edited this page Jun 11, 2025 · 3 revisions

You can use the VectorPSRAM or VectorHIMEM to stroe the data in the required memory area:

#include "esp32-psram.h"

void setup() {
  Serial.begin(115200);
  
  // Create a vector in PSRAM (or use VectorHIMEM for HIMEM)
  VectorPSRAM<int> psram_vector;
  
  // Add elements
  for(int i = 0; i < 1000; i++) {
    psram_vector.push_back(i);
  }
  
  Serial.printf("Vector size: %d\n", psram_vector.size());
  Serial.printf("First element: %d\n", psram_vector.front());
  Serial.printf("Last element: %d\n", psram_vector.back());
}
Clone this wiki locally