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.
November 9, 2014 at 10:09 pm
Firstly congratulations for the great work!. That helped me so much. I have a doubt:
How can I remove a specific line from an ordinary txt file? I want to remove the third line from a file like that:
“line1
line2
line3
line4
line5”
Resul after operation:
“line1
line2
line4
line5”
Thak you.
December 16, 2014 at 10:23 pm
How do I decode 168 is I want to read this value to the serial monitor? Hope to hear from you soon. Thanks.
January 1, 2015 at 11:41 pm
How do I decode 168 if I want to read this value from the SD card to the serial monitor?
February 25, 2015 at 11:37 pm
Hi, Jeremy
Thanks very much for the SD Datalogger tutorial. Timely, as I’m designing a commercial logger (using an ATXmega chip) so this was a useful refresher.
-Andy, Oulu, Finland
February 27, 2015 at 8:52 pm
Hii!
I have an SD card with some logs
20:54:58;27.02.2015
20:55:21;27.02.2015
21:00:07;27.02.2015
21:15:51;27.02.2015
….
When I ran:
”
myFile = SD.open(“log.txt”);
if (myFile) {
while (myFile.available()) {
Serial.write(myFile.read());
}
}
myFile.close();
}
”
It sends to the serial, all the file.
I wanna load only the last char line, in other words, the last nineteen.
Would somebody can help me? Thanks in advance!!!
February 27, 2015 at 9:11 pm
tks
March 13, 2015 at 7:14 pm
Hi Jeremy !
Thanks for your great tutorial data logging with SDCARD ! it’s very useful ! :)
I want to ask, how can we read data from CSV file, with multiple row and column..
Here, i want to try read some data like
[Identity] [Name]
1234 Jeremy
So i know that identity value of 1234 is Jeremy..
Thanks ! :)
March 27, 2015 at 6:24 am
thanx for the info but i have 1 small doubt now u have connected the sd card from pin 8 to 13 in arduino but if we want to go in another way, as there are two ways to connect sd card with arduino 1 is which u have mentioned in ur video and the another one which u have not shown, so please tell us how to interface the sd card with the another method.
May 17, 2015 at 9:15 am
hello, congratulations on this video. He has helped me a lot with my graduate work.
I’m having a problem: The .csv file is recording the data in one column, not into two columns, as in your video.
My code looks a lot like yours.
January 28, 2016 at 9:20 pm
I have a project requirement in which I need to record historical sensor data to a txt file and have the ability to access that file and output it on the screen (5″ 800×480 tft lcd). I basically need to read a line of text from a text file on the sd card and write that line to the screen. is this possible and if so, how would I begin?
February 12, 2016 at 6:38 am
Hi. Thanks for a thorough tutorial. Not many of that quality out there… I am to build a data logger with a number of sensors (shortwave radiation, temperature, humidity, pressure, longwave radiation, GPS) which means that my Arduino Uno does not have enough analog inputs. Do you know if the mentioned sensor will work if I use a multiplexer, or am I better of with e.g. the Arduino Mega? Thanks a lot for your answer
February 16, 2016 at 11:03 am
hi jeremy
i want to ask if we want to display name from a bunch of list in csv file to lcd. can it be?
May 16, 2016 at 8:40 am
Hello Jeremy,
I am doing a project on RFID and wondering if it is possible to store the RFID card read with the real time they were detected.
Can you plz give me your kind suggestions on that.
Thank you.
August 29, 2016 at 7:14 pm
I’m a little new to this world. I find it odd that I can find TONS of info on reading and writing to SD cards but nothing about how to use the data after your READ it from the SD card.
September 5, 2016 at 11:04 pm
I have made a simple data logger with VB.NET and Arduino http://www.computeraidedautomation.com/forum-topic/arduino-vb-datalogger
October 24, 2016 at 11:53 pm
Hi ^_^
I dont know anything about arduino , my friend is asking something like this.
From what i understand, they want to create something like reverse vending machine that would be using sensors for item detection if it is a can or plastic bottle, there will be equivalent points for thrown item (can/plastic bottles) so basically the quantity of thrown item is considered. Where should they store the equivalent points? SD cards on arduino for the storage of data?
For example the bottle/can thrown is 10 pieces then the equivalent points is 5points. Then the 5 points will be displayed on the TFT LCD.
My questions are:
-Can they store default data of equivalent points per item to SD cards? (something like a database?)
– How to retrieve and compare the equivalent points data from the arduino sensors? (If bottle is detected by the sensor, compare it to the equivalent points database and calculate the total points he will get and display to the TFT LCD screen)
March 7, 2017 at 5:36 am
/*
This Sketch uses the TinyGPS library and SD card library to log GPS data and save it on a SD card.
Important: This version is intended for Arduino 1.0 IDE. It will
not compile in earlier versions. Be sure the following files are
present in the folder with this sketch:
TinyGPS.h
TinyGPS.cpp
keywords.txt
A revised version of the TinyGPS object library is included in the sketch folder
to avoid conflict with any earlier version you may have in the Arduino libraries
location.
*/
#include
#include // Special version for 1.0
#include // Standard Arduino SD card library
File myFile;
TinyGPS gps;
SoftwareSerial nss(9, 10); // Yellow wire to pin 6. (Based on using
// Parallax 28500-RT PMB-648 GPS SiRF Internal Antenna)
void setup() {
Serial.begin(9600);
nss.begin(9600);
Serial.println(“Reading GPS”);
// Initialize SD card
Serial.print(“Initializing SD card…”);
pinMode(4, OUTPUT);
if (!SD.begin(4)) {
Serial.println(“initialization failed!”);
return;
}
Serial.println(“initialization done.”);
// End initialize SD Card
}
void loop() {
bool newdata = false;
unsigned long start = millis();
while (millis() – start < 5000) { // Update every 5 seconds
if (feedgps())
newdata = true;
}
if (newdata) {
gpsdump(gps);
}
}
// Get and process GPS data
void gpsdump(TinyGPS &gps) {
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print(flat, 4);
Serial.print(", ");
Serial.println(flon, 4);
/// And write it to SD card
myFile = SD.open("tracking.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to tracking.txt…");
myFile.print(flat, 4);
myFile.print(", ");
myFile.println(flon, 4);
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening tracking.txt");
}
///
}
// Feed data as it becomes available
bool feedgps() {
while (nss.available()) {
if (gps.encode(nss.read()))
return true;
}
return false;
}
bro my code can't log the data of sd card it just initializes the sd card …….
kindly help me doing this
April 2, 2017 at 12:10 am
HI I am new to this arduino projects. I am making a project with sd card adapter and arduino to open the files in sd card. I have seen the video in youtube and made the connections with normal copper wires. Everything is fine but the arduino cant open the file in sd. Please help me.Please. Thanks in advance!!!
Pingback: Arduino Video Tutorial 02 – copasvideo