Data logging: SD, EEPROM and flash lesson plan
Keep data through resets and power cuts: the Uno's EEPROM and its wear, a 24LC256 on I2C, SD cards and FAT, CSV logs with DS3231 timestamps, safe writes, and a month-long weather balloon flight recorder.
Objectives and materials
By the end, students can
- Small memories that survive the power going off.
- FAT, CSV logs and real timestamps.
- What reaches the card when the power goes.
- A weather balloon flight recorder built to log for a month.
Materials for the whole unit
- Arduino Uno R3
- Half breadboard
- I2C EEPROM, 24LC256
- LED
- microSD card module
- Real-time clock, DS1307
- Real-time clock, DS3231
- Resistor x 2
- Temperature sensor, DS18B20
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
EEPROM
Small memories that survive the power going off.
| Lesson | Time | What students do |
|---|---|---|
| EEPROM and wearThe Uno's own 1024 bytes of EEPROM: a boot counter that survives a reset, settings saved as a struct, and the sums for a cell rated at 100,000 writes. | 50 min |
|
| A 24LC256 on the bus32 KB of I2C EEPROM: page writes, the write cycle found by ACK polling, and the page wrap bug that a wrong page size causes. | 50 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- I2C EEPROM, 24LC256
- Real-time clock, DS1307
Check for understanding
Each student finishes "A 24LC256 on the bus" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Which memory for what".
Files on an SD card
FAT, CSV logs and real timestamps.
| Lesson | Time | What students do |
|---|---|---|
| SD cards and FATA microSD card on SPI: blocks, a FAT16 file system, listing the card, and why a file name has to fit in eight characters and three. | 50 min |
|
| CSV logsA temperature every second appended to LOG.CSV: a header row, one record per line, a separator, and the file printed back on demand. | 50 min |
|
| Timestamps from an RTCRows stamped by a DS3231: why millis() is not a time, Unix time, a date that rolls over at midnight by itself, and an ISO 8601 timestamp. | 50 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- LED
- microSD card module
- Real-time clock, DS3231
- Resistor x 2
- Temperature sensor, DS18B20
Check for understanding
Each student finishes "Timestamps from an RTC" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Log in UTC".
Surviving power loss
What reaches the card when the power goes.
| Lesson | Time | What students do |
|---|---|---|
| Power-loss safe writesA file kept open for speed: what flush() really does, a power cut that loses the unflushed rows, and the trade between speed, wear and safety. | 50 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- LED
- microSD card module
- Real-time clock, DS3231
- Resistor x 2
- Temperature sensor, DS18B20
Check for understanding
Each student finishes "Power-loss safe writes" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Designing for power loss".
Boss project
A weather balloon flight recorder built to log for a month.
| Lesson | Time | What students do |
|---|---|---|
| Boss: a month-long flight recorderA weather balloon logger built for a month: a file per day named by the RTC, timestamp, temperature and altitude rows, the flight number in EEPROM, and a resume after a power cut. | 65 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- LED
- microSD card module
- Real-time clock, DS3231
- Resistor x 2
- Temperature sensor, DS18B20
Check for understanding
Each student finishes "Boss: a month-long flight recorder" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it your recorder".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.