This is my first in a series of more advanced Arduino tutorials. Now that we’ve covered the basics in tutorials 1-10 (you have watched them all right!?), it’s time to start pursuing some more complex projects! In this episode, we’ll utilize an SD card shield from cooking-hacks.com to create a datalogger. First, I’ll walk you through the process of reading from, and writing to an SD card. Then, we’ll utilize some of our knowledge from tutorials 4, 6, 7, and 8 to add several sensors that we can poll periodically using our datalogger. The logger will record sensor values to its SD card in a useful format so that we can later use a computer program like Microsoft Excel to visualize the data. Download the schematics and source code first so you can reference them while you watch the video. For the first time, I’m using fritzing to draw the circuit schematics. So, take a look at them, and let me know what you think!
You can download the files associated with this episode here:
Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.
279 comments
Sorry that may have been a little vag. I am connecting the 27937 straight to the arduino is that right? I have a FAT32 memory stick that the 27937 says it supports.
Does that module have logic level shifting built in? SD cards are 3.3V but the arduino is 5V.
I am trying to write a timestamp to a csv file. Using the Time.h file I’ve created:
time_t myTime;
int myHour;
int myMinute;
int mySecond;
int myYear;
int myMonth;
int myDay;
then:
myDay = day()
….etc
I can print using > Serial.print(myDay);
But I cannot use:
String completeDate = String(myYear) + ‘-‘ + String(myMonth) + ‘-‘ + String(myDay) + ‘\t’ + String(myHour) + ‘:’ + String(myMinute) + ‘:’ + String(mySecond);
Serial.println(completeDate);
This, however, looks a lot like your code for this example (see line 112 in datalogger.pde)
Thanks in advance for any advice!
Hi Jeremy,
Nice tutorial, thank you. I’m wondering if it is possible to access the SD card via the Serial port?… so lets say we have a closed data logger box with simply a serial port connector on the side – could we send a command to Arduino via Serial eg ‘R’ (for Retrieve) and Arduino would respond be sending the SD card contents down the Serial port? I guess it would need some sort of VB app or similar to re-assemble the data into a file?…. hmmmm would be great but I expect its complicated :-)
Yes, you could do something like that. The arduino would wait for a command on the UART, and based on that command, it would send a command via SPI to the SD card, read data out into its RAM, then send it back over Serial.
Hi Jeremy, thanks a lot for all tutorials. They help me a lot.
I did find lots of tutorials about how to make a Datalogger, but normally the data is managed in the computer.
I’m with a problem when I need to manage data from a CSV file in the arduino.
Basically, it has three columns and I need to compare data that came thru the GPRS module with the first field of the CSV file.
Do you have anything like this to show me or have some clues about it?
Again, thank you very much a a very good new year.
Joselio
massive thanks for the tutorials they’ve been a really helpful.
is there anyway of increasing the a value of the .csv file each time the power is applied and remove to the arduino? for example,
log1.csv
log2.csv
log3.csv
etc
to record multiple sessions?
Thanks Sean
You could store the previous number in EEPROM and increment it each time.
Hello, Jeremy.
hi im beginner in arduino. this is nice blog and nice tutorial….How does the program when the data logger was given RTC DS1307??
is too complicated??
i want to know if gps data logger can be done with basic arduino uno itself instead of gng for rev2 or rev3 please help me asap
yes
Thanks for the tutorial, if you were to use a Leonardo would you just need the SD Card holder and the resistors to set this up on your own prototype board as it has a 3.3V regulated supply?
You still need to shift the level of the SPI communication
When i simulate it with Proteus, the “Card Failed” message is displayed. Why?
well jeremy can you mail me the schematic of the sensor circuit with sd card and all that
It is available for download above.
Hi Jeremy…
Is it necessary to convert the the value into ASCII format before writing it to the SD card for Datalogger,
Hello i have a arduino mega 2560 and the same sd module. SCK–>52 , MISO–>50 , MOSI–>51 , SS–>53 , GND–>GND , 3.3–>3.3. 2gb micro sd FAT16 formated(windows 7). i cant accsess the card. I get Card Failure error. Do you have some suggestions ? Thank you in advance
Is it possible to record the data, for example light data, in SI units? And how?
Hey Jeremy, great tutorial as usual!
Quick question, I was successively able to get the SD_write & the SD_read_write sketches to run with no problems or errors. However, with the datalogger sketch, the Arduino will only write about 4-5 iterations in the CSV file, and then stop, usually with random symbols entered in the data fields. I have troubleshooted as much as I can to my ability, and can not seem to fix the error. Any suggestions?
Thanks in advance!
Mike
Have you tried running the SPI communication at a lower speed? http://arduino.cc/en/Reference/SPISetClockDivider
Hi, Jeremy, I tried adjusting the SPI clock speed using SPI.setClockDivider() command, and tried all values 2-128, and am still having errors. At one point I got about 16 itterations, but their it errored out and stopped recording.
Do you have any other suggestions?!
Have you tried a different SD card?
Hi Jeremy, thanks again for the reply.
Yes, I have tried multiple micro-SD cards. I originally started with the 2gb card that came with the card reader shield , and I also tried another 1gb SD card that I had laying around. I formatted them both to FAT16 format, using Windows 7. I also tried formatting them to FAT32, but made no difference and I re-formatted them back to FAT16. As I mentioned earlier, I had absolutely no problems with the SD_Read_Write sketch, and was able to successfully write and read to the .txt file with no problems at all, both saving it to the file and having it display in real time in the serial monitor.
What kind of delay are you using between writes? You may be writing too frequently.
Hi Jeremy, sorry for the delayed response.
My initial delay between writes was what you suggested in the tutorial, once every second. I have tried different timings; every 2 seconds, every 500ms, and the most successful write was at 250ms, which gave me about 20 iterations, and then stopped. As odd at it seemed, the most successful writes were at the fastest delay timing. Like I said, I have tried everything I could to my ability to troubleshoot. I’m wondering if it has something to do with the latest version of the Arduino software..? Just for kicks, have you tried uploading your code recently with the latest software version?
I haven’t maybe you can download an old version of the IDE and try it? I know other people have run this successfully with Arduino 1.0+, so I doubt that is the problem.
Ok, I looked into this a bit more. I suspect you are running out of RAM. If you are using Serial in your program, remove all calls to Serial.print or Serial.println (they are for debugging anyways).
Odds are good that the literal strings within those calls are using up all your RAM and causing your problems.
Hi Jeremy,
Thanks for these wonderful tutorials.
I am facing similar problem as Mike S. In my case the file is created during setup() but during loop() it is unable to access the file(“Couldn’t open log file”). I have also tried the datalogger example given by Tom Igoe(available with arduino IDE), which stops after writing 5-6 values.
I have tried both ATmega1280 and ATmega2560 with different SD and MicroSD cards.
I have Also tried running the SPI communication at a lower speeds.
I found out what was the mistake i was doing, but didn’t have time to post earlier…..
I had very same problem as Mike S.
When working with SD card please try to Format it with FATx with block size of 512 bytes or 1024 bytes (at max).
After correcting my mistake i have been working with my SD card flawlessly……
Correct me if am wrong………
hi jeremy
very good tutorial.
i am attempting a data logging project but am very stuck with extracting data from the sd card and using it in an arduino sketch. i have a csv file with various types of data, eg 1,2,30,kitchen,0,0,
im trying to read this whole line from the file on the sd card to a buffer so i can split the data but i cannot work out how to read from the card.
any help would be much apreciated.
thanks alot sammy
Hi, I am having the same problem, I bought the openlog and I haven’t been able to use it. First how do we connect it to arduino Uno so that I can make it to create a csv file and then every 3 or 4 minutes add the data from some sensors to the file? I have searched the web but I haven’t found a solution.
Hi jeremy
I would like to know how to use the Arduno Uno bord with Seeedstudio SD Card Shield V.3.0, Please can you help me ?
** about – some source code and the example to connecting the bord with analog sensor
thank you
Mr.Nattachai
Hi jeremy,
I tried SD_WRITE example you’ve given. It works fine in the serial monitor and prints ‘ hello ‘ every 5 secs.
Then I ‘ reset ‘ the arduino and then removed the power of arduino and then I removed the SD CARD and put that in my windows 7 pc.
In my computer the SD CARD shows a weird name with strange symbols ( SD card name I first used as SD CARD, but it has been replaced with some meaning less charactrs ).
And then I opened the sd card . Unfortunately there are number of files with more weird names ( nothing can be understood . even those charactors are not in the key board to type ) .
So I tried to open all of them but ended up with windows errors .
Any solution ?
Thanks.
Shanuka.
Did you make sure to format the card first?
Jeremy,
I also have another problem.
In my project datalogger ( using SD card ) is a one part.
I also have a LCD display connected which shows the values ( that are to be logged into a card ).
My problem is, LiquidCrystal.h library uses PINs as follow,
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
And also the SD CARD module also uses some of those mentioned pins ( 11,12 ).
I think we cant change what’s written in the library.
So what would be the solution.
Many Thanks.
Dileesha.
dear jeremy,
im using an arduino mega board to do this sd card logging thing,, but it always says that “sd card invalid”…….
i plugged into the arduino mega 2560 digital pin 8-13 and the ground this cool hacks sd card shield for arduino…..
please help me with this thing……
loking for help asap, because this is based on my final year project..
Hi mate,
for someone so young you are a clever dude who really understands electronics and embedded programming. Thank you for these tutorials.
hi Jeremy, i have more sensors, this sensor send states to a csv file into sd card build on ethernet shield.
now i want see this states in real time and i want to save the csv file on my remote pc.
the first point was made but the second no.
how i can do it?
tnx
Consider using a service like cosm.com
hey Jeremy, thanks for the tutorial can you please post where i can get arduino chip and which specific one you used. can you also post a link to the data sheet
thanks
Frankie
Hi Jeremy
Thank you for the tutorials.
I am trying to build a datalogger than can sample up to a 600kHz sine wave and store the data onto a csv file; similar to what you did in your tutorial but much more demanding on the microcontroller.
After several days of trials, I am beginning to think that the Arduino is not up to the task; I am trying for a 9.6kHz sampling frequency, but I think the bottle neck is really the speed at which data can be logged onto the SD chip.
Do you have any suggestions? Should I look for a different board?
oops, I meant to say 600Hz, not 600kHz.
You may be better off doing this with a dedicated Data Acquisition Device feeding into your computer.
Hi Jeremy,
I have tried your code but comment the read the file part . the problem that i am facing is when writing , after write two or three times my arduino UNO gets lag and sometimes prints garbage in serial interface..
This is the data string
String dataString = String(id) + “, ” + String(light_level) + “, ” + String(IR1_val) +”, ” + String(IR2_val);
If i make it as following it writes and i can see whats it writing from serial interface
String dataString = String(id) + “, ” + String(light_level) + “, ” + String(IR1_val) ; // i just reduce one string..
So what might be the problem.. when i load original code of yours without any modifications also the same happens as i mentioned at the start…
hope to get a solution
This could mean that you are running out of RAM. Consider decreasing the number of static strings you are using to see if that helps.
I highly appreciate Jeremys’ work and tutorial.
Also I found another working example for those who want to WRITE DATA to a SD CARD. May be Jeremy can modify it .
Below is the code. This also works . ( But you need the ‘SD’ library installed, normally it comes with the latest arduino IDE )
/////////////////////////////////////////////////////////////////////////////////
/* FILE: ARD_SD_CARD_MODULE_HCARDU0008_Write_Example.pde
DATE: 09/07/12
VERSION: 0.1
This is an example of how to use the HobbyComponents SD card reader module
(HCARDU0008). This module allows reading and writing of data to a standard
SD card and is useful for applications such as data loggers where a large
amount of data needs to be stored. The module works with the standard
Arduino SD card library.
This example program will create a test file on the SD card called test.txt
If the file already exists it will first delete it and then create a new
one.
MODULE PINOUT:
PIN 1: GND —> Arduino GND
PIN 2: +3.3V —> Arduino 3V
PIN 3: +5V —> Arduino 5V
PIN 4: CS —> Arduino DIO 4
PIN 5: MOSI —> Arduino DIO 11
PIN 6: SCLK —> Arduino DIO 13
PIN 7: MISO —> Arduino DIO 12
PIN 8: GND —> N/A
You may copy, alter and reuse this code in any way you like but please leave
reference to HobbyComponents.com in your comments if you redistribute this code. */
/* Include the standard SD card library */
#include
#define SD_CARD_CD_DIO 4 /* DIO pin used to control the modules CS pin */
File SDFileData;
/* Initialise serial and DIO */
void setup()
{
Serial.begin(9600);
/* DIO pin used for the CS function. Note that even if you are not driving this
function from your Arduino board, you must still configure this as an output
otherwise the SD library functions will not work. */
pinMode(10, OUTPUT);
}
/* Main program loop */
void loop()
{
/* Initiliase the SD card */
if (!SD.begin(SD_CARD_CD_DIO))
{
/* If there was an error output this to the serial port and go no further */
Serial.println(“ERROR: SD card failed to initiliase”);
while(1);
}else
{
Serial.println(“SD Card OK”);
}
/* Check if the text file already exists */
while(SD.exists(“test.txt”))
{
/* If so then delete it */
Serial.println(“test.txt already exists…DELETING”);
SD.remove(“test.xlsx”);
}
/* Create a new text file on the SD card */
Serial.println(“Creating test.txt”);
SDFileData = SD.open(“test.txt”, FILE_WRITE);
/* If the file was created ok then add come content */
if (SDFileData)
{
SDFileData.println(“Print this to file”);
/* Close the file */
SDFileData.close();
Serial.println(“done.”);
}else
{
Serial.println(“Error writing to file !”);
}
/* Do nothing */
while (1);
}
//////////////////////////////////////////////////////////////////////////////////
Thanks,
Dileesha.
Hi Jerremy,
How would I go about creating a data and time stamp for my datalogger rather than the simple id# in you sketch?
If I knew how to get a date and time stamp, I can just substitue it for the id#, but I don’t know where to go to find that info.
Scott
You’ll need to use a Real Time Clock. Most are I2C.
Hi, how i can read another serial (rfid) . I need have just one access to one local exclusive, and logging this..
Sorry for my bad english
Regards
Salvo
I am building a data logger for 10 analog input and two pulse input. Can l use 4051 as a multiplexer but how. I need the schematic diagram and how to connect it to the arduino UNO (2) from Delft University of Technology as part of Marker package for Tahmo sensor competition. I have SD card shield or reader which l wanted you to see if l can use instead of the one you recommended(micro SD module which we cannot get now because of time. The competition is ending on 30th June. I will mail the SD shield picture to you to advice me on how to use it. Thanks so much for all the tutorials, you are a genius. I have tried my hand on C ++ before but with your tutorial it made it very easy.
These instructions should work fine with any SD card reader/writer – they are basically all the same. As for the 4051 Multiplexer, this page explains how to hook one up: http://playground.arduino.cc/learning/4051
hai jeremy………
how to programming arduino web server with css file embeeded sd card, but html file embedded at arduino
Hi Jeremy,
Is there are way to read the last line of a file and replace it with another line.
I am logging data to a XML file on the SD card but I need to be able to replace/delete the last line which is the closing of the main block , add/append some more content and add the closing block back in.
eg:
……
would like to to remove the “” (last line) add more content and then re write the last line back in again.
Thanks
George
hi jeramy i just want to know that what is the memory limit of this sd card module??? its very important to my project ,,, im going to do your gps thing as my final year project,,,, thanz jeramy you saved my life,,,, :)
2GB. That’s enough to store millions of data points.
How would I modify the datalogger file if I wanted to use 2 or 3 of the DS18B20 digital temperature sensors instead of the analog ones? I’d want the temps in celcius logged to the SD as csv along with date and time.
Any help would be greatly appreciated – I’m new to Arduino and found your tutorials very helpful. Keep them coming.
Hello! I am creating a piggybank with a counter (LCD and coin acceptor) I want to add sd card to save the total amount; in this case I want to read the last line in the file on my sd! How is that possible??
Yes, you’ll need to read the file line by line until you find a line with no carriage return at the end. Then use the value from that line.
http://arduino.cc/en/Reference/FileRead
do find on “no return” then read the line
Hello, I’m trying to connect the Arduino with Simulink and read data throgh serial port, How can I do that?
Hold tight, I’m working on a tutorial for this.
Thanks for the replies about reading the last line… I still can’t figure it out with the code though! :( there are no examples on the Internet.. Looks like it is impossible. I only read about other ways to handle that on the forums! And I found a way myself! (I hope). Is to delete the file every time a new value writes to the sd! I’ll try that instead all though its not my favorite action!
instead of making tedious stuff like decade … y dont u use …
float refreshrate=0.0 //initialize
while(commandFile.available())
{
float temp= (commandFile.read() – ‘0’)
refreshrate=(refreshrate*10)+temp;
}
Hi Jeremy,
I’ve been working on a project and have hit a wall with reading files from the SD card. I have had no problems writing to the card. However, I saw that when it reads data from the SD card, it reads it as bytes and not data. Is there another SD library out there that allows the read command to read data? I find it odd that the write command can write data but I can’t do the same for read.
Thanks!
Actually, scratch what I just said. I didn’t understand the serial port stuff correctly until just now. Tried what you had with a few different files and it worked for me. However, how would I go about using the same logic for the integer vales in a file that contains more then one line? I tried doing it, and just received rubbish back,
Thanks again!
You should be able to read the buffer up until a newline character, then start looking for a character on the next line.
Counter Mechanism
Designing a system using arduino uno, and the Adafruit datalogger shield.
Purpose is to read two analog inputs and based on the values turn the LEDs high or low, and record part counts. Analog input is reading the value from two different potentiometers. One to select the “Operation type” and second to select “part type”. There is a reed switch between part type pot and 5V. The reed switch is activated each time operation is complete. So here is what I need to do –
Every time a part is made, I want to record the timestamp, what is op type, what is part type, and count.
I have the sketch for turning On the LEDs and counting the number of parts. I need help with recording data and writing it to SD card in CSV format :
Sketch –
const int analogPin = A0; // pin that the sensor is attached to
const int ledgoodPin = 9; // pin that the LED is attached to
const int ledbadPin = 8;
const int ledsetupPin = 7;
const int analog2Pin = A1; // pin that the sensor is attached to
const int ledop1Pin = 2; // pin that the LED is attached to
const int ledop2Pin = 3;
const int ledop3Pin = 4;
int goodcount = 0;
int badcount = 0;
int setupcount = 0;
int good = 0;
int prevgood = 0;
int OFF = 0;
int ON = 1;
int bad = 0;
int prevbad = 0;
int idle = 0;
int previdle = 0;
void setup() {
pinMode(ledgoodPin, OUTPUT);
pinMode(ledbadPin, OUTPUT);
pinMode(ledsetupPin, OUTPUT);
pinMode(ledop1Pin, OUTPUT);
pinMode(ledop2Pin, OUTPUT);
pinMode(ledop3Pin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the value of the operation potentiometer:
int analog1Value = analogRead(analog2Pin);
if (analog1Value >0 && analog1Value 400 && analog1Value 900 && analog1Value 214 && analogValue 900) {
digitalWrite(ledgoodPin, HIGH); // turn on the Good part LED
good = ON;
}
else {
digitalWrite(ledgoodPin,LOW);
}
if (prevgood == OFF && good == ON) {
goodcount++; record timestamp
Serial.println(goodcount);
}
}
prevgood = good;
if (analogValue > 111 && analogValue 223 && analogValue 170 && analogValue 450 && analogValue < 610) {
digitalWrite(ledsetupPin, HIGH);
idle = ON;
}
else {
digitalWrite(ledsetupPin,LOW); }
}
if (previdle == OFF && idle == ON) {
setupcount++; record timestamp
Serial.println(setupcount);
}
previdle = idle;
delay(1000); // delay in between reads for stability
}
Hey Jeremy, sorry I gave the code without the timestamp.. here is the updated code. The problem is I only want it to log data each time the reed switch closes… how do i incorporate that,. thanks,
#include
#include “RTClib.h”
#include
RTC_DS1307 RTC;
char buffer [40];
File logFile;
const int CS_pin = 10;
int pow_pin = 6;
const int analogPin = A0; // pin that the sensor is attached to
const int ledgoodPin = 9; // pin that the LED is attached to
const int ledbadPin = 8;
const int ledsetupPin = 7;
const int analog2Pin = A1; // pin that the sensor is attached to
const int ledop1Pin = 2; // pin that the LED is attached to
const int ledop2Pin = 3;
const int ledop3Pin = 4;
int goodcount = 0;
int badcount = 0;
int setupcount = 0;
int good = 0;
int prevgood = 0;
int OFF = 0;
int ON = 1;
int bad = 0;
int prevbad = 0;
int idle = 0;
int previdle = 0;
int partype = 0;
int optype = 0;
void setup() {
// initialize the LED pin as an output:
pinMode(ledgoodPin, OUTPUT);
pinMode(ledbadPin, OUTPUT);
pinMode(ledsetupPin, OUTPUT);
pinMode(ledop1Pin, OUTPUT);
pinMode(ledop2Pin, OUTPUT);
pinMode(ledop3Pin, OUTPUT);
Wire.begin();
RTC.begin();
// initialize serial communications:
Serial.begin(9600);
//Serial.println(“Initializing Card”);
//CS Pin is an output
pinMode(CS_pin, OUTPUT);
//SD Card will Draw Power from Pin 6, so set it high
pinMode(pow_pin, OUTPUT);
digitalWrite(pow_pin, HIGH);
//Initialize Card
if (!SD.begin(CS_pin))
{
//Serial.println(“Card Failure”);
return;
}
//Serial.println(“Card Ready”);*/
}
void loop() {
// read the value of the operator potentiometer:
int analog1Value = analogRead(analog2Pin);
if (analog1Value >0 && analog1Value 400 && analog1Value 900 && analog1Value 214 && analogValue 900) {
digitalWrite(ledgoodPin, HIGH); // turn on the Good part LED
good = ON;
partype = 1;
}
else {
digitalWrite(ledgoodPin,LOW);
}
// }
if (prevgood == OFF && good == ON) {
goodcount++;
Serial.println(goodcount);
}
}
prevgood = good;
// Serial.print(prevstate);
//Serial.println(analogValue);
if (analogValue > 111 && analogValue 223 && analogValue 170 && analogValue 450 && analogValue < 610) {
digitalWrite(ledsetupPin, HIGH);
idle = ON;
partype = 3;
}
else {
digitalWrite(ledsetupPin,LOW); }
}
if (previdle == OFF && idle == ON) {
setupcount++;
Serial.println(setupcount);
}
previdle = idle;
// print the analog value:
// Serial.println(analogValue);
DateTime now = RTC.now();
sprintf(buffer, "%.2d/%.2d/%.2d %.2d:%.2d:%.2d", now.month(), now.day(), now.year(), now.hour(), now.minute(), now.second());
//Serial.println(buffer);
File logFile = SD.open("DATALOG.csv", FILE_WRITE);
if (logFile)
{
logFile.print(buffer);
logFile.print(", ");
logFile.println(optype);
logFile.print(", ");
logFile.print(partype);
logFile.print(", ");
logFile.close();
Serial.print(buffer);
Serial.print(", ");
Serial.println(optype);
Serial.print(", ");
Serial.print(partype);
}
else
{
Serial.println("LogFile cannot be opened");
}
delay(1000); // delay in between reads for stability
}
Hi Jeremy,
If my text file is very big (something like 10 MB) then can I open it in Arduino Uno?
If I have to open such a big file to read something then what kind of Arduino i should use. I have not yet started it but looking at the SRAM memory issue; I need to know if I should go for an Arduino which has big SRAM to open 10 MB text file.
Thanks in advance.
Best regards
Sachin
Hi,
Can you please suggest which Arduino i should use if I want to open 10 MB file from SD card for reading?
Best regards
Sachin
Hi Jeremy,
Let me be more specific about my 2 queries I asked you.
I want to open a text file (which will serve as a lookup table and may be of size around 10 MB) to search for ID and then get the other data from it.
Now, my query is,
1. Is there any limitation in Arduino on size of file which can be opened for reading.
2. If I want to search in such a big size file, then will the search and read operation be very slow? Here I want Arduino to perform this search and read operation very fast within 5 seconds.
So considering two points above can you please guide me?
Best regards
Sachin
Hi, your new book is very helpful for arduino beginners like me. At the moment I having some problem with my data logging with SD cards, I brought an Official Arduino Wireless SD Shield, according to your book, I set pin4 as CS_PIN instead of pin10, and still set pin10 as output, but I keep getting “Card Failure” message, can you help?
#include
const int CS_PIN = 4;
const int POW_PIN = 8;
void setup()
{
Serial.begin(9600);
Serial.println(“Initializing Card”);
pinMode(CS_PIN, OUTPUT);
pinMode(10, OUTPUT);
pinMode(POW_PIN, OUTPUT);
digitalWrite(POW_PIN, HIGH);
if (!SD.begin(CS_PIN))
{
Serial.println(“Card Failure”);
return;
}
Serial.println(“Card Ready”);
}
Hmm, that could happen for any number of reasons. First off, I don’t think the official SD wireless shield uses pin 8 as a power pin. It uses the built-in 5V pin. You should need to set it as an output/high.
hello Jeremy,
Is it possible for Arduino to read excel file?
You can read a CSV file, but not an excel file.
Hi Jermy,
Is there any way to make arduino to create a .csv file in our PC??? I mean to save our digital or analog input readings directly in our PC with using an SD card.
Thank you
You can use the keyboard library on the leonardo to write directly to an open CSV file. My book explains how to do something like this.
Hello jerry ,
I want to interface SD card with Arduino DUE,when i am trying to compile the code availble in example of SD,it prints fatal error i.e avr/pgmspace.h ,is there any solution for that.i know that avr & ARM is totaly deifferent from each other.hope you ans. my que.
Thanks,
Yunus