Micro SD -kortinlukija Arduino-, ESP8266-, ESP32- ja Wemos-laitteille tiedostojen lukemiseen ja kirjoittamiseen.
SKU: OT760-D37 Tuotenumero: AA115 EAN: 8720589817258 Sijainti: D03.07
Vaihtoehto
Ethernet Shield W5100 Micro-SD-kortinlukijalla Arduinoon
€ 10,90
Katso tämä vaihtoehto
Näin kytket Micro SD -kortinlukija Arduinoon:n Arduino UNOon tai ESP32:een, mukana esimerkkisketsi, jonka voit ladata heti.
Tämä projekti näyttää, miten 5V Micro-SD-kortinlukija kytketään Arduino Uno -levyyn SPI-kommunikaation avulla. Sketch alustaa SD-kortin, kirjoittaa yhden rivin tekstiä tiedostoon nimeltä test.txt ja lukee tiedoston sitten takaisin Serial Monitoriin. Avaa Serial Monitor nopeudella 115200 baud nähdäksesi tulosteen.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : Read and Write with Micro-SD Card Reader
* Board : Arduino UNO (arduino:avr:uno)
* Parts : Micro-SD Card Reader 5V
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
#include <SPI.h>
#include <SD.h>
const int chipSelect = 10;
void setup() {
Serial.begin(115200);
while (!Serial) {
; // Wait for serial port to connect
}
Serial.println(F("Initializing SD card..."));
if (!SD.begin(chipSelect)) {
Serial.println(F("Initialization failed! Check wiring and FAT16/FAT32 format."));
return;
}
Serial.println(F("Initialization done."));
// Write data to the card
File myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) {
Serial.print(F("Writing to test.txt..."));
myFile.println(F("Hello from Arduino UNO!"));
myFile.close();
Serial.println(F(" done."));
} else {
Serial.println(F("Error opening test.txt for writing."));
}
// Read data back from the card
myFile = SD.open("test.txt");
if (myFile) {
Serial.println(F("--- Content of test.txt ---"));
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
Serial.println(F("--- End of file ---"));
} else {
Serial.println(F("Error opening test.txt for reading."));
}
}
void loop() {
// Demo runs once in setup
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Kytke 5V MicroSD-korttimoduuli ESP32:een käyttämällä 4-kanavaista tasonsiirrintä, jotta turvallinen 3.3V SPI-tiedonsiirto varmistuu. Sketch alustaa SD-kortin VSPI-väylällä, luo ja kirjoittaa testitiedoston sekä lukee sen sisällön takaisin Serial Monitorissa nopeudella 115200 baud.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : ESP32 MicroSD Card Read and Write Demo
* Board : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
* Parts : Micro-SD Card Reader 5V
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
#include "FS.h"
#include "SD.h"
#include "SPI.h"
const int chipSelect = 5;
void setup() {
Serial.begin(115200);
while (!Serial) { delay(10); }
Serial.println("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("Card Mount Failed! Check wiring and ensure a FAT32 card is inserted.");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("No SD card attached.");
return;
}
Serial.print("SD Card Type: ");
if (cardType == CARD_MMC) Serial.println("MMC");
else if (cardType == CARD_SD) Serial.println("SDSC");
else if (cardType == CARD_SDHC) Serial.println("SDHC");
else Serial.println("UNKNOWN");
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);
// Write to a test file
Serial.println("Writing to test.txt...");
File file = SD.open("/test.txt", FILE_WRITE);
if (file) {
file.println("Hello from ESP32 and MicroSD Card!");
file.close();
Serial.println("Write complete.");
} else {
Serial.println("Error opening file for writing.");
}
// Read the test file back
Serial.println("Reading test.txt:");
file = SD.open("/test.txt");
if (file) {
while (file.available()) {
Serial.write(file.read());
}
file.close();
} else {
Serial.println("Error opening file for reading.");
}
}
void loop() {
// Idle
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Tämä micro SD -kortinlukija sopii Arudinoon, ESP8266:een, ESP32:een, Wemosiin jne. Se on jo osa vakio-Arduino-kirjastoa.
Ihanteellinen tiedostojen lukemiseen ja kirjoittamiseen. Tallennuskapasiteetti määräytyy asennetun micro SD -kortin mukaan.
Korttityyppi: Micro SD max. 2GB asti ja Micro SDHC max 32GB asti
Piirivirta: 3.3V ja 5V
Liitännät: VCC, GND, MISO, MOSI, SCK/SPI ja CS

| Virtalähde | 3.3V ja 5V |
|---|---|
| Liitäntä | VCC, GND, MISO, MOSI, SCK/SPI ja CS |
| Sopii | Arduino, ESP8266, ESP32, Wemos |
| Kapasiteetti | jopa 2 GB |
| Korttityyppi | Micro SD |
Toimii oikein, tekee sen mitä lupaa tehdä.
Etkö ole tyytyväinen? Sinulla on 30 päivää aikaa vastaanotosta palauttaa tuote.
Kaikki palautuksista
Micro SD -kortinlukija Arduinoon