Problems with the library file of DS1307 and DS3234

Hello folks,
I’m working on Real Time Clock. Attachment is the compressed folder of RTC_DS3234 and DS1307. Both examples of DS3234 and DS1307 don’t work with this library. when I compile the code of DS1307 and DS3234, it showed RTC_DS1307 does not name a type. SO does RTC_DS3234. Could you help me make the code work? The library has been attached.

Best regards
Jingbo

RTCDS3234andDS1307.rar (9.47 KB)

Should the first sketch have a: #include <RTC_DS1307.h>
Where are the libraries ? Can you go to the folder of your projects ? There is a folder between your project folders called “libraries”. The libraries should be there.
Did you try the examples ? When you install the library, the included examples show in the menu of the Arduino IDE.

Thanks for your kind reply. I tried the example, it works well. However, when I put SDIserial.h , SD.h and RTClib.h together in the code, it didn’t work. Maybe something wrong with RTClib. Because in the code, for the RTClib it’s in the form #include “RTClib.h” rather than #include<RTClib.h>.

This includes a library : #include <something.h>
This includes a *.h file from your project : #include “something.h”

On the upper-right of the Arduino IDE is a drop down menu. You can add new files. If you add “something.h”, you need to include it with the double quotation marks.

That is the normal way, but I have seen it in other ways, and that might also work.

I think SDIserial.h has nothing to do with the RTC files. So I don’t know what the problem is.
Can you make a new sketch to test it ? Include all the *.h files, and declare the RTC… classes. See what happens. Show your sketch and the error messages in your post. Use [code][/code] tags around the sketch when you include your sketch in your post.

Thanks for your kind reply. Could you help me check the code of DS1307 and DS3234. why does it show that RTC does not name a type. it can not be download to arduino. Could you help me make the RTC library work?

When something "does not name a type", the compiler has never heard of it. The compiler doesn't know what it is. It means that either the include file or the library is missing or in the wrong place.

Could you download the library attached and check what is wrong with it?

RTCDS3234andDS1307.rar (9.47 KB)

They are old. They are not updated for Arduino 1.0 and newer.
When you really want to use them, they should be updated.

This is what I did: Windows 10 Preview 64-bit. Arduino 1.5.8 BETA zip-file. The 1.5.8 doesn’t need to install any extra Java in Windows 10 Preview, the 1.0.6 does need some extra Java. Installed the library in the “libraries” folder next to my project folders. Tried all 4 examples.

Error output: WProgram.h: No such file or directory
In the three library *.cpp files, changed “WProgram.h” with “Arduino.h”.
New error output: prog_uint8_t doesn’t exist.
Changed “prog_uint8_t” into “uint8_t”.
New error output: ‘class TwoWire’ has no member named ‘send’ and no member named ‘receive’.
Replaced “send” with “write” and “receive” with “read” in RTC_DS1307.cpp

In datecalc.ino and softrtc.ino, added “#include <SPI.h>” before the RTClib.h.

Now everything compiles, but I don’t know how good the code is.

Could you send your RTC library to me?

It is attached.
I used Arduino 1.5.8 BETA, and you have to remove the old library.

RTCDS3234andDS1307.zip (9.46 KB)

Hi,Peter, I use arduino uno r3 to test the library you attached. when I download the code to arduino, it still showed RTC_DS1307 does not name a type. What should I do for this library?

I have only tested the 4 examples of the library, not your sketch. You should include the DS1307 include file, just as in the example of the DS1307.

Hi, I’ve also tested the example of DS1307 and DS3234. Before I tested them, I put the file in my arduino libraries. the example still did work. you can check the picture I attached.

Those are the system files of Arduino with the default libraries. So that is what all the confusion is about.

Go to the settings of the Arduino IDE: File / Preferences.
Look at the location of your projects : “Sketchbook location:”.
It might be something like this: C:\Users<user>\Documents\Arduino
Go to that folder.

There you see the folder of your projects. One of them is called ‘libraries’.
And that is the ‘libraries’ folder for downloaded extra libraries. That is where it should be.

In the Arduino IDE, select “Sketch” / “Import Library…” / “Add Library…”. Select the zip-file and it will be installed in that ‘libraries’ folder next to your projects.

When the Arduino IDE is updated to a new version, your project files and your downloaded libraries stay the same. So it makes sense :slight_smile: But perhaps the system libraries folder should be called “syslibs” or so.

Don’t forget to remove it from the system libraries. Or perhaps download the Arduino IDE again to be sure that the Arduino system files are in their original state.

Brilliant! It works very well. Thank you very much. Best regards Jingbo