Datasheet
Code Walkthrough
Introduction
This is a walkthrough of the Light and Temperature Logging sketch. Its long and detailed so
we put it here for your perusal. We strongly suggest reading through it, the code is very
versatile and our text descriptions should make it clear why everything is there!
Download the complete file here (http://adafru.it/c7e):
Includes and Defines
#include "SD.h"
#include <Wire.h>
#include "RTClib.h"
OK this is the top of the file, where we include the three libraries we'll use: the SD library to
talk to the card, the Wire library that helps the Arduino with i2c and the RTClib for chatting
with the real time clock
// A simple data logger for the Arduino analog pins
#define LOG_INTERVAL 1000 // mills between entries
#define ECHO_TO_SERIAL 1 // echo data to serial port
#define WAIT_TO_START 0 // Wait for serial input in setup()
// the digital pins that connect to the LEDs
#define redLEDpin 3
#define greenLEDpin 4
// The analog pins that connect to the sensors
#define photocellPin 0 // analog 0
#define tempPin 1 // analog 1
Next are all the "defines" - the constants and tweakables.
LOG_INTERVAL is how many milliseconds between sensor readings. 1000 is 1 second
which is not a bad starting point
ECHO_TO_SERIAL determines whether to send the stuff thats being written to the card
also out to the Serial monitor. This makes the logger a little more sluggish and you
may want the serial monitor for other stuff. On the other hand, its hella useful. We'll
set this to 1 to keep it on. Setting it to 0 will turn it off
© Adafruit Industries https://learn.adafruit.com/adafruit-data-logger-shield Page 76 of 85