DIY Arduino Data Logger: Log Temperature & Humidity to an SD Card
- Cartell Automotive
- May 22
- 2 min read
Updated: May 29
Ever wanted to track environmental conditions in your workshop, greenhouse, or 3D printer enclosure? With a few basic components, you can create your own temperature and humidity logger that saves data to a microSD card for later analysis—no Wi-Fi required.
What You’ll Need
Arduino Uno (or compatible board)
DHT11 or DHT22 temperature & humidity sensor
Micro SD Card Module (SPI)
microSD card (formatted FAT32)
Jumper wires
5V power source (USB or adapter)
RTC could be a nice addition for timestamps!
Wiring Guide
🔹 DHT Sensor (Connected to Digital Pins)
DHT Pin | Arduino Pin |
VCC | 5V |
GND | GND |
DATA | D6 |
(N/C) | — |
Note: If your DHT sensor has only 3 pins, it will be VCC, GND, and DATA.
SD Card Module (SPI Pins)
SD Module Pin | Arduino Pin |
GND | GND |
VCC | 5V |
MISO | D12 |
MOSI | D11 |
SCK | D13 |
CS (SS) | D10 |

Arduino Code
Install these libraries first:
DHT sensor library by Adafruit
SD library (built-in to Arduino IDE)
#include <SPI.h>
#include <SD.h>
#include <DHT.h>
#define DHTPIN 6
#define DHTTYPE DHT11
#define CSPIN 10
DHT dht(DHTPIN, DHTTYPE);
File logFile;
void setup() {
Serial.begin(9600);
dht.begin();
if (!SD.begin(CSPIN)) {
Serial.println("SD card failed or not present.");
return;
}
logFile = SD.open("datalog.txt", FILE_WRITE);
if (logFile) {
logFile.println("Temp(C),Humidity(%)");
logFile.close();
}
}
void loop() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if (isnan(temp) || isnan(hum)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
logFile = SD.open("datalog.txt", FILE_WRITE);
if (logFile) {
logFile.print(temp);
logFile.print(",");
logFile.println(hum);
logFile.close();
Serial.println("Data logged.");
}
delay(5000); // Log every 5 seconds
}
Reading Your Data
After the logging session, remove the SD card and plug it into your PC. Open datalog.txt with Excel, Notepad, or any CSV viewer to see your timestamp-free log of temperature and humidity readings.
Use Cases
Science experiments
Greenhouse monitoring
3D printer enclosure tracking
Graphing environmental changes over time
Wrap-Up
The Arduino + DHT11 + SD Card combo is a simple yet powerful way to start logging real-world data. Want to upgrade it? Add an RTC (Real-Time Clock) module for timestamped logs or Bluetooth to send live data to your phone.
Looking for the hardware? We stock SD card modules, DHT sensors, and jumper kits. Drop us a DM or check our link in bio.
Let me know if you'd like this formatted for your website, or if you want a version with timestamps or real-time graphing via serial!




Comments