bulk update to save battery? | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
bulk update to save battery?
No permission to create posts
May 6, 2019
12:42 pm
Avatar
obod0002

Silver
Members
Forum Posts: 19
Member Since:
March 13, 2019
sp_UserOfflineSmall Offline

Hi,
I'm collecting data by some ESP's. As Wifi is expensive in terms of battery I first tried to gather the data in the internal memory of the ESP's and to upload it e.g. only once a day.
Unfortunately MATLAB is storing when data is uploaded and, luckily, you can access that information quite easily, e.g. by adding

'Outputformat','Timetable'

to your tables.

But, could I use one of the 'Fields' of a 'Channel' to also upload date and time when the data was produced and ignore MATLAB's internal timekeeping?
Which format do I have to pass over to MATLAB or which format changes do I have to do while parsing the data in MATLAB? Could I e.g. use 'seconds since 1970' and is there any MATLAB function to easily convert the entire column?

Maybe there's a link I haven't found or an excerpt of a routine you're using?

Thx

May 7, 2019
11:47 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 754
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Are you using the REST API for your update? If so, use the "created-at" parameter to set the time when the data was produced.
Have a look at the Write Data page:
https://www.mathworks.com/help/thingspeak/writedata.html

You can also use the created-at parameter in the bulk update to save more battery and send your posts all in one update. The bulk update syntax is a little trickier though:
https://www.mathworks.com/help/thingspeak/bulkwritejsondata.html

Time formats are described in the created-at parameter: " Absolute time of the event in ISO 8601, EPOCH, or MYSQL format. The timestamp must be unique within channel."

ThingSpeak and MATLAB should be able to handle the time series data without resorting to using a field for storing time.

Later in the post you talk more about manipulating data in MATLAB instead of posting from the device. Let me know if there is another question you have about time manipulation in MATLAB.

May 8, 2019
1:06 am
Avatar
obod0002

Silver
Members
Forum Posts: 19
Member Since:
March 13, 2019
sp_UserOfflineSmall Offline

I'm using something like

ThingSpeak.begin(client);
client.connect( "api.thingspeak.com" , 80 );

ThingSpeak.setField(1, (float)value1);
ThingSpeak.setField(2, (float)value2);

if { ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey) == 200) {

Looks like it's a bit differing from what you mentioned? Would the created_at be possible here as well or should I rather re-code that part?

May 8, 2019
8:53 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 754
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

try ThingSpeak.setCreatedAt(timestamp)
right before or after the setField.

There is documentation about it here:
https://github.com/mathworks/thingspeak-arduino

June 15, 2019
6:49 am
Avatar
obod0002

Silver
Members
Forum Posts: 19
Member Since:
March 13, 2019
sp_UserOfflineSmall Offline

cstapels said
The bulk update syntax is a little trickier though:
https://www.mathworks.com/help/thingspeak/bulkwritejsondata.html

While preparing the changes I had to learn that updating ThingSpeak every 20minutes using #include ThingSpeak.h and ThingSpeak.writeFields burns energy like a V8: uploading one set of three elements takes about 6 seconds!!! - at least in my configuration

I'm now using JSON POST request and 'same' upload is done within 250milliseconds.

I also managed to get the bulk upload to work. Thanks a lot for your help, @cstapels
At the moment, however, I'm fine with the current optimizations.

June 15, 2019
7:41 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 327
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

obod0002 said

While preparing the changes I had to learn that updating ThingSpeak every 20minutes using #include ThingSpeak.h and ThingSpeak.writeFields burns energy like a V8: uploading one set of three elements takes about 6 seconds!!! - at least in my configuration. I'm now using JSON POST request and 'same' upload is done within 250milliseconds.

 

Are you using the latest version of the ThingSpeak Support Library?

We made some very significant improvements in the recent past hat have reduced the memory footprint and included other optimizations.

August 8, 2019
3:25 pm
Avatar
obod0002

Silver
Members
Forum Posts: 19
Member Since:
March 13, 2019
sp_UserOfflineSmall Offline

sounds interesting. I'm using 1.4.3 at the moment and see that 1.5.0 is available. Would that come close to JSON uploads in terms of speed?
It's a lot easier to use the library instead of coding every byte by myself ...

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
33 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Fathima22, jefflam1994, harrydawson, markpaul7931, sgarsvk2rdx, Win Win

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457