0
#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?

dda
1,5951 gold badge12 silver badges17 bronze badges
asked Aug 8, 2018 at 14:18
4
  • 1
    Welcome to EE.SE. Please format your code properly using the {} 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. Commented Aug 8, 2018 at 14:21
  • 1
    Have you included the library that defines the "Time" type? Commented Aug 8, 2018 at 14:28
  • isn't it already in the library wire.h? Commented Aug 8, 2018 at 14:49
  • 1
    @Hanatsuki No - see playground.arduino.cc/Code/Time Commented Aug 8, 2018 at 14:51

1 Answer 1

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.

answered Aug 10, 2018 at 3:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.