Hardware Reference
In-Depth Information
FormattingDatawithCSVFiles
CSV, or comma-separated value, files will be the format of choice for storing
data with your SD card. CSV files are easy to implement with a microcontroller
platform and can easily be read and parsed by a wide range of desktop appli-
cations, making them well suited for this kind of task. A standard CSV file
generally looks something like this:
Date,Time,Value1,Value2
2013-05-15,12:00,125,255
2013-05-15,12:30,100,200
2013-05-15,13:00,110,215
Rows are delimited by new lines, and columns are delimited by commas.
Because commas are used to distinguish columns of data, the main require-
ment is that your data cannot have commas within it. Furthermore, each row
should generally always have the same number of entries. When opened with
a spreadsheet program on your computer, the preceding CSV file would look
something like this.
Table 13-1: An Imported CSV File
DATE
TIME
VALUE1
VALUE2
2013-05-15
12:00
125
255
2013-05-15
12:30
100
200
2013-05-15
13:00
110
215
Because CSV files are just plain text, your Arduino can easily write to them
using familiar print() and println() -style commands. Conversely, Arduinos
can also parse CSV files with relative ease by looking for newline and com-
mand delimiters to find the right information.
PreparinganSDCardforDataLogging
Before you start logging data with your Arduino, prepare the SD card you plan
to use. Which kind of SD card you use will depend on the kind of shield you are
using. Some will use full-size SD cards, others will use micro SD cards. Most
micro SD cards ship with an adapter that lets you plug them into standard-sized
SD card readers. To complete the exercises in this chapter, you need an SD card
reader for your computer (either built in or external).
 
Search WWH ::




Custom Search