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

migrated from electronics.stackexchange.com Aug 8 at 23:42

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • 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. – Transistor Aug 8 at 14:21
  • 1
    Have you included the library that defines the "Time" type? – Tyler Aug 8 at 14:28
  • isn't it already in the library wire.h? – Hanatsuki Aug 8 at 14:49
  • 1
    @Hanatsuki No - see playground.arduino.cc/Code/Time – awjlogan Aug 8 at 14:51

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.