Chapter 13

Data Logging with SD Cards

Chapter Summary

This chapter covered the following concepts:

  • CSV files use newlines and commas as delimiters to easily store data in a plain text format.
  • You can format an SD card in in Windows, Mac, or Linux.
  • There are a plethora of available SD card shields, each with unique features.
  • You can use the SD Library to write to and read from a file on an SD card.
  • You can build an RTC and write software that utilizes it to insert timestamps.
  • You can overcome RAM limitations by storing strings in flash memory.
  • You can detect movement by looking for changing analog values produced by a distance sensor.
  • You can graph data from a data logger using a spreadsheet on your computer.

Parts List

Useful Links

Color Wiring Diagrams


Follow along with this video tutorial about data logging:

Follow along with this more advanced video tutorial about logging GPS data:


Chapter 13 Code Download

All code is licensed via the GNU GPL v3. Code is maintained and updated on GitHub. The download zip linked above always contains the most recent version of the code examples that have been pushed to the GitHub Code Repository.

Taking it Further

You can use data logging in many different ways. Here are some project suggestions that you can now complete:

  • Build a data logger for an autonomous vehicle or aircraft.
  • Build a wireless weather station that stores weather history.
  • Build a home-efficiency monitor that monitors when you forget to turn your lights off.
  • Build a temperature logger that records how frequently the compressor switches on inside your air conditioner or refrigerator.

References & Credits

  • Figure 13-7: Cooking-Hacks SD Card Shield Photo Credit: Cooking Hacks, (source)
  • Figure 13-8: Arduino Wireless SD Card Shield Photo Credit: Arduino, (source)
  • Figure 13-9: Arduino Ethernet Shield Photo Credit: Arduino, (source)
  • Figure 13-10: Arduino Wi-Fi Shield Photo Credit: Arduino, (source)
  • Figure 13-11: Adafruit Data-Logging Shield Photo Credit: Adafruit Industries, (source)
  • Figure 13-12: SparkFun Micro SD Card Shield Photo Credit: SparkFun (Photographer Juan Peña), (source)