SD/MMC
SD/MMC
3.3V to 5V
10mA to 50mA
1GB to 1TB or more
FAT16, FAT32, NTFS
Up to 50MHz
-40C to 85C
Typically 15mm x 15mm x 2mm (L x W x H)
Conclusion
The SD Card Module is a versatile and widely used IoT component that provides a convenient and cost-effective way to add storage capacity to IoT devices. Its compact design, low power consumption, and support for various file systems make it an ideal choice for a wide range of IoT applications.
SD Card Module DocumentationOverviewThe SD Card Module is a widely used IoT component that enables microcontrollers to read and write data to SD cards, greatly expanding their storage capacity. This module is compatible with most microcontrollers, including Arduino, Raspberry Pi, and ESP32/ESP8266.Pinouts and ConnectionsThe SD Card Module typically has the following pinouts:VCC: Power supply (3.3V or 5V)
GND: Ground
SCK: Serial Clock
MOSI: Master Out Slave In
MISO: Master In Slave Out
CS: Chip SelectExample 1: Reading and Writing Files using ArduinoIn this example, we will use the SD Card Module with an Arduino Uno to read and write files to an SD card.Hardware RequirementsArduino Uno
SD Card Module
SD Card (at least 1GB)
Breadboard and jumper wiresSoftware RequirementsArduino IDE (version 1.8.x or later)Code
```c++
#include <SPI.h>
#include <SD.h>// Set the chip select pin for the SD card
const int chipSelect = 5;void setup() {
Serial.begin(9600);
// Initialize the SD card
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
while (1); // Wait forever
}
Serial.println("Card initialized.");
}void loop() {
// Create a file on the SD card
File dataFile = SD.open("data.txt", FILE_WRITE);
if (dataFile) {
dataFile.println("Hello, World!");
dataFile.close();
Serial.println("Data written to file.");
} else {
Serial.println("Error opening file.");
}
delay(1000);
// Read the file from the SD card
dataFile = SD.open("data.txt", FILE_READ);
if (dataFile) {
while (dataFile.available()) {
Serial.write(dataFile.read());
}
dataFile.close();
} else {
Serial.println("Error opening file.");
}
delay(1000);
}
```
Example 2: Logging Sensor Data using Raspberry PiIn this example, we will use the SD Card Module with a Raspberry Pi to log sensor data from a temperature and humidity sensor.Hardware RequirementsRaspberry Pi
SD Card Module
DHT11 temperature and humidity sensor
Breadboard and jumper wiresSoftware RequirementsRaspbian OS (version 10 or later)
Python 3.xCode
```python
import os
import time
import Adafruit_DHT# Set the pin for the DHT11 sensor
DHT_PIN = 17# Set the file path for the log file
LOG_FILE = "/mnt/sdcard/log.csv"while True:
# Read the temperature and humidity data from the DHT11 sensor
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, DHT_PIN)
# Create a string to write to the log file
log_string = f"{time.strftime('%Y-%m-%d %H:%M:%S')},{temperature},{humidity}
"
# Write the log string to the file
with open(LOG_FILE, 'a') as f:
f.write(log_string)
# Print the log string to the console
print(log_string)
# Wait 1 minute before logging again
time.sleep(60)
```
These examples demonstrate the basics of using the SD Card Module with different microcontrollers. You can modify the code to suit your specific requirements and applications.