Go Down

Topic: Possible to print millis in [HH:MM:SS] format? (Read 4 times) previous topic - next topic

.jacob

Nov 16, 2010, 12:33 am Last Edit: Nov 16, 2010, 12:33 am by .jacob Reason: 1
Hi I'm trying to insert arduino runtime into a tweet like this:

Code: [Select]

sprintf(tweet,"%d Sensor Reading S1=%e S2=%e", millis, (float)temp_f, (float)real_humidity); //Your tweet message


But millis of course is just the ms it's been running in raw form which quickly becomes a huge string.  How can I format millis into a 24 hour display, [HH:MM:SS] that resets every 24 hours, or better yet, insert an authentic time value?  I need a time stamp of some sort to get around Twitter's spam filters.

Thanks!


Korman

#1
Nov 16, 2010, 12:43 am Last Edit: Nov 16, 2010, 12:43 am by Korman Reason: 1
Look at the Time Library. It provides all the functions you want for this.

Korman

PaulS

You'll need an RTC if you don't want to have to reset the real time every time the Arduino restarts.

.jacob

Thanks!  A RTC would be nice to have but not necessary as I just need some sort of counter not to exceed 6 digits to get around Twitter filtering.

I'll experiment with the time library.


PaulS

If that's all you need, just generate a random number. Or, only use the last 6 characters of millis()'s value as a string.

Go Up