ds1307 library does not compile

goo morning

dear programmer I have a question, I have been using arduino for 3 years. I have used rtc programs before and all have worked perfectly fine. however since 2015, 3 of my machines refused to compile any rtc, ds1307 or timing program. I do get a wire.h error followed by a twi error. I even re-installed arduino into a new machine, downloaded the ds1307, ds1302 files etc. and there is still a error ????

please if anyone could help

What version of Arduino do you have installed?

What DS1307 library do you have installed?

What board are you compiling for?

good morning sir

I have installed arduino 1.01, 1.0.3, 1.0.5, and the latest 1.0.6.

I am using arduino uno

and I have downloaded the ds1307 from gethub; the site that appears from arduino;

santosh369: I have downloaded the ds1307 from gethub; the site that appears from arduino;

You will have to be more specific. I can't find the Arduino page that references the Github repository. Can you provide a link to the page?

I don’t think it matters what board or IDE you are using, but you may have the library in the wrong place, just check that it is really in the same folder as the original libraries that are known to work.

FWIW I don’t use a library for the DS1307. Below is what I got to work first time, so I stuck with it and I believe it is more efficient.

http://bildr.org/2011/03/ds1307-arduino/

good morning john

http://www.pjrc.com/teensy/td_libs_DS1307RTC.html

and this page directs you to the page above

http://playground.arduino.cc/Code/Time

@nick thank you for your response

I followed your link (http://www.pjrc.com/teensy/td_libs_DS1307RTC.html), followed the “Latest code on GitHub” link there to GitHub - PaulStoffregen/Time: Time library for Arduino and downloaded the .zip. I installed the Time library and re-started my IDE 1.6.0. The example File->Examples->Time->TimeRTC compiled fine for me.

I assume you also installed the DS1307RTC library from here: http://www.pjrc.com/teensy/td_libs_DS1307RTC.html

When you compile the sketch File->Examples->Time->TimeRTC, what are the exact error messages you get?

good afternoon sir

i have run the program ds1307rtc, settime; abd the following message i get

Arduino: 1.0.6 (Windows 7), Board: “Arduino Uno”
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\cores\arduino -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\variants\standard -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\Wire C:\Users\santosh\AppData\Local\Temp\build6927191735237122175.tmp\SetTime.cpp -o C:\Users\santosh\AppData\Local\Temp\build6927191735237122175.tmp\SetTime.cpp.o

In file included from SetTime.ino:1:
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:9:18: warning: Time.h: No such file or directory
In file included from SetTime.ino:1:
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:17: error: ‘time_t’ does not name a type
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:18: error: ‘time_t’ has not been declared
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:19: error: ‘tmElements_t’ has not been declared
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:20: error: ‘tmElements_t’ has not been declared
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:25: error: ‘uint8_t’ does not name a type
C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:26: error: ‘uint8_t’ does not name a type
SetTime:10: error: ‘tmElements_t’ does not name a type
SetTime.ino: In function ‘void setup()’:
SetTime:20: error: ‘tm’ was not declared in this scope
SetTime.ino: In function ‘bool getTime(const char*)’:
SetTime:53: error: ‘tm’ was not declared in this scope
SetTime.ino: In function ‘bool getDate(const char*)’:
SetTime:70: error: ‘tm’ was not declared in this scope
SetTime:72: error: ‘CalendarYrToTm’ was not declared in this scope

@nick i have tried your program and has worked brillantly. hi-five; but still cant understand why the above error is occuring; also nice to find a solution.

santosh369: but still cant understand why the above error is occuring; also nice to find a solution.

It looks like you have installed the third-party library where ONLY the Arduino libraries should reside. If I'd make a guess this is the Arduino software installation folder, right?

C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\

But all your third party libraries that you install later than the Arduino software should reside in the library folder where your sketches are stored. The extra libraries should go to something like: C:\Users\santosh\Documents\Arduino\libraries (folder below the users "Documents" folder for sketches, see Arduino "Preferences" settings)

So I'd say: Library is not installed correctly, so compiler provides errors.

C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\cores\arduino -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\variants\standard -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC -IC:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\Wire C:\Users\santosh\AppData\Local\Temp\build6927191735237122175.tmp\SetTime.cpp -o C:\Users\santosh\AppData\Local\Temp\build6927191735237122175.tmp\SetTime.cpp.o

In file included from SetTime.ino:1: C:\Users\santosh\Desktop\arduino-1.0.6-windows\arduino-1.0.6\libraries\DS1307RTC/DS1307RTC.h:9:18: warning: Time.h: No such file or directory

As said above, it looks like the DS1307RTC library is installed in the wrong place. Read this for where to install third-party libraries: http://arduino.cc/en/Guide/Libraries

It looks like the Time library is not installed at all. You need both.

The Arduino IDE files should probably be in the Program Files directory, not on your desktop. You should re-do the install. You might as well switch to the latest IDE: 1.6.0

santosh369:
@nick i have tried your program and has worked brillantly. hi-five; but still cant understand why the above error is occuring; also nice to find a solution.

Glad to hear it worked. I have stuck with that procedure because it worked first time and it also leads to slightly smaller programmes.

I guess you were just having a simple library positioning problem. There seems to be a few theories on what that might be - which I think are nonsense. All my libraries, whether they be out-of-the -box or third party, are exactly where you would expect them to be - which is in a folder called “E:\Arduino\libraries”. Further, the safest place to park a new library must surely be beside an original library that you have already used.

I submit that all this has nothing to do with where your programmes are stored which, in my case, went to E:\MyDocuments\Arduino by default, but this can subsequently be changed at any time by hitting CTRL+comma when in the IDE, and putting them wherever you like - and without incurring obligation about where the libraries go.

As Johnwasser suggests, a clean install of V1.6 is a good idea. I believe it starts faster!

Keep on clockin’