Complex multi-gates system with several Arduino boards and radios communicating with a “central” unit.
When a gate is activated (open, stop, close), the gate controller sends a message to the central, where date, time, operation, user etc are logged on an SD high volume card. The central adds date and time to the log before writing it to the SD card, reading time and date from the Velleman RTC.
When connecting the PC to the controller (USB), using Serial.xxx functions, I want to reset the date/time on the RTC, reading the PC date/time.
How could I do that?
(I can set the RTC manually, but I want it automatic, each time I connect the USB)
// execute a command from Arduino monitor
// Read the header byte to determine the type of command
msg = Serial.read();
case 0x01: // Central request for log
case 0x02: // Write dummy log to SD card
if (key_check() > -1) // any key gets the menu (options such as download and erase LOGs from SD card)
if (Serial.available()) // USB MESSAGE FROM MONITOR
USB_command(); // execute the command, ie reset the clock
if (ZetaSerial.available()) // ZETAPLUS MESSAGE FROM GATES