SD CARD + ORARIO + TEMPERATURE
IN PREPARAZIONE...
UTILIZZATO CARD da 4 GIGA
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
File
Dati;// Variabile di tipo dati
const int chipSelect =4;
int
inPin =2; //Pin ingresso sonda di temperatura
int
temp = 0; //Variabile della temperatura
int
k =0; // Contatore conteggio
temperature
String
Buffer="";// Buffer per la scrittura dei dati
void setup ()
{
Serial.begin(9600);
Wire.begin();
RTC.begin();
RTC.sqw(1);
//0 Led off - 1 Freq 1Hz - 2 Freq 4096kHz - 3 Freq 8192kHz - 4 Freq
32768kHz
if (!
RTC.isrunning()) {
Serial.println("RTC
is NOT running!");
//
following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__,
__TIME__));
}
Serial.print("\nSto
verificando la presenza della scheda...\n");
pinMode(10,OUTPUT);//
Fa funzionare la SD
if(!SD.begin(chipSelect))
{
Serial.println("SD
Card non trovata");
return;
}
else
{
Serial.println("Scheda
inserita e funzionante");
Serial.println();
}
}
void loop ()
{
Buffer="";//Nuovo giro, stringa vuota!
DateTime
now = RTC.now();
k = k +1;
temp
=(5.0 * analogRead(inPin)*100)/1024;
Serial.print(now.day(),
DEC);
Serial.print('/');
Serial.print(now.month(),
DEC);
Serial.print('/');
Serial.print(now.year(),
DEC);
Serial.print("
");
Serial.print(now.hour(),
DEC);
Serial.print(':');
Serial.print(now.minute(),
DEC);
Serial.print(':');
Serial.print(now.second(),
DEC);
Serial.print( "
");
Serial.print(k);
Serial.print(" lettura ");
Serial.print(temp);
Serial.println(" gradi");
//Serial.println();
Buffer +=(now.day());
Buffer
+=('/');
Buffer
+=(now.month());
Buffer
+=('/');
Buffer
+=(now.year());
Buffer
+=(" ");
Buffer
+=(now.hour());
Buffer
+=(':');
Buffer
+=(now.minute());
Buffer
+=(':');
Buffer
+=(now.second());
Buffer +=(" ");
Buffer += k;
Buffer +=(" lettura ");
//Serial.print(k);
//Serial.print(" lettura ");
Buffer +=temp;
Buffer +=(" gradi");
Dati
= SD.open("datalog.txt", FILE_WRITE);// apriamo il file in scrittura
if (Dati) {
Dati.println(Buffer);
Dati.close();
Serial.println
("HO MEMORIZZATO ");
Serial.println(Buffer);
Serial.println();
}
else
{
Serial.println("Errore
nell'apertura del file datalog.txt");
}
delay(3000);
FACCIAMO ELABORARE IL TUTTO AD EXCEL