Reply to topic  [ 38 posts ]  Go to page 1, 2, 3, 4  Next
Data Logger Shield (HCARDU0093) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 650
Post Data Logger Shield (HCARDU0093)
Image

Image

This data logger shield provides an Arduino Uno, Leonardo, or Mega with the ability to log sensor data to an SD card with the minimum of set-up. The shield provides sever useful features:

Real Time Clock Module
The shield includes the very popular DS1307 battery backed real time clock (RTC). This RTC will keep an accurate track of the data and time for up to several years, even when then shield isn't being powered.

SD Card reader
A standard SD card reader is provided to allow FAT16 or FAT32 formatted SD cards up to 32GB in size to be read or written to and is compatible with the standard SD card library. The shield also contains appropriate level shifting circuitry to protect the 3.3V interface of your SD card.

Prototyping area
A very useful protoyping area consisting of a grid of pads on a standard 0.1" pitch provide an area to add your own components such as sensors to interface to your Arduino board.

LED's L1 & L2
Two additional LEDs have been added which can be mapped to any of your Arduino's digital pins for use as visual indicators.

Standard Arduino headers.
The shield has a standard set of Arduino headers allowing additional compatible shields to be stacked.

This product is manufactured by Deek-Robot and is derived from the Adafruit(TM) Data logger reference design which was released under the Creative commons Attribution-ShareAlike 3.0 licence http://creativecommons.org/licenses/by-sa/3.0/.

Order Yours Here.

Image

Image




Image

Code:
/* FILE:    Data_Logger_Shield_HCARDU0093_Example
   DATE:    24/02/15
   VERSION: 0.1
   
REVISIONS:

24/02/15 Created version 0.1

This is an example of how to use the Hobby Components data logger shield
(HCMODU0093). This shield contains a battery backed DS1307 real time clock
and an SD card interface. This allows any sensor data read by your Arduino
to be stored with an accurate time stamp to an SD card. In this example sketch
we will continually read the value of an LM35 temperature sensor and store the
result together with the current time and date to a CSV file. This file can then
be loaded into a spreadsheet such as Excel or Open Office.

To use this sketch you will require the HCTRC library which is available for
download in the software section of our support forum. You will also need to
connect an LM35 temperature sensor as follows:

LM35.....Arduino
Pin 1....+5V
Pin 2....Analogue pin A0
Pin 3....GND

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.

This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */



/* Include the wire library */
#include <Wire.h>
/* Include the Hobby Components RTC library */
#include <HCRTC.h>
/* Include the standard SD card library */
#include <SD.h>

/* The RTC has a fixed addresses of 0x68 */
#define I2CDS1307Add 0x68

/* DIO pin used to control the SD card CS pin */
#define SD_CS_DIO 10

/* Define the analogue pin used to read the temperature sensor (A0) */
#define LM35Pin 0

/* Create an instance of HCRTC library */
HCRTC HCRTC;

/* Create an instance of the standard SD card library */
File DataFile;

/* This will store the current temperature reading */
float Temperature;


void setup()
{
  /* Initialise the serial port */
  Serial.begin(9600);

  /* Set internal 2.56V reference for analogue pins */
  analogReference(INTERNAL);
 
  /* Set the SD card CS pin to an output */
  pinMode(SD_CS_DIO, OUTPUT);
 
  /* Use the RTCWrite library function to set the time and date.
     Parameters are: I2C address, year, month, date, hour, minute, second,
     day of week. You would normally only need to do this once */
  HCRTC.RTCWrite(I2CDS1307Add, 15, 2, 24, 14, 21, 0, 2);
 
  /* Initialise the SD card */
  if (!SD.begin(SD_CS_DIO))
  {
    /* If there was an error output this to the serial port and go no further */
    Serial.println("ERROR: SD card failed to initialise");
    while(1);
  }else
  {
    Serial.println("SD Card OK");
  }
}



/* Main Loop */
void loop()
{
  /* Read the LM35 connected to the analogue pin and convert to oC */
  Temperature = analogRead(LM35Pin) / 9.31;
   
  /* Read the current time from the RTC module */
  HCRTC.RTCRead(I2CDS1307Add);
   
  /* Lets output this data to the serial port */
  Serial.print(HCRTC.GetDateString());
  Serial.print(", ");
  Serial.print(HCRTC.GetTimeString());
  Serial.print(", ");
  Serial.println(Temperature);   
   
  /* Open the data.csv file to save our data to.
     If the file already exists it will just tag our new data onto the end of it */
  DataFile = SD.open("data.csv", FILE_WRITE);

  if (DataFile)
  {
    DataFile.print(HCRTC.GetDateString());
    DataFile.print(", ");
    DataFile.print(HCRTC.GetTimeString());
    DataFile.print(", ");
    DataFile.println(Temperature); 
    DataFile.close();
  }

  /* Wait a second before reading again */
  delay(1000);
}





Image

To use the shield's RTC with the above example sketch please download the HCRTC library available from the software section of our support forum here:
viewtopic.php?f=58&t=1357


Tue Feb 24, 2015 1:09 pm
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: Data Logger Shield (HCARDU0093)
hi does any body know what i have to change to get this to work with the mega works fine with my uno but need the xtra pins and memory on the mega


Fri Apr 24, 2015 7:14 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: Data Logger Shield (HCARDU0093)
The reason why the shield wont work on a Mega in its unmodified state is because it needs to use the I2C and the SPI interfaces on your Arduino board. As you are probably already be aware, these two interfaces are in a different location on a Mega compared to an Uno. Looking at the schematic it looks like you would need to do the following:

For the I2C interface (used by the RTC) you'll need to link the pads marked SCL and SDA (next to the LEDs marked L1 & L2) across to the similarly marked pads on the opposite corner of the shield (near the analogue header). Keep in mind when you do this you are effectively shorting the analogue pins A4 and A5 to pins 20 & 21 on your Mega. If you can guarantee that you wont configure these pins as digital outputs at any point whilst the shield is connected then you should be safe. Otherwise you'll need to disconnect the header pins that plug into the A4 and A5 socket on your Mega.


For the SPI interface (used by the SD card reader) you'll need to wire across the Mega's SPI interface (available on digital pins 50, 51, & 52 or via the 6 pin ICSP header) to digital pins 11, 12, & 13 on the shield. You can also use the prototyping pads near the header for this. As with the I2C interface you'll want to with bend out the digital pins 11, 12, & 13 on the shield so that they don't plug into the socket on your Mega, or just cut the tracks on the underside of the board that run between the header pin and its prototyping pad.

Hope this makes some sort of sense

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Sat Apr 25, 2015 8:54 am
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: Data Logger Shield (HCARDU0093)
hi wired as said but when runnning the program it locks at //HCRTC.RTCWrite(I2CDS1307Add, 15, 2, 24, 14, 21, 0, 2); i // this line reload then it says ERROR: SD card failed to initialise tried cs on pin 53 still same any more ideas ?

thnks ken


Wed Apr 29, 2015 3:04 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: Data Logger Shield (HCARDU0093)
Can you give this sketch below a try. If you open up the serial monitor window you should see the time tick up once a second.


Code:
/* FILE     HCRTC_Example.cpp
   DATE:    23/12/13
   VERSION: 0.2
   AUTHOR:  Andrew Davies

This is an example of how to use the Hobby Components RTC library to read and
write to and from the DS1307 real time clock 24C32 EEPROM. The library is intended
to be used with our RTC clock module (HCMODU0011), but should work fine with any
module that uses a DS1307 device.

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/


/* Include the wire library */
#include "Wire.h"
#include "SPI.h"

/* Include the Hobby Components RTC library */
#include <HCRTC.h>

/* The RTC and EEPROM have fixed addresses of 0x68 and
    0x50 so define these in software */
#define I2CDS1307Add 0x68


/* Used in example as an index pointer */
byte index;

/* Create an instance of HCRTC library */
HCRTC HCRTC;


void setup()
{
  Serial.begin(9600);
}

void loop()
{
 
 
 
  /* Continuously read the current time and date from the RTC */
  while(true)
  {
    /* Read the current time from the RTC module */
    HCRTC.RTCRead(I2CDS1307Add);
   
    /* Output the information to the UART */
    Serial.print(HCRTC.GetDay());
    Serial.print("/");
    Serial.print(HCRTC.GetMonth());
    Serial.print("/");
    Serial.print(HCRTC.GetYear());
    Serial.print(" ");
   
    Serial.print(HCRTC.GetHour());
    Serial.print(":");
    Serial.print(HCRTC.GetMinute());
    Serial.print(":");
    Serial.print(HCRTC.GetSecond());
    Serial.print(" DOW:");
    Serial.println(HCRTC.GetWeekday());
   
    /* Now output the same thing but using string functions instead: */
    Serial.print(HCRTC.GetDateString());
    Serial.print(" ");
    Serial.println(HCRTC.GetTimeString());
   
    /* Wait a second before reading again */
    delay(1000); 
  }
}

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Thu Apr 30, 2015 10:54 am
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: Data Logger Shield (HCARDU0093)
hi stops at line as other program tried 2 diff mega s same on both prints ok1 and ok 2 but not ok3 so no time

Serial.print("0k1");
/* Continuously read the current time and date from the RTC */
while(true)

{
/* Read the current time from the RTC module */
Serial.print("ok2");
HCRTC.RTCRead(I2CDS1307Add);
Serial.print("ok3");


Thu Apr 30, 2015 5:39 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: Data Logger Shield (HCARDU0093)
I've checked the last sketch on a Mega with the shield so it should defiantly work. It must be a connection issue. Can you check the following:

There is a connection between pin 20 (SDA) on your mega and the SDA pad on your shield
There is a connection between pin 21 (SCL) on your mega and the SCL pad on your shield.
That analogue pins 4 and 5 on your mega are not connected to the shield.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri May 01, 2015 7:54 am
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: Data Logger Shield (HCARDU0093)
:D ok got the time sketch to work now for the sd card still says sd card failed to initalize do i leave the cs pin on 10 or 53 ? many tnks for your patience


Fri May 01, 2015 3:00 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: Data Logger Shield (HCARDU0093)
That's great. You should be able to leave it on pin 10 but it's wise to configure pin 53 as an output. This stops the hardware SPI interface from being accidently switched to slave mode by RF noise and locking up the SPI interface.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri May 01, 2015 3:50 pm
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: Data Logger Shield (HCARDU0093)
thnks for your time andrew i moved the chip select pin to 53 and changed lines
to #define SD_CS_DIO 53
analogReference(INTERNAL1V1);
pinMode(53, OUTPUT);

now works as sketch for uno hope to try it on my meg that i got the touch screen working on as looks like the pins are free now ive moved 10 as well

its a project iam doing for making beer from grain and controling the process

thnks again


Fri May 01, 2015 4:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 38 posts ]  Go to page 1, 2, 3, 4  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD