How to read Firebase timestamps
matzesoft opened this issue · 3 comments
Hi. I am currently trying to read timestamps stored in Firebase on my Arduino Nano 33 IoT.
However timestamps are very high numbers. The current timestamp I am writing this message for example is: 1634573019348.
Using the getInt()
function doesn't work because the return value only reaches up to 2147483647
, which is the highest a long
variable can get. Using unsigned long
should work, however this data type as it looks to me is not supported by the library.
Is there any other way to read timestamps?
Thanks for your help :)
The library was updated to v1.2.0 which supports double and 64-bit signed/unsigned integer.
Firebase-Arduino-WiFiNINA/examples/Basic/Basic.ino
Lines 63 to 70 in 979cc49
fbdo.int64Data() returns long long data type
fbdo.uint64Data() returns unsigned long long data type
The timestamp in milliseconds can't store in unsigned long (32-bit) unless unsigned long long (64-bit) or long long (64-bit).
To get 64-bit number, you can use getInt.
Oups, yeah your right unsigned long
is still to small.
But thanks for updating the library. Got it working now.