sd_card_logger.ino

M5Stack PaperDIY Complete Kit ESP32-S3 e-paper Development Kit · File : sd_card_logger.ino · Language : C++ (Arduino) · Use case : Enregistrer des données temporelles sur la carte MicroSD.

Writes timestamped data to a text file on the SD card.

Insert a FAT32-formatted MicroSD card. Change the SD_CS pin according to the PaperDIY electrical schematic. The code creates or appends to 'log.txt'. Check write permissions if the file is not created.

sd_card_logger.ino

#include <Arduino.h>
#include <SD.h>
#include <FS.h>

// Broches SPI génériques ESP32-S3 (à adapter selon schéma PaperDIY)
#define SD_CS 53 

void setup() {
  Serial.begin(115200);
  if (!SD.begin(SD_CS)) {
    Serial.println("Card Mount Failed");
    return;
  }
  Serial.println("SD Card initialized");
}

void loop() {
  File dataFile = SD.open("log.txt", FILE_APPEND);
  if (dataFile) {
    dataFile.print(millis());
    dataFile.print(", ");
    dataFile.println("Sensor Data Placeholder");
    dataFile.close();
    Serial.println("Data logged");
  } else {
    Serial.println("Error opening log.txt");
  }
  delay(5000);
}

← Back to the board