Data Logging with SD Cards
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.
- Arduino Uno
- A-B USB Cable
- Power Supply (9V/holder, USB Power Adapter, or AC/DC Adapter)
- Sharp GP2Y0A41SK0F IR Distance Sensor with Cable
- Real-Time Clock Breakout (or self-assembled RTC circuit) (Not needed if using Adafruit Data-Logging Shield)
- SD card Shield & SD Card (Cooking-Hacks MicroSD Shield, Arduino Wireless Shield, Arduino Ethernet Shield, Arduino Wi-Fi Shield, Adafruit Data-Logging Shield, or SparkFun MicroSD Shield)
- Jumper Wires
- Computer with SD Card Reader
- Arduino SD Library Reference
- RTCLib Real-Time Clock Library Download
- Sharp IR Distance Sensor Datasheet (PDF)
- Pre-formatted Google Spreadsheet for Graphing Logged Data
Color Wiring Diagrams
Follow along with this video tutorial about data logging:
Follow along with this more advanced video tutorial about logging GPS data:
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, www.cooking-hacks.com (source)
- Figure 13-8: Arduino Wireless SD Card Shield Photo Credit: Arduino, www.arduino.cc (source)
- Figure 13-9: Arduino Ethernet Shield Photo Credit: Arduino, www.arduino.cc (source)
- Figure 13-10: Arduino Wi-Fi Shield Photo Credit: Arduino, www.arduino.cc (source)
- Figure 13-11: Adafruit Data-Logging Shield Photo Credit: Adafruit Industries, www.adafruit.com (source)
- Figure 13-12: SparkFun Micro SD Card Shield Photo Credit: SparkFun (Photographer Juan Peña), www.sparkfun.com (source)