Tutorial 11 for Arduino: SD Cards and Datalogging


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 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:

GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.


  1. 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:


    Resul after operation:


    Thak you.

  2. How do I decode 168 is I want to read this value to the serial monitor? Hope to hear from you soon. Thanks.

  3. How do I decode 168 if I want to read this value from the SD card to the serial monitor?

  4. 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

  5. Hii!
    I have an SD card with some logs


    When I ran:

    myFile =“log.txt”);
    if (myFile) {
    while (myFile.available()) {

    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!!!

  6. 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 ! :)

  7. 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.

  8. 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.

  9. 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?

  10. 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

  11. 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?

  12. 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.

Leave a Reply

Required fields are marked *.