Blog
ESP32 Data Storage: Save, Read, Wipe
Everything you save on an ESP32, and how to get rid of it. This covers how to store data in esp32, how to clear esp32 memory, wiping the chip, and what you can and cannot pull back off it.
How to Store Data in ESP32?
Pick the tier that fits the data. Key-value settings go in NVS through the Preferences library — a float, a counter, credentials. Files — configs, web pages, images — go in the SPIFFS/LittleFS partition. Bulk data — logs, audio, photos — goes on an SD card. RAM is for runtime only: it dies on reboot, which surprises exactly everyone once.
How to Clear ESP32 Memory?
Depends which memory you mean. RAM clears itself on reboot. NVS: Preferences.clear() wipes a namespace, or nvs_flash_erase() for all of it. Filesystem: SPIFFS.format() or LittleFS.format(). Whole chip: esptool.py erase_flash. Most people who ask this mean the last one — see the next question, and the FAQ index for related storage topics.
How to Wipe ESP32?
esptool.py erase_flash — one command, entire flash gone: firmware, filesystem, NVS, everything. Erasing does not brick the chip; it still boots into the ROM download mode, and the next Upload rebuilds it all. I wiped a week of calibration data once by running it out of habit — back up your NVS keys first. The flashing guide has the full workflow.
How to Copy a File to ESP32?
With the Sketch Data Upload plugin in Arduino, or uploadfs in PlatformIO: the data/ folder beside your sketch becomes the filesystem image and gets flashed into the filesystem partition. For a single file, write it from code instead — download over HTTP or copy from an SD card. The data uploader rebuilds the whole filesystem each run, so it replaces, never merges.
How to Increase Storage Space on ESP32?
Two honest answers. Inside the chip: edit the partition table — a custom partitions.csv can give the filesystem 3 MB instead of 1.5 MB, at the cost of OTA or app space. Beyond that, the flash size is fixed at purchase (4 MB typical; WROVER modules reach 16 MB), and PSRAM is RAM, not storage. Real capacity means an SD card.
How to Pull Code Off ESP32?
You cannot recover the source — the chip stores compiled firmware, not your sketch. esptool.py read_flash dumps the binary and a determined person can disassemble it, but no tool reconstructs your code from that. Keep the sketch in git; the board is not a backup.
How to Get Code into ESP32 Without a USB Connection?
OTA — over-the-air updates over Wi-Fi. ArduinoOTA or an HTTP update server flashes new firmware to a board sitting in a case across the room, and the wifi FAQ covers the connection side. A USB-TTL adapter on the UART pins works too, and WebSerial turns a browser tab into a terminal. All three beat crawling under the desk with a cable.
Why does my data vanish on reboot?
Almost always one of three things: it was in RAM (a variable, not NVS), the filesystem was never formatted (SPIFFS.begin() returned false and got ignored), or an earlier erase_flash wiped it before the backup existed. Add a serial print of begin()’s return value and the mystery usually disappears.
RAM, flash, NVS — what’s the difference?
RAM: roughly 320 KB of volatile SRAM, fast, gone on reboot (plus optional PSRAM on WROVER). Flash: 4-16 MB, holds firmware and the filesystem, survives reboots. NVS: a flash-backed key-value store with wear leveling, meant for small frequent updates — what Preferences uses. Three tiers, one mental model: fast, big, permanent.
How do I back up settings before wiping?
Dump your NVS keys to a file first: read every key you own into a JSON document and save it to the filesystem or an SD card. A full-chip backup is possible with esptool.py read_flash, but the practical backup is your data folder in git plus a config export. Ten minutes of prep beats re-calibrating a device by hand.
Write It, List It, Read It Back — In Your Browser
All three storage tiers from this FAQ have runnable examples, free, in the simulator:
- I2C EEPROM R/W — byte-level nonvolatile memory at 0x50:
I2C EEPROM R/W Test (0x50)
Writing test data...
Write reg[0] = 42
Read reg[0] = 42
Card ready. → Files on card: → Read back:) and the failure branch (SD.begin() FAILED - check the wiring).Bytes on one end, files on the other — the two instincts (verify what you wrote; check the mount before blaming the code) transfer straight to SPIFFS partitions on real hardware.