Ciao,ho comprato un modulo Tinyrtc versione 1.1 e volevo testare un programma che mi ero scaricato dal web,però ho un problema.
La libreria che utilizza il programma per la gestione dell'ora / data è diversa dalla mia ( la mia è la DS1307.h ) ,quando compilo il codice mi vengono segnalati degli errori ( ...in fondo al codice gli ho allegati ),volevo sapere se qualcuno mi poteva indicare le modifiche da apportare per testare il codice in maniera corretta.
Grazie 1000,Mauro
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
#include <SD.h>
#include <dht11.h>
#include "DS1307.h"
#define CS 10
#define DHT11_PIN 4
DS1307 RTC;
dht11 DHT;
char buffer[50];
File myFile;
void setup () {
Serial.begin(57600);
Serial.print("Initializing SD card...");
pinMode(CS, OUTPUT);
if (!SD.begin(CS)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
Wire.begin();
RTC.begin();
RTC.sqw(1);
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
// -----------------------------------------------------------------------
int chk;
chk = DHT.read(DHT11_PIN); // READ DATA
int data = 0; // RETUTRNCODE
switch (chk){
case DHTLIB_OK:
data = 0;
break;
case DHTLIB_ERROR_CHECKSUM:
data = 997; // CHECK SUM ERROR
break;
case DHTLIB_ERROR_TIMEOUT:
data = 998; // TIMEOUT ERROR
break;
default:
data = 999; // UNKNOWN ERROR
break;
}
// -----------------------------------------------------------------------
sprintf(buffer, "%02d/%02d/%d %02d:%02d:%02d %d %d", now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second(), DHT.humidity, DHT.temperature, data );
Serial.println( buffer );
myFile = SD.open("dati.log", FILE_WRITE);
if (myFile) {
myFile.println(buffer);
myFile.close();
} else {
Serial.println("error opening data.log");
}
delay(600000);
}
/*-----> errori che mi segnala il compilatore
Creating C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp.o...
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp: In function 'void setup()':
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp:35: error: 'class DS1307' has no member named 'begin'
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp:36: error: 'class DS1307' has no member named 'sqw'
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp:37: error: 'class DS1307' has no member named 'isrunning'
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp:40: error: 'class DS1307' has no member named 'adjust'
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp: In function 'void loop()':
C:\Documents and Settings\mauro\Documenti\Arduino_Build\test14\test14.ino.cpp:45: error: 'class DS1307' has no member named 'now'
[Stino - Error 1]