0Pricing
Arduino & IoT Academy · Lektion

CSV auf eine SD-Karte schreiben

Hängen Sie Messwerte an eine Datei an, um sie später zu analysieren.

CSV auf eine SD-Karte schreiben ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why an SD Card?

An SD card gives your device cheap, roomy storage that survives power loss. It is perfect for keeping a long history of logged readings. 💾

Why CSV?

CSV means comma-separated values: plain text where each line is a record and commas split the fields. Spreadsheets open it instantly.

What a Row Looks Like

One log entry per line keeps things tidy. A row might pair a timestamp with a reading so each value has clear meaning later.

2026-06-25 14:03,24.7,55

The SD Module

An SD card module connects over the SPI bus. You wire its MOSI, MISO, SCK, and CS pins to the matching pins on your board.

Starting the Card

Before reading or writing you must initialize the card and tell the library which pin is chip select. If it fails, the card or wiring is off.

if (!SD.begin(10)) { return; }

Opening a File

You open a file by name, choosing a mode. Use FILE_WRITE to add data; it creates the file if it does not exist yet.

File f = SD.open("log.csv", FILE_WRITE);

Appending, Not Overwriting

FILE_WRITE seeks to the end, so each new line is appended. Your old entries stay safe and the history keeps growing.

Writing a Line

You print fields and commas just like Serial output. End the row with println so the next entry starts on a fresh line.

f.print(temp);
f.print(",");
f.println(humidity);

Always Close the File

Calling close() flushes your data and frees the file. Skip it and your last writes may never reach the card.

f.close();

A Header Row

Write a header line once when the file is new, naming each column. Spreadsheets then label your charts automatically.

time,temp,humidity

Don't Write Too Often

Each write costs power and time. For battery nodes, log every few seconds or minutes rather than every loop to keep the card happy.

Quick Check

What happens if you forget to close the file after writing?

Recap

Wire an SD module over SPI, open a CSV file in append mode, print comma-separated rows, and always close it. Now your readings are saved for good. ✅

Häufig gestellte Fragen

Ist die Lektion „CSV auf eine SD-Karte schreiben“ kostenlos?

Ja — der vollständige Text von „CSV auf eine SD-Karte schreiben“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „CSV auf eine SD-Karte schreiben“?

Hängen Sie Messwerte an eine Datei an, um sie später zu analysieren. Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?

Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „CSV auf eine SD-Karte schreiben“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?

Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Mit NTP/RTC die Echtzeit abrufen
  2. CSV auf eine SD-Karte schreiben
  3. Uploads puffern und bündeln
  4. Gespeicherte Daten visualisieren
← Zurück zu Arduino & IoT Academy