diff options
Diffstat (limited to 'sensor.c')
-rw-r--r-- | sensor.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -11,6 +11,7 @@ #include <string.h> #include <ctype.h> #include <unistd.h> +#include <time.h> #include "wiringx.h" @@ -69,8 +70,12 @@ int main() { fprintf(stderr, "Failed to open '%s' for writing.\n", "/srv/http/tmp/sensor"); return -1; } + time_t now = time(NULL); + char time_str[20]; + strftime(time_str, 20, "%Y-%m-%d %H:%M:%S", gmtime(&now)); fprintf(of, "RH: %f %%\n", data[0] + data[1]/256.); fprintf(of, "T: %f °C\n", data[2] + data[3]/256.); + fprintf(of, "t: %s\n", time_str); fclose(of); } // main |