help! I need sync arduino with the clock PC.

Hello.

I'm beginner in Arduino and I need to create a kind of schedule.
the aim is to make the arduino able to know what day of the week and we also know the precise time.
I've used the example of DateTime arduino playground but could not get any results.
I had many errors declaration functions.

I need to know if the code is correct and functional? yes if someone can help me put my project in motion?

Thanks.

Rafael_23:
I've used the example of DateTime arduino playground but could not get any results.
I had many errors declaration functions.

I suggest you post the code you were using (the whole sketch, enclosed in code tags), and the errors you got from it.

I use a TinyRTC v1.1 "RTC I2C DS1307 AT24C32 Real Time Clock Module For Arduino
and the RTClib, Time, TimeAlarms Libaries to do this

Try this:

void setup() {
Serial.begin(115200);
}

void loop() {
Serial.print(DATE);
Serial.print(" ");
Serial.println(TIME);
delay(5000);
}

K5CZ:
Try this:

void setup() {
Serial.begin(115200);
}

void loop() {
Serial.print(DATE);
Serial.print(" ");
Serial.println(TIME);
delay(5000);
}

That will repeatedly print the date and time at which the program was compiled, which is not what is wanted.

I know, but DATE and TIME is simplest way to "push" current date and time to Arduino and work with these. In combination with a time.h library Arduino can show almost current date and time after sketch is uploaded.

For my needs I use a combination of NTP server and RTC chip, but this requires additional hardware and for a beginner it is not so easy.

Third way is to write terminal application and send accurate timestamp to Arduino over serial, but this is hardest way.

Hi again!

In moment i have a Tiny RTC I2C module but when i run the example sketch "TimeRTC" the program return the error:
TimeRTC.pde: In function 'void setup()':
TimeRTC:14: error: 'RTC' was not declared in this scope

So i can't know what is the time and date in RTC.. Can you help me with this problem?

Thanks.

Do not have any DS1307 chip, so I never tried this sketch, but I think you missed <DS1307RTC.h> library.

Try to download and import library from:
http://www.pjrc.com/teensy/td_libs_DS1307RTC.html

I looked into the library and I found that it can be used with the DS3231, which I have and it works!

Thanks K5CZ! :wink:

In fact i have the lib <DS1307RTC.h> installed but the problem may be linked with the function RTC.get() in this library.
So like i said my program can’t recognize the function and report me the error.

I can’t understand this. I have doing install/uninstall the library <DS1307RTC.h> and the problem still exist.

Can you tell me if it may be the version I’m using arduino?

I do the download library in Arduino Playground - HomePage and install the Time lib in past libraries of arduino.

I open the sketch TimeRTC and when i compile the program the sistem return the same error in the line 13.

  setSyncProvider(RTC.get);   // the function to get the time from the RTC

At the moment i still not able to solve this problem and i not yet realized what the error is that I am committing. :frowning:

Your libraries may be imported incorrectly. Did you use this method?

Thanks a lot K5CZ!!! :slight_smile: :wink:

I do not know this method but it worked perfectly. you are a genius.

Any questions I post here.

Thanks so much!

Hi!

Now i have a Arduino MEGA and when i doing ‘compile’ sketch the led 13 blinkly. What make this possible? RAM of system? :confused:

I use many array and e need replace UNO for MEGA and after some code lines the problem return. I do not know what can be.

after compiling the program says: “Binary sketch size: 18.084 bytes (of a 258.048 byte maximum)”

It’s not normal…i think.

Thanks

Do you mean that LED13 sometimes blinks and upload of sketch fails? My last piece of knowledge (or my hard "new discovery") is three exclamation marks problem. Simply remove !!! from your sketch (if they are there).

For better advises, please attach your sketch to post (if it is long) or use CODE tags ( [ # ] icon ) and publish your sketch.

Rafael_23:
Hi!

Now i have a Arduino MEGA and when i doing 'compile' sketch the led 13 blinkly. What make this possible? RAM of system? :confused:

I use many array and e need replace UNO for MEGA and after some code lines the problem return. I do not know what can be.

after compiling the program says: "Binary sketch size: 18.084 bytes (of a 258.048 byte maximum)"

It's not normal..i think.

Thanks

Which part of this is the problem you're asking for help with? Are you having trouble compiling the sketch, or uploading it, or a problem with what it does when it runs?

i have found a solution for this :wink:

i I had many Serial.print and that was to occupy me a lot of memory. I lost some time and figured it out.
But thank you very much for your help!

Thanks

actually I’m having the same problem with MEGA.
I have some variables declared as local and, when put as overall program, the memory occupied greatly increases.
Now, with the development of the code, the memory is increasing again, preventing me from continuing the program.
I do not know if you can be be using many arrays but I do have to use them.

I do not look anything like normal memory usage is growing very much every cycle if / for that I implement.

Intervalos_teste11.ino (72.8 KB)

Oh yes, I also had the same problems with memory! But forum users advised me to use keyword PROGMEM and F macro.

It is simply:
Serial.print("Hello!");
occupies 6 bytes of Flash EPROM and also 6 bytes of RAM !!!
Serial.print(F("Hello!"));
occupies only 6 bytes of Flash EPROM and no RAM :slight_smile:

PROGMEM is little complicated to use, so look for examples to learn.

ok, thank you!
I'll put all the print as 'flash'.
I will study PROGMEM and say something.