Go Down

Topic: Update ds1307 rtc-NTP sync tool (Read 8108 times) previous topic - next topic

robtillaart

Together with Rodrigo Castro an Arduino 1.0 update was made for - http://www.arduino.cc/playground/Main/DS1307OfTheLogshieldByMeansOfNTP -

The code should work under 0.22, 0,23 and 1.0

As always comments and remarks are welcome, in this thread.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Dane

Thanks for this.

Should the code be updated to prefer DHCP if the Arduino board supports it?

Also,
Quote from: robtillaart link=topic=85764.msg642340#msg642340

07/01/2011
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1291637975#10
shows DST function, to be integrated.


Was this integrated into the 04/01/2012 version? I'm unsure how/if I would need to handle DST for my location/project.

THANKS

robtillaart


no, not integrated, but you are free too.

I prefer to do my logging without DST to prevent gaps/doubles in my data set
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#3
Apr 26, 2012, 09:03 pm Last Edit: Apr 26, 2012, 09:08 pm by Bajdi Reason: 1

Together with Rodrigo Castro an Arduino 1.0 update was made for - http://www.arduino.cc/playground/Main/DS1307OfTheLogshieldByMeansOfNTP -

The code should work under 0.22, 0,23 and 1.0

As always comments and remarks are welcome, in this thread.


I think there is a typo in the example sketch on the playground.
Code: [Select]
#if ARDUINO >= 100
#include <EthernetUdp.h>        // New from IDE 1.0
#else
#include <UDP.h>
#endif


UDP.h should be Udp.h
At least on my system:
sketch_apr26a.cpp:31:17: error: UDP.h: No such file or directory
I'm still using version 0023, my gentoo installation and 1.0 don't play nice. I should do something about that and switch to 1.0  :smiley-red:

Oh, and thanks for the sketch and libraries.


www.bajdi.com

robtillaart


updated the example, thanks for the feedback
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

I am using Arduino IDE 1.0.1 and I can't get UDP , I Know all about IP addressing and gateway etc...
My MAC Address don't even show up on router list....
No Compile errors....

Can this work with on v 1.0.1 ?

I downloaded Arduino IDE V 1.0 and it worked!
The IDE V 1.0.1 Don't Work..... Byte Command Word ? Something changed in the compiler....



robtillaart

@shane
have you checked the release notes of 1.0.1?

As I have limited time now (other prio's) I cannot dive into this and redesign it to support new version. If you have patches please share them here.

Thanks,
Rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Having originally failed continually with "No UDP available ...", I managed to get UDP working by first reading packet size by using parsePacket, and then modifying the Udp.read to use that packet size

Code: [Select]

int packetSize = Udp.parsePacket(); //<<<<<<<<<<<<NEW LINE HERE
// send an NTP packet to a time server
sendNTPpacket(timeServer);

...
Udp.read(pb, packetSize);      // New from IDE 1.0 <<<<<<<<<<<<<MODIFIED LINE



And then, if you aren't in Chile, remember to make your own adjustment to UTC in the line which reads
Code: [Select]
t4 -= (3 * 3600L);
(the notes say this is a 4 hour adjustment, but clearly it is 3 hours)

robtillaart

#9
Apr 07, 2013, 07:26 pm Last Edit: Apr 07, 2013, 07:34 pm by robtillaart Reason: 1
Thanks John for this improvement!

can you post your complete modified version, then I will update the playground code.

Thanks again,

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nino90

Hello
I am trying to sinhronize my time clock withe an ntp server but i have some issues. On these site:
http://playground.arduino.cc/Main/DS1307OfTheLogshieldByMeansOfNTP
I found the code wich should work, but it gives mee allways the same message No UDP available ., and i cannot understand why is that ?
Maybe the ntp server is out of date or something, i have tried to find another one and ping its address to find its ip, but i got the same message, I am in Europe so i need an european Server.
So the code is the same as the on on the example


robtillaart


1) check if your router blocks UDP and/or port 123.
2) check which NTP server your router uses (your internet provider offers) and use that one.
3) check - http://support.ntp.org/bin/view/Servers/WebHome - for an alternative NTP server.

Please note that NTP servers block IP addresses that request too often
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nino90

#13
Sep 14, 2013, 04:30 pm Last Edit: Sep 14, 2013, 04:36 pm by nino90 Reason: 1
well when i use the code from this tutorial http://arduino.cc/en/Tutorial/UdpNtpClient
it works, but it is not my timezone, and i dont know how to find the ip of a ntp server I can just find the name of the srever, the ip i ping from cmd and find out, however, even when i put the ip from the tutorial http://arduino.cc/en/Tutorial/UdpNtpClient, in the code from http://playground.arduino.cc/Main/DS1307OfTheLogshieldByMeansOfNTP it doesnt work. So that means it is not the problem with the server and i can recive udp with no problem.
I was compairing those two codes and could only find a difference taht the one that works uses Udp.parsePacket() insted of Udp.available(). Bet even if i change that it doesnt work
PS: i would use the one that works, but it gives me only time, I need date also and to synhronise it with the timer

robtillaart

Quote
but it is not my timezone,

you must add an offset =  3600L * hours;  to get the adjusted the timezone.
Every timeserver responds in universal time == Greenwich mean time zone.

Which IDE version do you use?


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up