Home Code Arduino Data logger shield RTC example

Arduino Data logger shield RTC example

by shedboy71

This is a simple data logging shield which will enable you to add SDCard storage support and RTC capability to your Arduino project. Here is a picture of the shield that I purchased

data logging shield

data logging shield

Features

Here is a summary of the features of the shield

SD card interface works with FAT16 or FAT32 formatted cards. 3.3v level shifter circuitry prevents damage to your SD card
Real time clock (RTC) keeps the time going even when the Arduino is unplugged. The battery backup lasts for years
Included libraries and example code for both SD and RTC mean you can get going quickly Prototyping area for soldering connectors, circuitry or sensors.
Onboard 3.3v regulator is both a reliable reference voltage and also reliably runs SD cards that require a lot of power to run
Works with Arduino UNO, Duemilanove, Diecimila, Leonardo or ADK/Mega R3 or higher. ADK/Mega R2 or lower are not supported
To start, remove the battery from the holder while the Arduino is not powered or plugged into USB. Wait 3 seconds and then replace the battery. This will reset the RTC chip.
Code

You will need to include the RTCLib, this example gets the latest time from your computer and then displays it via the serial monitor

[codesyntax lang=”cpp”]

#include <Wire.h>
#include "RTClib.h"
 
RTC_DS1307 RTC;
 
void setup () 
{
    Serial.begin(57600);
    Wire.begin();
    RTC.begin();
 
  if (! RTC.isrunning()) 
  {
    Serial.println("RTC is NOT running!");
    //sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
 
}
 
void loop () 
{
    DateTime now = RTC.now();  
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    delay(1000);
}

[/codesyntax]
Result

This is a brief outline of the output as seen in the serial monitor

2015/11/22 21:38:20
2015/11/22 21:38:21
2015/11/22 21:38:22
2015/11/22 21:38:23
2015/11/22 21:38:24

 

Link
Data Logger Module Logging Data Recorder Shield for Arduino UNO SD Card

Share

You may also like