Hi, I am new to this, although have done loads of programming (some in C) way back. I'm now trying to set up a Uno R3 to be able to access the RTC on a data logger shield, but, when compiling the code, I see the error message:
'RTC_DS1307 RTC' does not name a type; did you mean 'DS1307' ?
I have the code: #include <Wire.h> #include "RTClib.h"
(but I'm not sure why Wire.h has <> brackets, whereas RTClib.h has "") - I've tried changing the "" to <> but it makes no difference.
The especially puzzling part is that the code for this was copied from the Tinkbox notes for the Keyes Data Logging Shield . I also see the same error message if I change the shield to the Deek-Robot Data logging shield. It doesn't seem to get as far as uploading the compiled code to the device, so it isn't something there, such as a dud coin-cell battery.
Does anyone have any idea how to make this work ?
Thanks
WildBill - Thanks for your reply. Both the DeekRobot and the Keyes data loggers were sold as compatible with the UNO R3, so I'm assuming they are.
Crossroads - Thanks, too, for your reply, and the very useful info about the <> & "" meanings. I'll see if I can locate the folder containing RTClib.h -- If I'm using Arduino Create (which I understand is the on-line version rather than a program on my desktop computer) should that automatically find it, or should I download it and put it into a folder on my computer ?
Wildbill: Thanks - following your advice (Change RTC_DS1307 to DS1307) I tried that, and the compiler seemed to like it. However, it then came back with:
'DATE' was not declared in this scope
The code preceding that is:
[if (!RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// The following line sets the RTC to the date & time this sketch was compiled
// uncomment it & upload it to set the time, date and start run the RTC.
RTC.adjust(DateTime(DATE, TIME);
}
]
When I made the RTC.adjust line a comment the sketch compiled successfully, but that's not much help if I can't subsequently set the date & time !
The enigmatic thing is that this code was lifted from the Keyes Data Logging Shield on the Tinkbox site notes.
I just deleted and retyped the underscores (just to be certain), but had the same response ('DATE' was not declared in this scope) on recompiling.
Sadly, I can't remember enough from my C programming days to remember what "in this scope" means (and whether it would made a difference).
f I'm using Arduino Create (which I understand is the on-line version rather than a program on my desktop computer) should that automatically find it, or should I download it and put it into a folder on my computer ?
According to this link the Web Editor should find the library
All the libraries available in the Library Manager are automatically detected, so you’ll never need to install them to get your code to compile.
RTC_DS1307 RTC is correct syntax for RTClib.h.
Something is wrong, and following the compiler down a rabbit hole is not going to help.
Does the web editor get you to the library examples for RTClib.h?
Wildbill: I just checked and put two underscores each side of both DATE and TIME, and that compiled with no errors (Yippee !).
However, it didn't ask me to set the date or time, and looking at the Monitor, it produces what looks like garbage (not even a flow of Hex).
I know there's a particular way to include the sketch, but can't remember what it is. Please can you remind me ?
Wildbill: I just tried with the other board (the Keyes one, instead of the DeekRobot one), which gave the same output. Then I noticed the baud rates were different, so I set that to 57600 and recompiled it to the board. It then seemed to be producing hex, but maybe not.
Its output shows as :
ccA8Fcc 8<FccA<Fc<FcCNң88cNcCccK8ҡX<F<FccA<Fcc9c Fc8cN<FcEcCccC8EɡXccA8FccA9<Fc8cKcccccC8cҡXҡXҡX9ÖNE"cc<F8F
and it's still not asking to be set correctly.
I may be a bit dim at the moment, but I can't see any reference to "Sticky threads" on my screen. I did go to "Community : Forum" and opened that in a new tab, but couldn't see anything there either - sorry (and huge thanks for your time and wisdom).
Cattledog: Sorry for the delay in response. Yes, clicking the "Libraries" tab does show me the library of UNO libraries, and each has an "Examples" link. Putting "RTC" in the search box only gives "RTCZero" which apparently doesn't work on the UNO. Putting RTClib.h brings back no matches.
The "sticky threads" are called sticky because they "stick" - they permanently remain as the first 3 threads. That's what I meant, "the top of the forum".
Try navigating through the Library Manager tab above the Search Libraries field. I can see RTClib there but I don't use the web editor and am not certain what to do from that point to access the library examples.
Aarg: Many thanks for the directions - I hadn't noticed them there, as I wasn't thinking that way !
Cattledog: That worked well - it came up with 3 possible libraries, of which 2 seemed promising, so I've added them to Favourites.
Running some of the examples all failed as they couldn't find what they needed in a temp directory. However, when I went back to my testbed sketch it worked perfectly ! I now have to analyse why - perhaps part of one of the "favourited" libraries had an update that suited.
Oh, and it set itself to the correct time from my desktop machine !
HUGE thanks to all who have offered advice. You are an amazing, generous, and patient group ! Many thanks.
...now can I make it work in the real sketch ???