Is there any way to send data stored offline to Thinger.io

Hi, I’m currently using an Arduino Nano Connect RP2040 to send pressure sensor readings to a Data Bucket every 30 minutes. I’ve done this by setting up an outputValue resource and streaming it in loop{} every 30 mins.

The use case I want will mean the user may go out of range of wi-fi throughout the day. Is there any way using Thinger that I can store the data on the Arduino when disconnected from the wi-fi, and then on reconnection, send all of the data that I have saved.

Thanks,

Tom

Hi Tom,

Currently it cannot be done, due the thinger cloud establish the timestamp, maybe this could be a feature to request, the hability to store the timestamp directly from the remote device, to save the offline data and then update when the connection comes back.

Hope this helps.

2 Likes

Thanks for your response @ega, I thought that might be the case. Where do we place feature requests? Do you know if there is an easy way to ask Thinger to send the current timestamp to the device when there is a connection established?

Hi @Tom_Whiting,

devices can actually set the timestamp on the bucket, as long as you send it in the payload, i.e., you can use the write_bucket function with a payload like the following:

{
   "ts": 1647289544240,
   "pressure": 2.33
}

(ts is a timestamp field, which holds a unix timestamp in milliseconds: ms from 1/1/1970).

The problem here is that the device must use an RTC, and probably use NTP for sync time on boot, but it is feasible. Hope it helps!

3 Likes

Very interesting. I didn’t know this option was possible.
If it’s not in the documentation, it would be important to include it. An example demonstrating how to enter 20 pressure measurements with the respective timestamp, sending them all at once to the Thinger Server.
Thanks for the tip.

Hi @alvarolb, thanks very much for this information. Is ts something which thinger.io recognises as a timestamp and hence converts this into a date/time format e.g. 2022-03-17T15:16.00.000Z ? Or is ts just a variable that you created which just sends the timestamp in milliseconds to the bucket, as well as showing the Date column as the timestamp when it entered the bucket?

Thanks,
Tom

A Unix Timestamp is just a way to describe a point in time. Thinger.io use them to store the date/time of any given bucket entry. It is used always as an UTC time, so, we can later convert it to different timezones in the representation (i.e. dashboards). In the buckets section, what you see is a conversion from this timestamp to a ISO String representation, which is much more user-friendly.

So, what thinger does in any data being written to the bucket, is to check if it contains the ts key. It it is present, then, it does nothing and insert the provided timestamp (it must be unix timestamp in milliseconds). If the value is not present, then, it injects the current timestamp taken from the server.

Hope it helps!

1 Like

Very useful, thank you very much

1 Like

Thanks very much @alvarolb , managed to get it working nicely - key thing is the time has to be in milliseconds - I was doing it in seconds!

1 Like

That is a great information. So one can save massively power upon storing e.g. the minute-paced information in a local buffer and updating Thinger every 10 minutes at once with only one call?

Can we put the time stamp several times in one message or do we imperatively need a discrete message for every sequenced event?

2 Likes

At this moment the server and the library is expecting 1 message per call. But I think it can be changed to accept arrays. Will add it to the queue.

1 Like

Hi @alvarolb, has there been an issue raised for adding the ability to accept arrays? Just wondering if there had been any progress on this?

1 Like

hi evryone! I received data on/off from Thinger, an want handle on/off and send to lora node. pls help me!