How to efficiently transfer bulk upload from an ESP8266 to ThingSpeak?

This link showed me how to successfully do a JSON bulk upload from an ESP8266 to ThingSpeak. I would like to post 60 values in one bulk upload to save on batteries. I know that it is possible to do a CSV bulk upload of data that does not include the "delta_t" or "field1" ascii text for every datapoint as with JSON. This repeated JSON text really bloats the data transfer (about 2000 characters for 60 values). I did successfully complete the Postman example provided in this link but I am unable to mimic this action in the code on my ESP8266. Does anybody know where example code exists - I've been looking for days? Sorry so cryptic but I'm trying to keep my query trim.

 Accepted Answer

Okay, I think I answered my question. Using this code example built for the Photon, I twisted it into minimal code for the ESP8266 just to demonstrate a bulk load of 6 data elements. Hard for me to belive, it works. From here I can build out the code necessary to build a larger string of 60 data elements. I hope that this can help others so am attaching the resulting code for others. Maybe I get an upvote to my current reputation of zero. The code is attached in the next post..

More Answers (1)

Code edited and reattached.
Second edit: Attached (*V4) is a more fully developed CVS-like code that builds an demo array, assembles the data, and sends the data to Thingspeak. The demo array only has 6 data pairs (delta_t, and field1). The data_length is a compact 95 characters. When I expand this to my full 60 data pairs, the data_length should be 419 characters including the commas and a pipe separators. My JSON version equivalent had about 2000 characters. One of the things I did to keep this compact was to ommit the commas representing empty fields #2 through #8, and the location info. These commas were suggested in a Postman example found elsewhere of this site. Hope this helps somebody as it took me several days to build, and debug. .

2 Comments

Thanks for taking the time to share. It is a difficult endpoint, but there is a lot of data to get into the right place. I think your work well help other users.

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Categories

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!