Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Prototyping & Wiring
  4. ›SD Card Modules

Component guide · Beginner · 3 min read

SD Card Modules

Data Logging with Arduino and ESP32

By Geekobot Learning Team · Updated 24 Oct 2026

On this page
Short answerWiringLogging to a CSV fileReliable loggingCommon mistakesFAQsParts and next steps
Short answer

A microSD card module lets a microcontroller save files you can open on a computer, such as a CSV of sensor readings. It connects over SPI with four signal wires plus power, and modules for Arduino include a 3.3 V regulator and level shifter. Format the card as FAT32, open the file, write a line and close or flush it often so a power cut does not lose data.

Key specs at a glance

Interface
SPI: MOSI, MISO, SCK, CS
Card voltage
3.3 V; 5 V modules include a regulator and level shifter
Format
FAT16 or FAT32 (cards up to 32 GB are easiest)
Current
Bursts of up to about 100 mA while writing
Libraries
Arduino SD, SdFat; ESP32 SD and SD_MMC
ESP32 option
SD_MMC 1-bit or 4-bit mode for higher speed on boards like ESP32-CAM
01

Wiring

On an Uno: MOSI to D11, MISO to D12, SCK to D13 and CS to D4 or D10, with VCC and GND. Use a module with a level shifter for 5 V boards. On an ESP32, use a 3.3 V module without a regulator, or power the regulated module from 5 V, and use the VSPI pins (23, 19, 18, CS on 5).

Other SPI devices can share MOSI, MISO and SCK, but some cheap SD modules do not release MISO, which stops other devices from working. Test them together early.

02

Logging to a CSV file

Open, write one line, close.

Append a reading to log.csv every second · Arduino C++Verify & upload in Electrolark
#include <SPI.h>
#include <SD.h>
const int CS = 4;

void setup() {
  Serial.begin(9600);
  if (!SD.begin(CS)) { Serial.println("Card failed"); while (1); }
}

void loop() {
  File f = SD.open("log.csv", FILE_WRITE);   // appends on most cores
  if (f) {
    f.print(millis()); f.print(',');
    f.println(analogRead(A0));
    f.close();                               // saves data to the card
  }
  delay(1000);
}
03

Reliable logging

  • ✓Close or flush() after each line or every few lines; data in the buffer is lost if power drops.
  • ✓Use 8.3 filenames (8 characters plus a 3-character extension) with the classic SD library.
  • ✓Add a timestamp from an RTC so readings make sense later.
  • ✓Some cards are not detected; try a different card or format it with the SD Association formatter.
  • ✓For small settings or a few values, EEPROM or the board's flash is simpler.
04

Common mistakes to avoid

  • !Using an exFAT-formatted card with a FAT-only library.
  • !Never closing the file, so data is lost.
  • !A 3.3 V-only module on a 5 V Uno without a level shifter.
  • !A module that blocks the shared MISO line.
  • !Long filenames with the classic SD library.
05

Frequently asked questions

What size SD card can I use?

Cards up to 32 GB formatted as FAT32 work with most libraries. Larger cards need reformatting or the SdFat library.

Why does SD.begin() fail?

Check wiring, the CS pin, the card format and power. Try another card.

Can I use an SD card with ESP32?

Yes, over SPI or with the faster SD_MMC interface on supported pins.

How often should I save?

Close or flush after every line for safety, or every few seconds if speed matters.

Can the SD card share SPI with a display?

Usually yes, with separate CS pins, as long as the module releases MISO.

Parts for this guide

  • SD Card and USB Disk Module
    ₹49View
  • microSD Memory Card (Class 10)
    ₹412View
Shop Interface Modules

Terms in this guide

SPISerial Peripheral Interface: a fast bus with clock, data in, data out and a chip-select line per device.Logic levelThe voltage that represents a digital high: 5 V on classic Arduinos, 3.3 V on ESP32, Pico and Raspberry Pi.LDOLow-dropout regulator: a linear regulator that works with a small difference between input and output.MicrocontrollerA single chip with a processor, memory and input/output pins that runs one program, such as the ATmega328P or ESP32.

Projects that use it

Put this into practice: 104 step-by-step builds in our project library use parts from this guide.

Intermediate · 2–3 hoursGPS route loggerView projectIntermediate · 2 hoursTemperature data loggerView projectIntermediate · 2–3 hoursWeather data loggerView project
Browse all 104 projects

Keep learning

Concept explainerIntermediateSPI ExplainedSPI (Serial Peripheral Interface) is a fast four-wire bus: SCK carries the clock, MOSI carries data from the controller, MISO carries data back, and a separate chip-select (CS) line per device chooses who is listening.3 min read · Electronics FundamentalsComparisonBeginnerDS3231 vs DS1307 Real-Time Clock ModulesA real-time clock module keeps the date and time running from a coin cell while your project is off.3 min read · Semiconductors & ICsComponent guideIntermediateEEPROM and Flash Memory Chips (AT24C256, W25Q)EEPROM and flash chips store data that stays when power is off.3 min read · Semiconductors & ICsHow-toIntermediateESP32-CAMThe ESP32-CAM is a low-cost ESP32 board with an OV2640 2 MP camera and microSD slot but no USB port.3 min read · Boards & MicrocontrollersHow-toIntermediate3.3 V vs 5 V LogicYou need level shifting when a 5 V device sends signals to a 3.3 V board such as an ESP32 or Raspberry Pi Pico, because 5 V on their pins can damage them.4 min read · Prototyping & Wiring

Sources

  • SD Association Physical Layer Simplified Specification
  • Arduino SD library reference
  • SdFat library documentation

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWiringLogging to a CSV fileReliable loggingCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide1 item · ₹49

SD Card and USB Disk Module

Run itChange the inputs and watch the output

The sketch writes to the card, not the Serial Monitor. This shows the lines added to log.csv.

Serial monitor9600 baud
log.csv += 3,458

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question