Log temperature readings to a CSV file on an SD card, each stamped with the exact date and time — then open the file straight in Excel.
What you’ll build
Every minute the Arduino Nano reads the DHT11, asks the DS3231 RTC for the current time, and appends a line like 2026-06-30 14:05,31.2,58 to LOG.CSV on the SD card. Perfect for monitoring a room, greenhouse or fridge over days.
Components you’ll need
| Component | Qty | Price |
|---|---|---|
| Arduino Nano ATmega328P Compatible Board | 1 | ₹149 |
| SD Card Module | 1 | ₹19 |
| RTC DS3231 | 1 | ₹89 |
| DHT11 | 1 | ₹69 |
| 400 Point Breadboard | 1 | ₹299 |
| Jumper Wires MM | 1 | ₹299 |
| Total | ₹924 |
Step-by-step guide
- Wire the SD card module over SPI: VCC to 5V, GND to GND, CS→D10, MOSI→D11, MISO→D12, SCK→D13.
- Wire the DS3231 over I2C (SDA→A4, SCL→A5) and the DHT11 data pin to D4.
- Format a microSD card as FAT32 and insert it.
- Install the RTClib and DHT libraries; the SD library ships with the IDE.
- Set the RTC once with rtc.adjust (see the clock project), then upload this sketch.
- Let it run, then pop the card into your computer — LOG.CSV opens directly in Excel or Sheets for graphing.
The code
The sketch appends one CSV row per minute. Opening and closing the file each write makes it safe to pull the power at any time.
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <RTClib.h>
#include <DHT.h>
RTC_DS3231 rtc; DHT dht(4, DHT11);
void setup(){
Serial.begin(9600); dht.begin(); rtc.begin();
if(!SD.begin(10)){ Serial.println("SD failed"); while(1); }
}
void loop(){
DateTime now = rtc.now();
float t = dht.readTemperature(), h = dht.readHumidity();
File f = SD.open("LOG.CSV", FILE_WRITE);
if(f && !isnan(t)){
char stamp[20];
sprintf(stamp, "%04d-%02d-%02d %02d:%02d", now.year(), now.month(), now.day(), now.hour(), now.minute());
f.print(stamp); f.print(','); f.print(t,1); f.print(','); f.println(h,0);
f.close();
}
delay(60000L);
}Build this project
Add all 6 required components to your cart in one click — total ₹924.
Add all components to cart