PC time

Hi,

I am looking for a simple way to retrieve the pc clock date/time on arduino101 by using the normal USB connection, without any extra hardware. I will use the clock data to synch my RTC afterward.

Any help is appreciated!

To do what you want there needs to be some software running on the PC to send the time data to the Arduino.

Do you know what software is needed?

You were just told what software is needed.

It's unlikely you will find a ready made application that does this. Instead you would probably need to create your own and that could be done in numerous ways. The best way to proceed with that would depend on whether there are any programming languages or frameworks used to create PC applications that you're currently familiar with. For example, if you're skilled in Python, then the obvious choice would be to use Python.

If tell us what experience, if any, you currently have that could be applied to this project. We may be able to use that information to provide you with more specific advice.

Maybe with Processing

int s = second();  // Values from 0 - 59
  int m = minute();  // Values from 0 - 59
  int h = hour();

Then send it to Arduino.

Paul_KD7HB:
You were just told what software is needed.

What was that software ?

Obviously you didn't read my reply, where I clearly explain the situation and ask for some information so that we can help you further.

My solution may be a sledgehammer solution,, but since I already use MQTT in many of the nodes around the house, it was a simple task to have NodeRed publish the time every ten seconds to topics time12 and time24 (12-- and 24-hour format respectively).

I could sent it more often than every ten seconds, but it suits my needs.

It seems like there has to be some standard solution here, since people buy RTC modules all the time and use them. How do they get the time into it initially?

1 Like

DrAzzy:
It seems like there has to be some standard solution here, since people buy RTC modules all the time and use them. How do they get the time into it initially?

I've seen several cases of a specialized sketch to do this, some RTC libraries even include it.
It uses the compile time of the sketch to set the time.
i.e. the DATE and TIME strings.
It parses those and uses it to set the time.
It is one time thing that you compile and run when you need to set the time.

These days if you have an Arduino that has WiFi like the ESP modules, you can use NTP to get the time.
You don't even need an RTC. Or you can use an RTC and set it using NTP.

If it is desired to get timing information over USB (assuming that means a virtual serial session), then, as UKHeliBob pointed out some sort of s/w is needed on the host to send the time information out the virtual serial port over the USB interface and then the Arduino must receive it and parse it.
The common TimeLib library includes an example (TimeRTCset.ino) to parse time information from the serial port from a host.
On *nix systems it is easy to spit out the information. It can also be done on Windows based systems but it isn't as simple to get the desired output format re-directed to the needed serial port.

--- bill

1 Like

Thanks a lot for all the comments. I will try the suggestions.

Bests
Mebab