diff options
author | Erich Eckner <git@eckner.net> | 2019-09-23 10:04:19 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-09-23 10:04:19 +0200 |
commit | d2bebfd3dccea46f0c8edefcdb450b7d240390e9 (patch) | |
tree | 7689594c0430572195e0d993b03f7068b10c100a | |
parent | ad127a427b4f7cfbea1ee98231ecd15102ab8c6a (diff) | |
download | raspi-sensor-d2bebfd3dccea46f0c8edefcdb450b7d240390e9.tar.xz |
sensor.c: print date, too
-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 |