Pages: [1] 2   Go Down
Author Topic: Update ds1307 rtc-NTP sync tool  (Read 7448 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rob Tillaart

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

Wales
Offline Offline
Full Member
***
Karma: 0
Posts: 244
Don't take things too seriously
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


no, not integrated, but you are free too.

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

Rob Tillaart

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

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.


« Last Edit: April 26, 2012, 02:08:33 pm by Bajdi » Logged


Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


updated the example, thanks for the feedback
Logged

Rob Tillaart

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

Mesa,AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Mesa,AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....


 
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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
Logged

Rob Tillaart

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

Derbyshire, UK
Offline Offline
Newbie
*
Karma: 1
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
t4 -= (3 * 3600L);

(the notes say this is a 4 hour adjustment, but clearly it is 3 hours)
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks John for this improvement!

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

Thanks again,

« Last Edit: April 07, 2013, 12:34:34 pm by robtillaart » Logged

Rob Tillaart

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

Sarajevo
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Sarajevo
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

any suggestions  smiley-sad
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Rob Tillaart

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

Sarajevo
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 14, 2013, 09:36:40 am by nino90 » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?


Logged

Rob Tillaart

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

Pages: [1] 2   Go Up
Jump to: