0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« on: March 19, 2012, 11:21:35 am » |
Hi There, I'm unable to get any RTC examples to work, and suspect it is a library problem. I would be grateful for any advice or helps leading to the successful uploading and operation of the RTC examples. Here are some clues: * I've had success in other given examples, uploading and operational, such as Blink and LiquidCrystal, and others. This means many of the settings and basic function seems to work OK. * I would like to use a RTC in a project, bought one, and downloaded the Time library found at http://arduino.cc/playground/Code/Time* The first try did not work with more errors than I can paste here, but after a couple Saturdays worth of investigation, I figured the library was in the wrong folder. Using the Guess n Check method of troubleshooting, I reduced the number of errors to less than a page by copy n paste several libraries in various folders. * Here is the error list I get now ( except <myUserName> for a little privacy): TimeRTC.cpp.o: In function `digitalClockDisplay()': C:\Users\ <myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:33: undefined reference to `hour()' C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:34: undefined reference to `minute()' C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:35: undefined reference to `second()' C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:37: undefined reference to `day()' C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:39: undefined reference to `month()' C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:41: undefined reference to `year()' TimeRTC.cpp.o: In function `setup': C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:18: undefined reference to `setSyncProvider(unsigned long (*)())' C:\Users\<myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp:19: undefined reference to `timeStatus()' Time\DS1307RTC.cpp.o: In function `DS1307RTC::get()': C:\Program Files\Arduino\arduino-1.0-windows\arduino-1.0\libraries\Time/DS1307RTC.cpp:40: undefined reference to `makeTime(tmElements_t&)'If I could learn to upload the current time to the RTC unit somehow, AND send some RTC example sketches to the Arduino Uno, then I would call it a successful day. Thank you in advance!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #1 on: March 19, 2012, 11:57:48 am » |
Sorry, I misunderstood. The problem I'm having seems to be in the environment, and not so much related to the project, as I haven't even got to the "project" phase, so "Installation and Troubleshooting" was my best guess as to where ask for help.
If this question is best for another area, which would it best fit under, and how would I move it there, please?
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #2 on: March 19, 2012, 12:07:36 pm » |
Third party library files must be stored is a specific manner in a specific folder in a specific location to be able to be picked up by the arduino IDE when it compiles the sketch. As an example, here is where my RTC library files are located in my windows XP system: C:\Documents and Settings\Primary Windows User\My Documents\Arduino\libraries\DS1307
1 Folders:
examples
3 Files:
DS1307.cpp DS1307.h DS1307.o
Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #3 on: March 19, 2012, 12:12:19 pm » |
The Time library does not have a method called digitalClockDisplay(), so that must be in your sketch. Post that code.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #4 on: March 19, 2012, 12:29:20 pm » |
Retrolefty,
Thanks, I think you are confirming the information I am missing: Which library goes in which folder? From the error text (the stuff I pasted onto the question above) I think the Arduino IDE is looking in an entirely different location than where all the other Arduino program, other libraries (that came with the original Arduino package), are located. So I need to either 1. find out where Arduino IDE is looking (and move the library there), or 2. re-direct the Arduino IDE to look in the right place. I don't know how to do either. Am I reading your solution correctly?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #5 on: March 19, 2012, 12:39:40 pm » |
PaulS, Here is the unmodified code from the TimeRTC Example. /* * TimeRTC.pde * example code illustrating Time library with Real Time Clock. * */
#include <Time.h> #include <Wire.h> #include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup() { Serial.begin(9600); setSyncProvider(RTC.get); // the function to get the time from the RTC if(timeStatus()!= timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); }
void loop() { digitalClockDisplay(); delay(1000); }
void digitalClockDisplay(){ // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); }
void printDigits(int digits){ // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #6 on: March 19, 2012, 12:44:17 pm » |
PaulS, Here is the unmodified code from the TimeRTC Example. /* * TimeRTC.pde * example code illustrating Time library with Real Time Clock. * */
#include <Time.h> #include <Wire.h> #include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup() { Serial.begin(9600); setSyncProvider(RTC.get); // the function to get the time from the RTC if(timeStatus()!= timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); }
void loop() { digitalClockDisplay(); delay(1000); }
void digitalClockDisplay(){ // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); }
void printDigits(int digits){ // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
So in the same folder where your sketches are stored you need to create a folder named libraries. Inside that folder you must create a folder named DS1307RTC. Inside that folder must be the DS1307RTC.h file along with the other files that comprise of the library. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #7 on: March 19, 2012, 01:05:59 pm » |
Thanks, Lefty. I think I've done as you suggested. Here is the path to what I previously did:
C:\Program Files\Arduino\arduino-1.0-windows\arduino-1.0\examples\9.Time\TimeRTC\libraries\DS1307RTC
(I Named the Time example "9. Time" to be in sequence of the included examples) Within this folder (. . . \libraries) is a file called DS1307RTC.h, and others.
Notice the difference in where the Arduino program is declaring the missing information from and where the Arduino IDE program is; very different parts of the hard-drive tree: C:\Users\ <myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp vs. C:\Program Files\Arduino\arduino-1.0-windows\arduino-1.0\examples\9.Time\TimeRTC\libraries\DS1307RTC
Is that a clue? I do not know how to get the Arduino to stay within it's given folder boundaries.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #8 on: March 19, 2012, 01:13:51 pm » |
Is that a clue? I do not know how to get the Arduino to stay within it's given folder boundaries. No. You can't. Here is the path to what I previously did: If you haven't moved the library, you should. That path is for the Arduino-supplied libraries, not user downloaded libraries.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #9 on: March 19, 2012, 01:23:25 pm » |
Humm, OK. So apparently I need to create another file where the Arduino is expecting it to be. That is not clear to me where it is looking, unless I fumble around in the area where the error text is indicating (seems odd to me). Neither the sketch or libraries are in the area of the path the error describes:
C:\Users\ <myUserName>\AppData\Local\Temp\build4065146874160206963.tmp/TimeRTC.cpp
The deepest folder in this path is "\temp" . 1. Shall I create a "TimeRTC" folder inside "\temp"? 2. Shall I create a "libraries" folder in "\temp" (and drop the needed libaries in there)? 3. Or something else?
-again, thank you for your assistance!
|
|
|
|
|
Logged
|
|
|
|
|
Gosport, UK
Offline
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #10 on: March 19, 2012, 01:35:02 pm » |
That location is a temporary folder where the compiler attempts to build your sketch.
In the IDE, open a sketch that you have written and saved. Then click Sketch->Show Sketch Folder. That should open your sketch book folder. You need to create, if it doesn't already exist, a libraries folder there. Downloaded libraries should be placed in that folder.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #11 on: March 19, 2012, 01:35:56 pm » |
1. Shall I create a "TimeRTC" folder inside "\temp"? 2. Shall I create a "libraries" folder in "\temp" (and drop the needed libaries in there)? 3. Or something else? No, no, and yes. In the same folder where your sketches are stored, create a folder called libraries, if one does not exist. Move the folder from where it is now to the sketch folder's libraries folder.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #12 on: March 19, 2012, 01:55:01 pm » |
"In the same folder where your sketches are stored, create a folder called libraries, if one does not exist. Move the folder from where it is now to the sketch folder's libraries folder."
PaulS, I did this already. There is a folder called "libraries" in the "TimeRTC" sketch folder. To be sure, I saved "TimeRTC" as "TimeRTC2" in a new sketch folder, created a new libraries folder under "TimeRTC2", dropped the libraries into it, and tried again. Same error list.
dxw00d, Thank you for the explanation of the other folder string. Now I know not to go there in my "guess n check" methodology.
I'm starting to get libraries scattered all over. Is it a problem to have too many libraries in a folder? Should I wipe Arduino off the map, and start over?
|
|
|
|
|
Logged
|
|
|
|
|
Gosport, UK
Offline
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #13 on: March 19, 2012, 01:57:59 pm » |
There is a folder called "libraries" in the "TimeRTC" sketch folder. That's too far down. The libraries folder should be at the same level as the "TimeRTC" sketch folder.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #14 on: March 19, 2012, 02:05:55 pm » |
That didn't work either, dxw00d. Put "libraries" at same level as "TimeRTC" sketch folder. Same error. Keep guessing. . . we will score eventually!
|
|
|
|
|
Logged
|
|
|
|
|
|