summaryrefslogtreecommitdiff
path: root/sensor.c
diff options
context:
space:
mode:
Diffstat (limited to 'sensor.c')
-rw-r--r--sensor.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sensor.c b/sensor.c
index 29f2718..834c6bf 100644
--- a/sensor.c
+++ b/sensor.c
@@ -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