SD readers/What the board is/01. Why a card and not the flash you already have
What the board is · 01 of 11

Why a card and not the flash you already have

An ESP32 already has a filesystem, and for a few settings it is the right one. A card earns its place the moment you want more than a megabyte and a half, or want to read the result on a laptop instead of down the serial port.

What is already on your board

An ESP32 has flash, and the Arduino IDE hands you a slice of it as a filesystem. The default scheme on a 4 MB board is named after the split it makes: 1.2 MB APP / 1.5 MB SPIFFS. That 1.5 MB is the whole of your file space, and it is enough for settings, a small web page and a log you intend to read and clear.

It stops being enough in two ways, and the first is size.

One reading a minute
Logging for30 days
Rows written
43,200
File size
1.2 MB
Flash runs out at
36 days
43200 rows × 30 bytes = 1.2 MB. Still inside the 1.5 MB partition — for now. It fills on day 36, and the only way to read it back is over the serial port, one line at a time.

The second is harder to design around. To read a file out of flash you have to ask the board for it — over serial, over Wi-Fi, through code you wrote. To read a file off a card you take the card out and put it in a laptop.

What a card costs you

Six wires and about 0.3 mA of standing current for the power LED on this board, plus whatever the card itself draws while it is working — tens of milliamps in bursts, which is why the board carries a 10 µF capacitor beside the socket.

And one habit. A card occasionally stops for tens of milliseconds to reorganise itself internally, and a sketch sampling on a tight timer loses whatever lands in that gap. Logging to a microSD card has the buffering pattern that survives it.

What a card does not give you

It is not faster than flash and it is not more reliable than flash. It is bigger, and it is removable. Those are the two reasons, and if neither of them is your reason, the board you already have is the better answer.

When it does not work

Can I just use the flash on the board?

For a Wi-Fi password, a calibration constant or a handful of counters, yes — that is what Preferences and LittleFS are for, and they need no extra parts. The line is roughly a megabyte and a half on a 4 MB board, and the other line is whether you ever need to carry the data to a computer.

Which card should I buy?

A small, ordinary one. Anything from 4 GB upward, class 10 or better, from a brand you recognise. A fast card does not make this faster — the bench measured 5 MB/s at best, and the slowest card on a shop shelf can beat that. What a cheap fake card will do is lose your data at the point where its real capacity runs out.

Does a bigger card give more write cycles?

Effectively yes, because the card's own controller spreads writes across the whole chip. But the thing that actually kills a logging card is opening and closing the file on every row, not the size of the card. Buffer a few kilobytes and write blocks.

Can I take the card out while the board is running?

Not safely with a file open. The card can be in the middle of a write that it never finishes, and the filesystem entry for that file is then wrong. Close the file first, or unplug the board.

Where this goes next

The one thing on this board that can destroy something, and it is a part that is not fitted.

Three volts three, and nothing else

Edit this page — content/books/sd/why-a-card.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum