Take the course at /learn/path/data-logging-and-storage. It is an intermediate course: it assumes the Uno course.
The lessons
EEPROM. A boot counter and settings in the Uno's 1024-byte EEPROM that
come back after a reset, put() and get(), and the sums for a cell rated at
100,000 writes. Then a 24LC256: page writes, ACK polling through the write
cycle, and a page size bug that wraps a write around its page.
Files on an SD card. Mounting a FAT16 card, listing it, and the 8.3 name rule. CSV rows with a header, read back on demand, and a semicolon for European spreadsheets. Rows stamped by a DS3231: Unix time, a year that rolls over by itself, and ISO 8601.
Surviving power loss. A file kept open and flushed every ten rows: cut the power and count what reached the card, then flush every row and lose none.
Boss. A weather balloon flight recorder: a file per day named from the RTC's date, timestamp, temperature and altitude rows closed after every write, the flight number in EEPROM, and a resume after a power cut.
The benches
The EEPROM lessons open the gallery's clock and memory board: a 24LC256 at 0x50 and a DS1307 at 0x68 on A4 and A5. The other lessons open the temperature data logger: a microSD card on CS 10, MOSI 11, MISO 12 and SCK 13, a DS18B20 on pin 2, a DS3231 at 0x68 and a LED on pin 7. The card starts with one file, README.TXT.
What each sketch does
dlogeeprom: a struct of settings and a boot count at address 0,bandtcommands to change them, and the wear sums forSAVE_EVERY_MIN.dlog24lc: an I2C scan, 100 bytes written from address 40 in chunks split atPAGE_SIZE, ACK polling, and a read-back check.dlogsd: mounts the card, lists the root, and createsFILE_NAME.dlogcsv: LOG.CSV with aSEPseparator, a row a second,dto dump it.dlogrtc: STAMPED.CSV with RTClib timestamps and Unix time.dlogsafe: SAFE.CSV kept open and flushed everyFLUSH_EVERYrows;xstops the sketch dead, as a power cut would, and RESET counts the rows.dlogboss: daily YYYYMMDD.CSV files,LOG_SECONDSbetween rows with aSPEEDUPfor the demo, a flight number in EEPROM, and a resume.
Honest limits
- The EEPROM and the SD card keep their contents through resets within one Run, and start fresh at the next Run. Real ones keep them for years.
- The SD library makes FAT16 short names only: no FAT32, no long names.
- Pressing RESET in the middle of a block write leaves the simulated card
mid-transaction, as a real card would be until its power is cycled. The
power-loss lesson uses
xto stop the sketch between writes instead. - The DS3231 reports lost power at the start, as a fresh module does until
rtc.adjust()sets it.
Related
Clocks, RTCs and time for time zones and RTC alarms, and Low power products for sleeping between log rows.