Industrial & Biomedical Automation · Intermediate · Logging
ESP32 SD Card Data Logger
Samples to a card with a real header row, and keeps logging when the network drops.
Firmware status: Generated from this project's own pin map and compiled with arduino-cli for esp32:esp32:esp32 before publication; bench validation on your hardware is still required.
Board: ESP32 DevKit (ESP32-WROOM-32, 30 or 38 pin) · ESP32 dual core @ 240 MHz · 3.3 V logic · build for esp32:esp32:esp32.
What you will build
A logger that writes CSV to a card, flushes every row, and treats a missing card or missing network as a condition to report rather than a reason to stop.
Components
- ESP32 board
- microSD card module (SPI)
- FAT32-formatted card, 32 GB or smaller
- Analog sensor
- Jumper wires
Pin map for this build
| Sketch constant | Pin | What it is |
|---|---|---|
PIN_SENSE | 34 | Sensor — analog output, 3.3 V maximum |
PIN_SD_CS | 4 | microSD module — SPI, FAT32 card |
Tools
- USB programming cable
- Multimeter
- Current-limited bench supply (for anything that switches a load)
- Small screwdriver and wire cutters
Build sequence
- Format the card as FAT32 and insert it before powering up.
- Flash and confirm the card type and the created header row in the log.
- Watch samples land, then remove the card while running and confirm the sketch reports it and continues.
- Open the CSV in a spreadsheet: the columns should line up on the first try.
Test and expected result
A header row and one row per sample, correct CSV structure, and the sketch survives the card being pulled.
Acceptance checks
csv parses, rows flushed, missing card reported and survived
Safety and limits
A card removed during a write can be corrupted. Power down before removing it, or accept that the log may end abruptly.
Hardware scope
SPI card access, append-with-flush writes, sensor sampling on a fixed interval.
Connection diagram
Download the connection diagram (SVG)
Download the Arduino sketch (E23_esp32_sd_card_logger.ino)
Guide source: the sketch on this page was generated from the pin map above and compiled for esp32:esp32:esp32 before publication.