Logging Temperature Data to a MicroSD Card Using ESP32

Engineering illustration: Logging Temperature Data to a MicroSD Card Using ESP32

This project builds a standalone temperature data-logging station, saving temperature readings periodically to a microSD card with precise timestamps, suited for long-term monitoring with no constant computer connection needed.

Components needed

An ESP32 board, a DS18B20 digital temperature sensor, a microSD card reader module, and a microSD card.

Wiring it up

The DS18B20 sensor connects to GPIO21 via the 1-Wire protocol, with the usual pull-up resistor. The SD card module communicates via SPI using the standard MOSI, MISO, and SCK pins, with a chip-select (CS) pin on GPIO5. The module accepts 5V power, with an onboard regulator stepping it down to the 3.3V the memory card needs.

Data storage format

The system logs readings to a text file in comma-separated values (CSV) format, with each line containing a reading ID, date, time, and temperature in Celsius. Records are appended sequentially at the end of the file, each with a precise timestamp via NTP (Network Time Protocol) synchronization.

Power management

Between consecutive readings, the board enters deep sleep mode for 10 minutes, waking periodically to capture a new reading before returning to sleep — an approach that noticeably conserves power in battery-powered, long-running data-logging applications.

You can find ESP32 boards, DS18B20 sensors, and SD card modules at Juthour Tech.

Leave your comment

*
*
Only registered users can leave comments.