Tags: XD-204, Data, Logger, Shield, , Arduino, Shield, XD-204, sd, card, micro,

Data Logger Arduino Shield XD-204 (Battery Included)

  • 49.00 AED
    • Ex Tax:49.00 AED
    • Product Code: Digital
    • Availability: In Stock
    Here's a handy Arduino shield: we've had a lot of people looking for a dedicated and well-designed data logging shield. We worked hard to engineer an inexpensive but well-rounded design. This shield makes it easy to add a 'hard disk' with gigabytes of storage to your Arduino! Our latest version of t..
    Here's a handy Arduino shield: we've had a lot of people looking for a dedicated and well-designed data logging shield. We worked hard to engineer an inexpensive but well-rounded design. This shield makes it easy to add a 'hard disk' with gigabytes of storage to your Arduino! Our latest version of this popular shield has all the features of the popular original, and is "R3" compatible so you can use it with just about any Arduino or compatible. You can be up and running with it in less than 15 minutes - saving data to files on any FAT16 or FAT32 formatted SD card, to be read by any plotting, spreadsheet or analysis program.
    The included RTC (Real-Time Clock) can be used to timestamp all your data with the current time, so that you know precisely what happened when! The data logger is a reliable, well-rounded and versatile design. It is easily expanded or modified and come well supported with online documentation and libraries Features: SD card interface works with FAT16 or FAT32 formatted cards. Built-in 3.3v level shifter circuitry lets you read or write super fast and prevents damage to your SD card Real-time clock (RTC) keeps the time going even when the Arduino is unplugged. The coin cell 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. Two configurable indicator LEDs Onboard 3.3v regulator is both a reliable reference voltage and also reliably runs SD cards that require a lot of power to run Uses the "R3 layout" I2C and ICSP/SPI ports so it is compatible with a wide variety of Arduinos and Arduinocompatibles 

    Source code for Data Logger Arduino Shield :
    #include <SPI.h>
    #include <SD.h>
    #include "Wire.h"
    #include <Time.h>
    // Begin DS1307 RTC
    #define DS1307_I2C_ADDRESS 0x68
    #define TIME_MSG_LEN 11
    #define TIME_HEADER 'T'
    // End DS1307 RTC
    // Begin SD Card
    File myFile;
    // End SD Card
    // Temp Sensor
    #define SENSOR_PIN 0
    // End Sensor
    char floatStr[9];
    char dataStr[24];
    // Convert normal decimal numbers to binary coded decimal
    byte decToBcd(byte val)
      return ( (val/10*16) + (val%10) );
    // Convert binary coded decimal to normal decimal numbers
    byte bcdToDec(byte val)
      return ( (val/16*10) + (val%16) );
    // writes the date/time to the DS1307 RTC
    void setDateDs1307(byte mysecond,        // 0-59
                       byte myminute,        // 0-59
                       byte myhour,          // 1-23
                       byte dayOfWeek,     // 1-7
                       byte dayOfMonth,    // 1-28/29/30/31
                       byte mymonth,         // 1-12
                       byte myyear)          // 0-99
       Wire.write(decToBcd(mysecond));    // 0 to bit 7 starts the clock
       Wire.write(decToBcd(myhour));      // If you want 12 hour am/pm you need to set
                                       // bit 6 (also need to change readDateDs1307)
       byte ctrlRegByte = 0x13; // 00010000 to produce a 1 Hz square wave 
                                // from the SQW pin.  00010011 for 32.768 kHz.
                                // 00010001 for 4.096 kHz.  The square wave output
                                // can be viewed on an oscilloscope.
    // Gets the date and time from the ds1307
    void getDateDs1307(byte *mysecond,
              byte *myminute,
              byte *myhour,
              byte *dayOfWeek,
              byte *dayOfMonth,
              byte *mymonth,
              byte *myyear)
      // Reset the register pointer
      Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
      // A few of these need masks because certain bits are control bits
      *mysecond     = bcdToDec(Wire.read() & 0x7f);
      *myminute     = bcdToDec(Wire.read());
      *myhour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
      *dayOfWeek  = bcdToDec(Wire.read());
      *dayOfMonth = bcdToDec(Wire.read());
      *mymonth      = bcdToDec(Wire.read());
      *myyear       = bcdToDec(Wire.read());
    // sets the ds1307 clock date/time.  Set in serial monitor by sending T<unix epooch time>
    // Example: T1458122840
    time_t processSyncMessage()
      // return the time if a valid sync message is received on the serial port.
      // time message consists of a header and ten ascii digits
      while(Serial.available() >= TIME_MSG_LEN)
        char c = Serial.read();
        if(c == TIME_HEADER)
          time_t pctime = 0;
          for(int i=0; i<TIME_MSG_LEN -1; i++)
            c = Serial.read();
            if(c>='0' && c <='9')
              pctime = (10*pctime) + (c-'0'); // convert digits to a number
          return pctime;
      return 0;  
    // converts a float to a null terminated string
    char *ftoa(char *a, double f, int precision)
      long p[] = {0,10,100,1000,10000,100000,1000000,10000000,100000000};
      char *ret = a;
      long heiltal = (long)f;
      itoa(heiltal, a, 10);
      while (*a != '\0') a++;
      *a++ = '.';
      long desimal = abs((long)((f - heiltal) * p[precision]));
      itoa(desimal, a, 10);
      return ret;
    // ** SETUP **
    void setup() 
      Serial.print(F("Initializing SD card..."));
      // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
      // Note that even if it's not used as the CS pin, the hardware SS pin 
      // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
      // or the SD library functions will not work. 
       pinMode(10, OUTPUT);
      if (!SD.begin(10)) 
        Serial.print("Init failed!");
      Serial.println(F("initialization done."));
       floatStr[0] = '\0';   
    // ** LOOP **
    void loop() 
      byte mysecond, myminute, myhour, dayOfWeek, dayOfMonth, mymonth, myyear;
      float temperature, temperature_sum = 0.0F;
      // For setting the clock date and time.  Should only
      // have to do this once, or when adjusting for daylight
      // savings time
        time_t t = processSyncMessage();
        if(t > 0)
          //adjustTime(-21600);  // Subtract 6 hours to go from GMT to US Central
          adjustTime(-18000);  // Subtract 5 hours to go from GMT to US Central DST
          mysecond = (byte) second();
          myminute = (byte) minute();
          myhour = (byte) hour();
          dayOfWeek = (byte) weekday();
          dayOfMonth = (byte) day();
          mymonth = (byte) month();
          myyear = (byte) year();
          //Serial.print("The year is ");
          myyear -= 2000;
          setDateDs1307(mysecond, myminute, myhour, dayOfWeek, dayOfMonth, mymonth, myyear);      
      // open the file. note that only one file can be open at a time,
      // so you have to close this one before opening another.   
      myFile = SD.open("test.txt", FILE_WRITE);
      // if the file opened okay, write to it:
      if (myFile) 
        Serial.print(F("File opened for writing."));
        // if the file didn't open, print an error:
        Serial.println(F("error opening test.txt"));
      getDateDs1307(&mysecond, &myminute, &myhour, &dayOfWeek, &dayOfMonth, &mymonth, &myyear);
      for(int i=0; i< 60; i++)
        int sensor = analogRead(SENSOR_PIN);  
        temperature = ((sensor * 0.1075269) * 1.8) + 32;  // 1100 / 1023 / 10 = 0.1075269
        sprintf(dataStr, "%s F", ftoa(floatStr, temperature, 1));
        temperature_sum += temperature;
      temperature = temperature_sum / 60;
      temperature_sum = 0.0F;
      int decimalTime = (myhour * 100) + myminute;
      // print to file the date/time
      dataStr[0] = '\0';
      sprintf(dataStr, "%02d/%02d/%d %02d:%02d:%02d,", mymonth, dayOfMonth, myyear, (int) myhour, (int) myminute, (int) mysecond);
      // print to file the temperature
      dataStr[0] = '\0';
      sprintf(dataStr, "%s,F", ftoa(floatStr, temperature, 1));
      // close the file

    Write a review

    Please login or register to review