Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Undeclared class, DateTime
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Undeclared class, DateTime

by shoalwave on Mon Aug 10, 2020 10:50 pm

I'm using an older adafruit version of the datalogge shield. (No P/N on the shield for the RTC chip but only a P/N for the battery.) I wonder which RTC chip this shield might use and whether or not the latest library (RTClib.h) might support it. Anyway after loading the afore-mentioned library and attempting to compile the datalogger software (copied from "Exploring Arduino, 2nd edition, by Blum). I get the error, "DateTime was not declared in this scope". The compiler tags the line: "DateTime datetime = RTC.now();" as the offender. I checked the RTClib header, and it declares both the class, DateTime, and several objects, DateTime(). Now having said all this, I do have a recent copy of the datalogger shield and it does come with a labeled RTC chip (pcf8523). However this shield requires me to solder the pins on. Since I plan to make a number of these, I can't avoid this task in the long run. Thanks for whatever assistance you can render....Pete Smith

shoalwave
 
Posts: 3
Joined: Thu Aug 10, 2017 11:07 pm

Re: Undeclared class, DateTime

by adafruit_support_bill on Tue Aug 11, 2020 6:58 am

If it is an older shield, it probably has the DS1307. RTCLib supports the DS1307, PCF8523 and DS3231 chips. Example code for the DS1307 can be found here:

https://github.com/adafruit/RTClib/tree ... les/ds1307

adafruit_support_bill
 
Posts: 78759
Joined: Sat Feb 07, 2009 10:11 am

Re: Undeclared class, DateTime

by shoalwave on Tue Aug 11, 2020 10:43 pm

Any thughts re: the DateTime class being out of scope?

shoalwave
 
Posts: 3
Joined: Thu Aug 10, 2017 11:07 pm

Re: Undeclared class, DateTime

by adafruit_support_bill on Wed Aug 12, 2020 5:46 am

The DS1307 example compiles fine here. Possibly your copy of the library is corrupted.

adafruit_support_bill
 
Posts: 78759
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.