DS1307 Real time clock Datalogger

/Desarrollado a partir de Datalogger de la libreria SD, Keypad, LCD5110 Graph y del script de 18B20/

#include <SD.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LCD5110_Graph.h>
#include <Keypad.h>

//--------------DS1307--------
#include "Wire.h"
#include "RTClib.h"//Para poder obtener adecuadamente UNIXtime
#define DS1307_ADDRESS 0x68
byte zero = 0x00; //workaround for issue #527

RTC_DS1307 RTC;//Va acorde a RTClib.h

unsigned long s;//Segundos reloj
unsigned long mi;//Minutos reloj
unsigned long h;//Horas reloj
unsigned long ds;//Dia semana reloj
unsigned long dm;//Dia mes reloj
unsigned long me;//Mes reloj
unsigned long a;//A?o reloj

char fechahora='0';//A-Correctos/B-Incorrectos
//------------------------------

//Keypad
const byte ROWS = 4; //cuatro filas
const byte COLS = 4; //cuatro columnas

char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {6,7,8,9};
byte colPins[COLS] = {2,3,4,5};

//Dataloger Refresh Rate
unsigned long lastReadTime=0;
unsigned long refresh_rate = 0;
unsigned long currentTime=0;
unsigned long num = 0;
unsigned long numQ = 0;//Funcion de sensores de caudal (Definicion)
unsigned long t=0;
unsigned long numSensoresQ=0;
unsigned long numSensoresT=0;

char menu='0';
char menu1='A';
char menu2='A';
char menu3='A';
char menu4='A';
char menu5='A';
char menulog='A';
int pantallazo=0;

char unidad='0';

int numero=0;

int w = 0; //Contador DS18B20

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

//LCD
LCD5110 myGLCD(45,46,47,48,49);
extern uint8_t unican[];
extern uint8_t helice[];
extern uint8_t helice2[];
extern uint8_t helice3[];
extern uint8_t flecha[];
extern uint8_t borraflecha[];

extern uint8_t SmallFont[];

uint8_t* bm;

//Define puerto 18B20s
#define ONE_WIRE_BUS 11
#define TEMPERATURE_PRECISION 12 //resoluci?n de los sensores en bits

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

//SPI SD Card Pins
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
int CS_pin = 43;
int pow_pin = 8;

void setup()
{

Serial.begin(9600);

Wire.begin(); //Wire---DS1307 RTC

RTC.begin();

sensors.begin();//Inicializa sensores 18B20
int numSensoresT = sensors.getDeviceCount(); // Numero de sensores
int temparray[numSensoresT]; // Array que almacena un array con el numero de sensores

//--------------------------------------------------------LCD--------------------------------------------------------------------
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);

myGLCD.clrScr();
myGLCD.drawBitmap(0, 0, unican, 84, 48);
myGLCD.update();

delay(2000);

myGLCD.clrScr();
myGLCD.drawBitmap(0, 0, helice, 84, 48);
myGLCD.update();
delay(250);

myGLCD.clrScr();
myGLCD.drawBitmap(0, 0, helice2, 84, 48);
myGLCD.update();
delay(250);

myGLCD.clrScr();
myGLCD.drawBitmap(0, 0, helice3, 84, 48);
myGLCD.update();
delay(250);