• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Hire Me | Contact | Calculators-online
You are here: Home / Arduino Projects / Interfacing SD Card Module for Data Logging

Interfacing SD Card Module for Data Logging

Last Updated on May 14, 2026 by Swagatam Leave a Comment

In this post we are going to interface SD card module with arduino for data logging. We will see overview of SD card module and understand its pin configurations and on board components. Finally we will be constructing a circuit to log the temperature and humidity data to SD card.

Table of Contents
  •  Secure Digital Card
  • Image of SD card module:
    • Flipside of the module and pin configuration:
    • Schematic diagram:   
    • HOW TO SET TIME TO RTC:
    • Program:
      • Author’s prototype: 

 Secure Digital Card

SD card or Secure Digital card is boon for modern electronics as it provides high capacity storage at minimal size. We have used the SD card for media storage in one of the previous project (Mp3 player). Here we are going to use it for data logging.

Data logging is the fundamental step to record the past occurrence of an incident. For example: scientists and researchers able to interpret the rise of global temperature.

They came to this conclusion after understanding the rising temperature pattern by looking the data of past few decades. Recording the data about the current incident might also disclose about the future occurrence.

Since arduino being a great microcontroller for reading sensor data and supports various communication protocols to read the sensors and input output peripherals, the connection between SD card module arduino made piece of cake.

Since arduino don’t have any storage other than its own program storage space, we can add an external storage using the described module in this article.

Now let’s take a look at SD card module.

Image of SD card module:

Image of SD card module:

Flipside of the module and pin configuration:

Flipside of the module and pin configuration:

There are six pins and it supports SPI (serial peripheral interface) communication protocol. For Arduino UNO the SPI communication pins are 13, 12, 11, and 10. For Arduino mega the SPI pins are 50, 51, 52 and 53.

The proposed project is illustrated with Arduino UNO if you have any other model of Arduino please refer internet for the SPI pins.

The module consists of a card holder which holds the SD card in place. 3.3V regulator is provided to limit the voltage to SD cards as it is designed to function at 3.3V and not 5V.

It has LVC125A integrated circuit on board which is logic level shifter. The function of logic level shifter is to reduce 5V signals from arduino to 3.3V logic signals.

Now that concludes the SD card module.

Using SD card module we can store any king of data, here we are going to store text data. We will be storing temperature and humidity data to SD card. We are also utilizing real time clock module to log the time along with sensor data. It records the data every 30 seconds.

Schematic diagram:   

 

Interfacing SD Card Module for Data Logging

The RTC module will keep track of time and log the date and time to the SD card.

The error LED blinks rapidly, if the SD card fails or fails to initialize or SD card not present. Rest of the time the LED stay off.

HOW TO SET TIME TO RTC:

•    Download the library below.
•    With completed hardware setup, connect the arduino to PC.
•    Open arduino IDE
•    Go to File> Examples>DS1307RTC> SetTime.
•    Upload the code and RTC will get synchronised with computer’s time.
•    Now upload the code given below.

Please download following arduino library before uploading the code.

DS1307RTC: github.com/PaulStoffregen/DS1307RTC

DHT11 temp & humidity: arduino-info.wikispaces.com/file/detail/DHT-lib.zip

Program:

//-----Program developed by R.Girish-----//

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <dht.h>

#define DHTxxPIN A0

const int cs = 10;
const int LED = 7;

dht DHT;
File myFile;

int ack;
int f;

void setup()
{
  Serial.begin(9600);
  pinMode(LED, OUTPUT);

  if (!SD.begin(cs))
  {
    Serial.println("Card failed, or not present");
    while (true)
    {
      digitalWrite(LED, HIGH);
      delay(100);
      digitalWrite(LED, LOW);
      delay(100);
    }
  }

  Serial.println("Initialization done");
}

void loop()
{
  myFile = SD.open("TEST.txt", FILE_WRITE);

  if (!myFile)
  {
    Serial.println("File open error");
    return;
  }

  Serial.println("----------------------------------------------");
  myFile.println("----------------------------------------------");

  tmElements_t tm;

  if (RTC.read(tm))
  {
    int hr = tm.Hour;
    bool pm = false;

    if (hr >= 12)
    {
      pm = true;
      if (hr > 12) hr -= 12;
    }
    if (hr == 0) hr = 12;

    Serial.print("TIME:");
    myFile.print("TIME:");

    if (hr < 10)
    {
      Serial.print("0");
      myFile.print("0");
    }

    Serial.print(hr);
    myFile.print(hr);
    Serial.print(":");
    myFile.print(":");

    Serial.print(tm.Minute);
    myFile.print(tm.Minute);
    Serial.print(":");
    myFile.print(":");

    Serial.print(tm.Second);
    myFile.print(tm.Second);

    if (pm)
    {
      Serial.print(" PM");
      myFile.print(" PM");
    }
    else
    {
      Serial.print(" AM");
      myFile.print(" AM");
    }

    Serial.print(" DATE:");
    myFile.print(" DATE:");

    Serial.print(tm.Day);
    myFile.print(tm.Day);
    Serial.print("/");
    myFile.print("/");
    Serial.print(tm.Month);
    myFile.print("/");
    Serial.print("/");
    Serial.println(tmYearToCalendar(tm.Year));
    myFile.println(tmYearToCalendar(tm.Year));
  }
  else
  {
    if (RTC.chipPresent())
    {
      Serial.println("RTC stopped!!! Run SetTime code");
      myFile.println("RTC stopped!!! Run SetTime code");
    }
    else
    {
      Serial.println("RTC Read error! Check circuitry!");
      myFile.println("RTC Read error! Check circuitry!");
    }
  }

  Serial.println("----------------------------------------------");
  myFile.println("----------------------------------------------");

  ack = 0;
  int chk = DHT.read11(DHTxxPIN);

  if (chk == DHTLIB_ERROR_CONNECT) ack = 1;

  if (ack == 0)
  {
    f = DHT.temperature * 1.8 + 32;

    Serial.print("Temperature(C) = ");
    myFile.print("Temperature(°C) = ");
    Serial.println(DHT.temperature);
    myFile.println(DHT.temperature);

    Serial.print("Temperature(F) = ");
    myFile.print("Temperature(°F) = ");
    Serial.println(f);
    myFile.println(f);

    Serial.print("Humidity(%) = ");
    myFile.print("Humidity(%) = ");
    Serial.println(DHT.humidity);
    myFile.println(DHT.humidity);
  }
  else
  {
    Serial.println("NO DATA");
    myFile.println("NO DATA");
  }

  myFile.close();

  for (int i = 0; i < 30; i++)
  {
    delay(1000);
  }
}

//-----Program developed by R.Girish-----//

Once the circuit is allowed to log data for some time, you can remove the SD card connect to your computer, there will be TEXT.txt file which all the temperature and humidity data is recorded along with time and date, as shown below.

NOTE: The above idea is an example how to interface and record data. The utilization of this project depend on your imagination, you can record sensor data of any kind.

Author’s prototype: 

Prototype for Interfaced SD Card Module with Arduino

You'll also like:

  • How To Use And Program ATmega Microcontrollers From Scratch Without Arduino
  • P 20150830 153854Make this 7 Segment Digital Clock with Beep Alert Circuit
  • CircuitDigital Weighing Scale Using Load Cell and Arduino
  • Scan 6Make this Home Security Project Using Arduino – Tested and Working

Filed Under: Arduino Projects Tagged With: Card, Data, Interfacing, Logging, Module, SD

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!

Previous Post: « Contactless Sensors – Infrared, Temperature/Humidity, Capacitive, Light
Next Post: How to Connect an IR Photodiode Sensor in a Circuit »

Have a question or feedback? Feel free to ask below—just make sure it relates to the post above!

Subscribe
Notify of
guest
guest
0 Comments

Primary Sidebar

My YouTube Channel

Circuit Simulator: Draw and Simulate Schematics

circuit simulator image

Categories

  • Arduino Projects (95)
  • Audio and Amplifier Projects (134)
  • Automation Projects (18)
  • Automobile Electronics (104)
  • Battery Charger Circuits (90)
  • Datasheets and Components (109)
  • Electronics Theory (151)
  • Energy from Magnets and Earth (43)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (20)
  • Health related Projects (27)
  • Home Electrical Circuits (13)
  • Indicator Circuits (16)
  • Inverter Circuits (98)
  • Lamps and Lights (161)
  • Meters and Testers (72)
  • Mini Projects (28)
  • Motor Controller (68)
  • Oscillator Circuits (30)
  • Pets and Pests (15)
  • Power Supply Circuits (91)
  • Remote Control Circuits (50)
  • Security and Alarm (65)
  • Sensors and Detectors (107)
  • SMPS and Converters (46)
  • Solar Controller Circuits (62)
  • Temperature Controllers (44)
  • Timer and Delay Relay (51)
  • Voltage Control and Protection (44)
  • Water Controller (37)
  • Wireless Circuits (31)

Subscribe to get New Circuits in your Email

Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Recent Comments

  • Swagatam on High Voltage Meter Circuit [for Measuring 10kV]
  • Swagatam on About Me
  • chukwuamaka on About Me
  • Brian Harding on High Voltage Meter Circuit [for Measuring 10kV]
  • Swagatam on Police/Ambulance Siren Circuit with Rotating Beacon Light

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Stack Exchange
  • Linkedin

Calculators

  • ZVS Induction Heater + Tank Calculator Tool
  • Zener Diode Calculator
  • Wire Current and Thickness Calculator (Ampacity Calculator)
  • Voltage Divider Calculator
  • Transistor Base Resistor Calculator
  • Transistor Astable Multivibrator Calculator
  • TL431 Calculator
  • Solar Panel, Inverter, Battery Calculator
  • Ferrite Core Air Gap Calculator Tool
  • Parallel MOSFET Calculator Tool: How to Connect MOSFETs in Parallel Safely
  • LC Resonance Calculator for EV Battery Charger Circuits
  • LED String Series Resistor Calculator
  • PFC (Power Factor Correction) Calculator Tool: 3kW
  • Passive Power Factor Correction (PFC) Calculator
  • LM567 IC Calculator Tool
  • SMPS Flyback Boost Converter Calculator
  • Shunt Resistor Calculator for Ammeters
  • SCR and Triac Gate Resistor Calculator
  • Battery Back up Time Calculator
  • Boost Converter Calculator (Non-Isolated)
  • Bootstrap Capacitor Calculator
  • Buck Converter Calculator
  • Buck-Boost Converter Calculator
  • Capacitance Reactance Calculator
  • DCM Flyback Transformer & Wire Gauge Wire Size Calculator Tool
  • Filter Capacitor Calculator
  • IC 4047 Calculator (Frequency and PWM)
  • IC 4060 Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • IC SG3525, SG3524 Calculator
  • Inductance Calculator
  • Induction Heater Inductor and Resonant Frequency Calculator
  • Induction Heater Work Coil Calculator
  • Inverter LC Filter Calculator
  • LC Resonance Calculator
  • LED Current Calculator
  • LM317, LM338, LM396 Calculator
  • NAND/NOT Gate RC Values Calculator
  • NOT, NAND Gate Frequency Calculator
  • Notch Filter Calculator Tool
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • RC Filter Calculator
  • Reactance Calculator
  • Sine Table Calculator for SPWM Arduino Code
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • SMPS Calculator for Toroidal Ferrite Transformers
  • SMPS Flyback Transformer Calculator – Design by Target Duty Cycle
  • TL431 Calculator
  • Op-Amp Hysteresis Resistor Calculator

© 2026 · Swagatam Innovations