Skip to content

Commit c8dbfe0

Browse files
authored
Add "setTime" function
Usecase: - wake ESP every 5 minutes from deepSleep to make a measurement and store it locally. - send all the data every 30 minutes to InfluxDB with timestamps for previous measurements. https://docs.influxdata.com/influxdb/v1.7/tools/api/#example-1-write-a-point-to-the-database-mydb-with-a-nanosecond-timestamp Works for me with a time_t as argument. ``` configTime(0, 0, "pool.ntp.org"); time_t now = time(nullptr); ``` (I'm calculating previous timestamps with "now" & "sleepTimeDuration" to avoid wifi in all the runs that get stored locally and only establish a connection in a run that also writes to the database; the small change in the code works for me ;-)
1 parent 703defe commit c8dbfe0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

InfluxData.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ class InfluxData {
1818
_values = (_values == "") ? (" ") : (_values += ",");
1919
_values += key + "=" + String(value);
2020
}
21+
void setTime(long int value)
22+
{
23+
_time = " " + String(value) + "000000000";
24+
}
2125

22-
String toString() const { return _measurement + _tags + _values; }
26+
String toString() const { return _measurement + _tags + _values + _time; }
2327

2428
private:
2529
String _measurement;
2630
String _tags;
2731
String _values;
32+
String _time;
2833
};

0 commit comments

Comments
 (0)