Olá a todos.
Estou a desenvolver um projeto de licenciatura e gostaria de gravar para um bloco de notas segundo esta forma:
2013/07/16 18:50:00 3.00V,
(no qual, estou a ler tensão [3V] de um circuito, pela porta analogica A0).
Irei gravar para bloco de notas no Processing, mas neste momento tenho um erro no código do Arduino. Gostaria de ler a Data e Hora no Arduino, mas não estou a conseguir!!
De seguida irei apresentar o código, no qual já inclui as livrarias encontradas no site do Arduino, a DataTime.h e a DateTimeStrings.h.
#include <DateTime.h>
#include <DateTimeStrings.h>
#define TIME_MSG_LEN 11 // time sync to PC is HEADER and unix time_t as ten ascii digits
#define TIME_HEADER 255 // Header tag for serial time sync message
int PinAnalogA0 = 0;
float valAnalog=0; // Coloca o Pino A0 a 0
float temp = 0;
void setup()
{
Serial.begin(9600);
getPCtime(); // try to get time sync from pc
if(DateTime.available())
{ // update clocks if time has been synced
unsigned long prevtime = DateTime.now();
while( prevtime == DateTime.now() ) // wait for the second to rollover
;
DateTime.available(); //refresh the Date and time properties
digitalClockDisplay( ); // update digital clock
// send our time to an app listening on the serial port
Serial.write( TIME_HEADER, BYTE); // this is the header for the current time
Serial.println(DateTime.now());
}
}
void getPCtime()
{ // if time available from serial port, sync the DateTime library
while(Serial.available() >= TIME_MSG_LEN ){ // time message
if( Serial.read() == TIME_HEADER ) {
time_t pctime = 0;
for(int i=0; i < TIME_MSG_LEN -1; i++){
char c= Serial.read();
if( c >= '0' && c <= '9')
pctime = (10 * pctime) + (c - '0') ; // convert digits to a number
}
DateTime.sync(pctime); // Sync DateTime clock to the time received on the serial port
}
}
}
void getPCtime()
{ // if time available from serial port, sync the DateTime library
while(Serial.available() >= TIME_MSG_LEN ){ // time message
if( Serial.read() == TIME_HEADER ) {
time_t pctime = 0;
for(int i=0; i < TIME_MSG_LEN -1; i++){
char c= Serial.read();
if( c >= '0' && c <= '9')
pctime = (10 * pctime) + (c - '0') ; // convert digits to a number
}
DateTime.sync(pctime); // Sync DateTime clock to the time received on the serial port
}
}
}
void loop ()
{
valAnalog = analogRead(PinAnalogA0);
temp = (valAnalog * 5.0) /1024;
Serial.print(" Tensao= " );
Serial.print(temp);
delay(2000);
}
O erro que me aparece é o seguinte:
'DateTime', was not declared in this scope
Agradeço a quem me poder de imediato ajudar e dar informações sobre como resolver este erro!!!
Obrigado.
Um abraço,
Pedro Santos