SD Card module with Arduino Uno

The SD card module is especially useful for projects that require data logging. The Arduino can create a file in an SD card to write and save data using the SD library. There are different models from different suppliers, but they all work in a similar way, using the SPI communication protocol.
This Micro SD Card is used for transfering data to and from a standard sd card. The pin out is directly compatible with Arduino and also can be used with other microcontrollers. It allow us to add mass storage and data logging to our project.
Micro SD Card Module
1. CS (chip select)
2. SCK (serial clock)
3. MOSI (master out slave in)
4. VCC (3.3V or 5V)
5. GND (ground).

ALL SENSOR DETAILS:
1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor
FUTURES:
a. Input Voltage: 3.3V/5V
b. With all SD SPI Pins out :MOSI, SCK, MISO and CS ,for further connection
c. Through programming, you can read and write to the SD card using your arduino
d. Make your SD application more easier and simple
e. Communicate with Arduino using SPI interface
f. Push-pop socket with card slightly over the edge of the PCB so its easy to insert and remove
g. 4 mounting holes with 2.2mm diameter
h. Only use 4 I/O pins on the Arduino
i. Size: 42mm x 25mm x 5mm

SD CARD PIN ARDUINO CONNECTIONS
Vcc 3.3 to 5V DC
CS 4
MOSI 11
CLK 13
MISO 12
GND Ground of Arduino Board

This module uses the standard SPI interface for communication, which involve SPI buses, MISO, MOSI, SCK, and a CS signal pin. through programming, the data can easily be read and wrote into SD Card by using the Arduino or other microcontrollers.
SD CARD WITH ARDUINO UNO CODE:
Copy and paste or download below given link:
//Circuito.io is an automatic generator of schematics and code.
//Copyright (C) 2016 Roboplan Technologies Ltd.
// Include Libraries
#include “Arduino.h”
#include “SD.h”
// Pin Definitions
#define SDFILE_PIN_CS 10
// Global variables and defines
// object initialization
File sdFile;
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println(“start”);
// Set SPI SS pin to output otherwise the SD library functions will not work.
// The SD is set to use SPI SS Arduino pin 10 as chip select(CS) by default.
// To change the pin use SD.begin(SD_CS_PIN)
pinMode(SDFILE_PIN_CS, OUTPUT);
// Check if the card is present and can be initialized
if (!SD.begin()) {
Serial.println(F(“Card failed, or not present”));
while(1);
}
Serial.println(F(“card initialized.”));
menuOption = menu();
}
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == ‘1’)
{
// Micro SD Card Memory Shield Module – Test Code
// The SD example code creates a datalog.txt file for logging sensor data
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
sdFile = SD.open(“datalog.txt”, FILE_WRITE);
// if the file exists in SD card, write sensor data
if (sdFile) {
//Write to file
sdFile.println(“ENTER SENSOR DATA HERE”);
// close the file
sdFile.close();
// Uncomment to print to the serial port
//Serial.println(“ENTER SENSOR DATA HERE”);
}
else {
// if the file didn’t open, print an error
Serial.println(F(“error opening file.”));
}
}
if (millis() – time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F(“\nWhich component would you like to test?”));
Serial.println(F(“(1) Micro SD Card Memory Shield Module”));
Serial.println(F(“(menu) send anything else or press on board reset button\n”));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == ‘1’)
Serial.println(F(“Now Testing Micro SD Card Memory Shield Module”));
else
{
Serial.println(F(“illegal input!”));
return 0;
}
time0 = millis();
return c;
}
}
}
Download SD Card Arduino code: Here.SD card with arduino

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 505

One comment

  1. hi i connected sd card interfacing with Arduino uno and i given pin description MOSI 11, MISO 12, SCK 13, CS 10, iam try to save the ultrasonic sensor values in sd card excel format if any body can know this please reply me thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×