Codey OnlineBiblioteka komponentów Arduino i ESP32 › Micro SD Card Adapter Module 3.3V for ESP32 and ESP8266
Micro SD Card Adapter Module 3.3V for ESP32 and ESP8266
Czujniki

Micro SD Card Adapter Module 3.3V for ESP32 and ESP8266

Moduł gniazda karty Micro SD 3,3 V, płytka z interfejsem SPI kompatybilna z ESP32, ESP8266 i Arduino

Szerokość: 21.5 mm

Pinout — Micro SD Card Adapter Module 3.3V for ESP32 and ESP8266

Pin Sygnał Opis
3V3 power 3.3V supply input for the microSD module and SD card logic.
CS chip-select SPI chip-select input for enabling the microSD card.
MOSI MOSI SPI data from MCU to microSD card.
CLK SCK SPI clock input from the MCU for SD card communication.
MISO MISO SPI data from microSD card back to the MCU.
GND ground Ground reference for power and SPI signals.

Przykładowy schemat połączeń — Micro SD Card Adapter Module 3.3V for ESP32 and ESP8266

Z Do Przewód
board:5V x1:3V3 red
board:GND x1:GND black
board:D10 x1:CS green
board:D11 x1:MOSI blue
board:D13 x1:CLK yellow
board:D12 x1:MISO purple

Przykładowy kod Arduino — Micro SD Card Adapter Module 3.3V for ESP32 and ESP8266

Ten przykład został napisany i sprawdzony kompilacją dla arduino-uno. Codey Online dostosuje go do każdej innej obsługiwanej płytki.

#include <SPI.h>
#include <SD.h>

const int SD_CS_PIN = 10;

void printFileToSerial(const char *filename) {
  File file = SD.open(filename, FILE_READ);
  if (!file) {
    Serial.print("Failed to open ");
    Serial.println(filename);
    return;
  }

  Serial.print("\nContents of ");
  Serial.println(filename);
  while (file.available()) {
    Serial.write(file.read());
  }
  Serial.println();
  file.close();
}

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  Serial.println("Initializing Micro SD card...");

  if (!SD.begin(SD_CS_PIN)) {
    Serial.println("SD card initialization failed!");
    Serial.println("Check wiring, card format, and that the card is inserted.");
    while (true) {
      delay(1000);
    }
  }

  Serial.println("SD card initialization done.");

  File root = SD.open("/");
  if (root) {
    Serial.println("Root directory:");
    while (true) {
      File entry = root.openNextFile();
      if (!entry) break;
      Serial.print("  ");
      Serial.print(entry.name());
      if (entry.isDirectory()) {
        Serial.println("/");
      } else {
        Serial.print("\t");
        Serial.println(entry.size());
      }
      entry.close();
    }
    root.close();
  }

  // Create a simple demo file if it does not already exist.
  if (!SD.exists("demo.txt")) {
    File file = SD.open("demo.txt", FILE_WRITE);
    if (file) {
      file.println("Hello from the Arduino Uno SD card example!");
      file.println("This file was created by the sketch.");
      file.close();
      Serial.println("Created demo.txt");
    } else {
      Serial.println("Could not create demo.txt");
    }
  }

  printFileToSerial("demo.txt");
  Serial.println("Setup complete.");
}

void loop() {
  // Periodically show that the card is still accessible.
  File file = SD.open("demo.txt", FILE_READ);
  if (file) {
    Serial.print("demo.txt size: ");
    Serial.println(file.size());
    file.close();
  } else {
    Serial.println("Could not reopen demo.txt");
  }

  delay(5000);
}

Podobne komponenty

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Zbuduj swój projekt Arduino lub ESP32 z pomocą AI

Opisz, co chcesz zbudować. Codey Online napisze kod, narysuje schemat połączeń, skompiluje projekt i wgra go na płytkę bezpośrednio z przeglądarki.

Zacznij za darmo