C. SD.begin() should check if initialization succeeded
D. dataFile.println() is not a valid function
Solution
Step 1: Review SD card initialization
SD.begin() returns true if SD card initializes correctly; this should be checked to avoid errors.
Step 2: Check other code parts
File object can be global, SD.open() supports FILE_WRITE, dataFile.println() is valid.
Final Answer:
SD.begin() should check if initialization succeeded -> Option C
Quick Check:
Always verify SD.begin() success [OK]
Hint: Always check SD.begin() returns true before using SD card [OK]
Common Mistakes:
Ignoring SD.begin() return value
Thinking File must be local to loop()
Believing SD.open() can't write files
Assuming dataFile.println() is invalid
5. You want to log temperature data every minute to an SD card using Arduino. Which approach best ensures data is saved even if power is lost suddenly?
hard
A. Open the file once in setup(), write all data in loop(), then close in loop()
B. Store all data in an array and write to SD card once after many readings
C. Write data only to Serial monitor without SD card
D. Open the file, write data, and close the file each time in loop()
Solution
Step 1: Understand data safety on power loss
Data saved to SD card only after file is closed or flushed; keeping file open risks data loss.
Step 2: Evaluate options for safe logging
Opening, writing, and closing file each time ensures data is saved immediately. Other options risk losing data if power fails.
Final Answer:
Open the file, write data, and close the file each time in loop() -> Option D
Quick Check:
Close file after each write to save data safely [OK]
Hint: Close file after each write to avoid data loss [OK]
Common Mistakes:
Keeping file open all time risking data loss
Logging only to Serial without saving
Delaying writes causing big data loss on failure
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.