The Adafruit SPI Flash SD Card is a versatile breakout board designed for data storage and retrieval using SPI (Serial Peripheral Interface) communication. This component is ideal for projects requiring external memory, such as data logging, audio recording, or firmware updates. It is compatible with both 3.3V and 5V microcontrollers, including popular platforms like Arduino, ESP8266, and Raspberry Pi.
Pin Number | Pin Name | Description |
---|---|---|
1 | CS | Chip Select for the SPI flash memory |
2 | SCK | Serial Clock for SPI communication |
3 | MISO | Master In Slave Out for SPI communication |
4 | MOSI | Master Out Slave In for SPI communication |
5 | GND | Ground connection |
6 | VCC | Power supply (3.3V to 5V) |
7 | CS_SD | Chip Select for the microSD card |
8 | CD | Card Detect for the microSD card |
#include <SPI.h>
#include <SD.h>
const int chipSelectSD = 10; // Chip Select pin for SD card
void setup() {
Serial.begin(9600);
while (!Serial) {
; // Wait for serial port to connect.
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelectSD)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop() {
// Open a new file to write to it.
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// If the file is available, write to it.
if (dataFile) {
dataFile.println("Data log entry");
dataFile.close();
Serial.println("Data written to datalog.txt");
} else {
// If the file isn't open, pop up an error.
Serial.println("error opening datalog.txt");
}
}
SD.cardType()
function to verify the SD card type and ensure compatibility.Q: Can I use this breakout board with a 5V microcontroller? A: Yes, the board includes level shifters to interface with both 3.3V and 5V microcontrollers.
Q: What is the maximum size of the microSD card that I can use? A: The breakout board supports SD, SDHC, and SDXC cards, typically up to 2TB, depending on the SD card specifications.
Q: How do I select between the SPI flash and the microSD card? A: You control which memory is active by setting the corresponding chip select (CS) pin LOW. Only one CS pin should be LOW at a time to communicate with the desired memory.
This documentation provides a comprehensive guide to using the Adafruit SPI Flash SD Card breakout board. For further assistance, consult the Adafruit forums or the community resources available online.