#include <DS3231.h>
#include <Wire.h> // i2C Conection Library
// Init DS3231
DS3231 rtc;
// Init a Time-data structure
Time t;
uint32_t targetTime = 0;
uint8_t hh = 0, mm = 0, ss = 0, dd = 0, bb = 0; //variable Unsignet int 0-255
int yy = 0; //variable integer
String Day = " "; //variable string
void setup() {
Serial.begin(115200);
}
void loop() {
t = rtc.getTime(); // gate all data time & date from RTC
Day = rtc.getDOWStr(); //get name of day
hh = t.hour,DEC; //pengambilan data jam
mm = t.min,DEC; //pengambilan data menit
ss = t.sec,DEC; //pengambilan data detik
dd = t.date,DEC; //pengambilan data hari
bb = t.mon,DEC; //pengambilan data bulan (dalam desimal)
yy = t.year,DEC; //pengambilan data tahun
//Buka Serial Monitor Arduino untuk melihat hasilnya
Serial.print (Day);
Serial.print (F(" Time = "));
Serial.print (hh); Serial.print (F(" : "));
Serial.print (mm); Serial.print (F(" : "));
Serial.print (ss); Serial.print (F(" Date = "));
Serial.print (dd); Serial.print (F(" . "));
Serial.print (bb); Serial.print (F(" . "));
Serial.println (yy);
delay (1000);
}
When I verify the code, this error appears:
exit status 1
'Time' does not name a type
What does it mean?
1 Answer 1
You don't mention which library you are using (which library does #include <DS3231.h>
refer to?)
The DS3231 library here https://github.com/NorthernWidget/DS3231 defines a DateTime
object which appears to have similar elements to what you are trying to access in 't' (hour, min, sec etc).
I would try defining 't' as a DateTime
object.
{}
code button (or add >= 4 spaces on the start of each line). Make sure it is indented properly. Use the preview to check it before submitting.