Easy Arduino Temperature Logger

Basic Temperature Logger with a Graph

Easy Arduino Temperature LoggerOne of the strengths of using an SD Card is that you are able to record information (or measurements) gathered by your Arduino and later export to documents or other analytical tools like spread sheets.

This very easy project uses an LM35 temperature sensor and a Low Cost LC Studio SD Card module in conjunction with an Arduino to create a logger.

In this project the logger will create a Comma Separated Values (CSV) text file.   This text file will then be imported into Google Sheets to create a nice graph of the values that were recorded.

Getting the Parts

The LC Studio SD Card Module

Any card using the SD.h library should work.

eBay    Amazon     Bang Good     Deal Extreme

The LM35 Temperature Sensor

You shouldn’t feel slaved to this or any other temperature sensor.  In fact, you could just as well be logging current, temperature, sound or light.

eBay     Amazon     Bang Good     Deal Extreme

Device Pin Outs

The pin outs for the devices I used are shown below

LC Studio SD Card Pin Outs

LM35 PinoutsComponent Familiarization

Read the Articles below if you’re new to either the LC Studio SD card or the LM35 temperature sensor.

The LC Studio SD Card with an Arduino

The LM35 Temperature Sensor with an Arduino

Easy Arduino Temperature Logger Tutorial


In a nutshell,  we’re going to create a temperature logger,  log some measurements and plot the values using Google Docs.

Connect Sensor and SD Card Module to the Arduino

Connections are pretty basic.  Both devices use 5 volts from your Arduino.

Easy Arduino Temperature Logger TutorialCopy Paste and Upload the Sample Sketch

About the Sketch

Up top we declare our variables.   Of particular note in this sketch are the variables SampleRate and NumOfSamples.

SampleRate is measure in milliseconds.   When implemented in the sketch,  it establishes a delay between our samples.   In the example code, it means we’re taking and recording a temperature measurement about every second.

NumOfSamples tells how many samples to take.   This sketch is taking 60 samples.

In setup(),  we..

  • Initialize the SD Card and Create a file called MyLog.txt.
  • Finally we call getData() and take the samples.

In getData()

  • We enter a for loop that loops until we reach the number of samples specified by NumOfSamples.
  • We make our temperature measurement
  • We write the time to the SD Card
  • We add a comma.  The comma is necessary is how we separate pieces of information in our sample.  Spreadsheets like Excel or Google Sheets will use this to determine how to separate information into columns.
  • We write the measured temperature to an SD card using println() to create a new line.  This new line is how spreadsheet programs separate the information into rows

The Sample Sketch

//Henry's Bench
// Easy Temperature Data Logger
//Connections:  MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 10
#include <SD.h>
#include <SPI.h>
int cs = 10; // Set Chip Select to pin ten

int analogIn = A0;
int RawValue= 0;
double tempC = 0;

// Parameters
int SampleRate = 1000;  // In milliseconds
int NumOfSamples = 60; // How many measurements to make
char myLogName[] = "MyLog.txt";  // The name of the file we will create

File myLog;  // a File Object
void setup()
  // Open serial communications and wait for port to open:
  while (!Serial) {
  Serial.println("Initializing SD card...");
  pinMode(cs, OUTPUT);
  // Documentation says you're supposed to do this
  // even if you don't use it:
  pinMode(SS, OUTPUT);
  // see if the card is present and can be initialized:
  if (!SD.begin(cs)) {
    Serial.println("SD did not initiliaze");   
    while (1) ;
  Serial.println("SD initialized.");
  myLog = SD.open(myLogName, FILE_WRITE);



void loop()

void getData(){
  for(long x = 0; x < NumOfSamples; x++){
    RawValue = analogRead(analogIn);
    tempC = (RawValue / 1023.0) * 500;   
    myLog.print(x * SampleRate);
    myLog.print(","); // Seperates the data points
    myLog.println(tempC); // println gives us a newline that will separate our samples     
  myLog.flush();  // Saves the file

Run the Sketch

Open your Serial Monitor and wave something hot in front of the LM35 temperature sensor.  I waved a flame.

Wait until the Serial Monitor indicates that the data log is complete.

Inspect the Text File

Remove the SD card from the LC Studio module and insert it into your computer.   Navigate to ‘MyLog.txt’ and open it in a program like ‘Note Pad’.

Your text file should look something like the one pictured below.

Easy Temperature Logger Text File Output

Making a Graph Using Google Sheets

A data file like we just created gets more powerful when its presented as a graph.   Spreadsheet programs like Excel or Google Docs allow us to that easily.  In this tutorial, I’m opting for Google Docs because it is freely available.

Start A New Google Docs Sheet

Go to the home page for Google Search and click where indicated.

Navigate to Google Docs

Click the menu and then select ‘Sheets’

Go To Google Sheets

Start a new sheet by clicking ‘Blank’.

Start a new spreadsheet

Import the Text File From the SD Card

Select ‘File’ and then Import

Click on Import

Choose to upload a file.

Choose to Upload a File

Navigate to your SD Card and select MyLog.Txt.  Click Open

Select MyLog

Match your input options to those shown and click ‘Import’.

Select Import Options

An option to open your new file will show up on the new Import File spreadsheet.   Click on it.

Open the Created File

Your new spreadsheet will appear and the rows and columns will be populated with data from your text file.   Click Insert and then Chart.

Select Insert Chart

The Chart Editor screen will appear.  Select a chart style that appeals to you and then press insert.

Chart Editor

Your chart with the data acquired by your Arduino will appear on your spreadsheet.   Size and position as desired.

Finished Chart