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 constantPinWhat it is
PIN_SENSE34Sensor — analog output, 3.3 V maximum
PIN_SD_CS4microSD 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

  1. Format the card as FAT32 and insert it before powering up.
  2. Flash and confirm the card type and the created header row in the log.
  3. Watch samples land, then remove the card while running and confirm the sketch reports it and continues.
  4. 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

Connection diagram for ESP32 SD Card Data Logger

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.

Related projects

    Back to all project guides · Study the course