Arduino micro SD Card Data Logger

If you want to track or monitor the sensor output value then it is important to log the data, Here temperature sensor LM35 output data is stored in a Micro SD card with the help of arduino and Micro SD card adapter, You can use this setup as Arduino SD card data logger and it can be exported to excel sheet for data analysis.




You can define the time interval of data reading and storing in SD card by the Arduino Code, Any types of sensors can be used as a data input source and the following setup will capture the sensor data and writes into SD as text file.

micro SD Card Pinout

Micro SD memory card available in different memory size, it contains 8 pins for SPI interface it requires level shifter to interfaced with Arduino board hence we use Micro SD card Adapter breakout board.

Inside the tiny micro SD card there is NAND Flash array placed to store the data bits and data in/out bus takes response to transfer the data from/to micro SD card then SD controller decides the operations of whole micro SD memory.

micro SD adapter pinout

This adapter breakout board helps to connect Microcontrollers with micro SD card and it contains one level shifter IC, Voltage regulator and six terminals for external interfacing.

micro SD Arduino Interface

Here temperature value is need to captured for every second, so the LM35 temperature sensor is connected with Arduino A0 pin then micro SD adapter is connected with Arduino as

* GND – GND
* 5V – VCC (+5V)
* D10 – CS
* D11 – MOSI
* D12 – MISO
* D13 – SCK

You can Install the “SdFat library” from https://github.com/greiman/SdFat. The Arduino SdFat library provides read/write access to FAT16/FAT32 file systems on SD/SDHC flash cards.

Here simple Arduino IDE example is used for datalogging. The data will be stored in micro SD card as “data-log.txt” text file.

Micro SD datalogger Arduino Code

 

#include <SPI.h>
#include <SD.h>
File myFile;
int x = 0;
int tempValue;
void setup()
{
   pinMode(10, OUTPUT);
   SD.begin(10);
}
void loop()
{
   tempValue = analogRead(A0);
   myFile = SD.open("data-log.txt", FILE_WRITE);
   if (myFile) {
      myFile.print("Temperature ");
      myFile.print(x);
      myFile.print(":");
      myFile.println((long)tempValue*0.48875);
   }
   myFile.close(); 
   x++;
   delay(1000);
}




Add a Comment

Your email address will not be published. Required fields are marked *