Alarm Function

What is the best way to set an alarm event on the Yun?

The “TimeAlarms.h” library functions seem like they would work for my needs but I am unsure how to get them to work properly with the Yun.

My issue is I want to log data continuously and then at a specific time of day pause the data logging for a few seconds and upload the data file, then resume data logging. The upload would repeat everyday.

If you want to do something at a specific time every day, this sounds like a perfect application of a cron task on the Linux side. This is especially true since the functions you want to do (read an SD card file, and upload over the network) are handled by the Linux side: why reinvent a scheduling system in the sketch, then move all of the data from the SD card, through Linux and into the sketch, then back through Linux and out the network?

  • Write a Linux shell script to upload your file, probably using the command line version of cURL.
  • Then set up a crontab entry to run that script daily at the desired time.

lexical43:
::::SNIP::::

My issue is I want to log data continuously and then at a specific time of day pause the data logging for a few seconds and upload the data file, then resume data logging. The upload would repeat everyday.

@lexical43,

There is no reason to stop your data collection. *nix/Linux was made for this. On the *nix side there is a command line utility named date(1). Date has an option called seconds-since-epoch. It is the number of seconds since Jan 1, 1970 12:00am. The command you will want is
** **date -%s** **
. What you do is quickly replace your log file and then append that epoch value as the filename extension.

It would look like this.

logfile.1436389325

Best of Luck
Jesse

jessemonroy650:
What you do is quickly replace your log file and then append that epoch value as the filename extension.

It would look like this.

logfile.1436389325

I've done something similar using the date as the file name: log20150709.csv would be today's file.

Each day, it automatically rolls over to a new file. Then, a cron task is set up to run a minute after midnight each day to transfer the old file to backup storage. It could also purge out old files (say those over a week or a month old.)

BTW lexical43, Jesse is a good person to give advice on this and to help with cron. :wink: