-
-
Notifications
You must be signed in to change notification settings - Fork 1
Typed RingBuffer
Phil Schatzmann edited this page Jun 11, 2025
·
2 revisions
For typed data you can use TypedRingBufferPSRAM and TypedRingBufferHIMEM:
#include "esp32-psram.h"
// Define a custom data structure
struct SensorData {
float temperature;
float humidity;
uint32_t timestamp;
};
void setup() {
Serial.begin(115200);
// Create a typed ring buffer for sensor data
TypedRingBufferPSRAM<SensorData> dataBuffer(100);
// Add some data
SensorData reading = {25.4, 68.7, millis()};
dataBuffer.push(reading);
// Read data back
SensorData result;
if (dataBuffer.pop(result)) {
Serial.printf("Temperature: %.1f°C, Humidity: %.1f%%\n",
result.temperature, result.humidity);
}
}