Sync time P.C. to Arduino.

Status
Not open for further replies.

Pommie

Well-Known Member
Most Helpful Member
This seems to come up every now and again and I needed to do this myself so here's an Arduino Sketch and a Visual Basic program to synchronize the Arduino clock (DS1307) to the P.C. clock. The VB program is in Visual Studio 2012 express but should work in any of the later releases as well - I've tried it in VS2017 and all OK.

It's self explanatory (I think) and looks like this.


Hope it's useful to someone.

BTW, the serial monitor can't be running at the same time and if you wish to compile the sketch then you need to disconnect the VB program.

Mike.
 

Attachments

  • VB Sync Time.zip
    87.5 KB · Views: 388
  • Sync_Time.ino
    3.4 KB · Views: 410
For any IoT type devices that have internet connectivity, you can get the time direct from an internet time server quite simply.

This gives the details needed to set up a request frame (just a lower case c padded with 47 space characters) and interpret the reply.
You could use a local server or eg. pool.ntp.org

**broken link removed**
 
I use NTP whenever I use a Wemos or other 8266 based board. However, this is a Nano setup with one of the US$2, I²C, DS1307 + 24C32 memory on board. It was easier to write the code than mess about adding setup buttons and code.

Mike.
 
I use NTP whenever I use a Wemos or other 8266 based board. However, this is a Nano setup with one of the US$2, I²C, DS1307 + 24C32 memory on board. It was easier to write the code than mess about adding setup buttons and code.

Mike.

A good idea - I've usually done it via a simple serial connection, and entered the time via a terminal program.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…