How to set the time inside an Arduino using MegunoLink Pro

Support forum for MegunoLink
Post Reply
philr
Posts: 270
Joined: Mon May 26, 2014 10:58 am

Tue May 27, 2014 9:45 am

Hi a user of MegunoLink Pro asked me a while ago how you go about setting and using the time on an Arduino. The trick is to add this nifty time library to your Arduino installation and then use MegunoLink's interface panel to send a message which will update the current time on the Arduino with the time on your computer.

The library includes an example called "TimeSerial". This program lets you send it the number of seconds since January 1st 1970 using the serial connection. It then decodes the message and uses it to set the microcontrollers time which it then continues to keep.

To send the special message to the Arduino using MegunoLink Pro, add a connection manager, monitor, and interface panel. In the interface panel add a button and configure it to send the following message:

Code: Select all

T[Math.Round(DateTime.Now.Subtract(new DateTime(1970,1,1,0,0,0)).TotalSeconds)]
The Arduino will detect the message and update its time to match It's that simple!

Give me a yell here if you have any questions. I'll also organise an example of this to go in to the next version of the MegunoLink library.
Post Reply