SD Card - AlexanderTonn/MyArduinoSnippets GitHub Wiki

Table of Contents

  1. Introduction
  2. Wiring
  3. Troubleshooting
  4. Workflows
  5. List of references

Introduction

My repository: https://github.com/AlexanderTonn/MyArduinoSnippets/tree/main/SecureDigitalMemoryCard

Offical pepository: https://github.com/arduino-libraries/SD/tree/master

Used modules

I'm currently using an SD Module in normal size (no micro SD) because i have more normal sized SDHC Cards. I bought this modules on amazon in germany ( Link to AmazonDE ).

2023-06-01-SDPinout

Wiring

Power supply Basically it's recommandable to use a external power supply because the SD Module can generate a consumption up to 200mA which is to high for the internal power supply of the board. In addition to that i prefer using the 5V Pin of the SD module (if existing).

Pin notation In the following table i add the pins which have to be connect on side of arduino with the pins of the SD Module. For the SD Pins are often used two different notations. I added both in each column starting with column 2 but at the end both notations meaning the same pin.

Arduino \ SD Module CS / SS SCK / CLK MOSI / COPI MISO / CIPO
Uno 10 13 11 12
Mega 53 52 51 50
MKR WiFi 1010 7 9 8 10

Arduino MEGA2560

2023-06-02-MEGA2560_wiring

Arduino UNO

2023-06-02-UNO_wiring

  • TODO: Inserting Picture of Pinout

Troubleshooting

Init is failing

  • check your wiring
  • SD Card inserted and formatted with FAT16 or FAT32?
  • if you use the 5V power supply, don't use the 3.3V Pin and play safe that the Voltage is >=5V. In my case it was helpful to increase the Voltage (of my LM317 power supply Circuit) up to 5.1V to prevent voltage drops (for the case that you have more modules connect on 5V the power supply)
  • If you use DC Power Connector for power supply of Arduino: Disconnect the plug while you debugging over USB Interface

Files & Dirs will not create

  • check your init routine. Did you forget SD.begin(ChipSelect)?

Directorys and Files will not create

  • TODO: Inserting content

Workflows

Please consider that the following Chapter only contains pseudo code for explaining the functionalty. Please go to my repository if you need working examples.

File naming: 8.3 Format

While naming files and directorys you have to play safe that the file names are matching with the 8.3 Format convention.

This means that the filename can only have 8 characters and additionally the fileextension can have maximal 3 characters. In addition to that you have to prevent the using of following special characters: ? : *

Writing files

Open File in root path

  1. Open File File file = SD.open(<Filename>,FILE_WRITE);
  • The file will create if the file dosen't exist.
  1. Check in a if loop whether file is present if (file)
  2. Inside of the if loop you can write data file.println(<data>);
  3. After writing you have to close file.close();

List of Sources

⚠️ **GitHub.com Fallback** ⚠️