5

Okay so I did this project from Fritzing first in my circuits.io project then on the arduino itself, it all works fine just how I wanted it.

But here is what I wanted to add, as you can see when you plug the arduino in it will set the time to 00:00 and you can adjust it yourself to the time right now, let's say 12:57. Then you put in the alarm so let's say you want to sleep an hour u put the alarm on 13:57.

Is there a way to automatically get the time from the computer? So you don't have to adjust it yourself everytime and start from 00:00.

Thanks for all the help!

  • Two ways: 1. Add a network interface to get the time from an internet time server (for example). 2. Write some software for your PC that gets the time and have the Arduino communicate with that through serial. – Majenko May 12 '17 at 11:10
  • 4
    Alternatively add an RTC so it remembers the time while it's turned off. – Majenko May 12 '17 at 11:29
  • 1
    But be careful some popular/cheap RTC modules claim to have recharge circuits when they don't and vice versa. (+1 for a good first question, BTW) – Code Gorilla May 12 '17 at 12:08
  • There are also atomic clock and GPS options Reading atomic radio clock – Johnny Mopp May 12 '17 at 13:17
1

There are several ways, and they are covered in the comments above.

  1. The answer to your question. Via Arduino USB to serial interface. and a simple batch file on a windows computer example:

    @echo off

    set datetimef=%time:~0,2%.%time:~3,2%:%time:~6,2%

    echo %datetimef% > COM5

COM5 is used as a example, your serial port can be another number.

The format in the example is hour.minute:second

| improve this answer | |
  • 2
    And you can have your batch running in a loop every n minutes, and presto! you have your own NTP "serial" server. Brilliant! – user31481 Aug 8 '17 at 13:54
  • And you may also need to set the COM port to correct speed: mode COM5 BAUD=9600 PARITY=n DATA=8 – MatsK Aug 8 '17 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.