Using Arrays in thinger

is there any way to send array data to the platform?
lets say i collect realtime data, but of course i just want to report it periodically.

Hi @Rodrigo_Molina, yes, it is possible to use arrays. However, using arrays will limit you when using the device information, as practically all widget dashboards use single values. What is your specific use case?

Hi, I am trying to achieve this as well.
The idea is to collect data at specific intervals during device awake/sleep cycles, and when enough data is collected, power up the wifi module and send the whole array to thinger. Rinse and repeat.
Hoping to maximize battery lifetime with this technique.
Also I will be writing a custom PC app for data visualisation, so that I’m not limited to thinger’s widgets using single values.
Hope you can provide some links to documentation that can help me achieve this.

Thanks in advance!

Hi, I tried going through the documentation and community for an answer on this. I am looking at uploading a 8x8 array into a bucket which I can later export to a server or better yet if Thinger comes out with the ability to add a custom widget I would like to add the data over to it.

Hi, i am trying a similiar thing. Did someone figure out how to do this?
Is it possible with the pson_array type?

Hi. I need to access a 42 byte array on my ESP32 module. The interface will be done using an Android App so, the dashboard limitations are not important. @alvarolb says that this is possible but I have not found any tnformation on how to do it. Can someone give me some help on this? Thanks in advance!

Hi, something like this should send to the cloud a set of variables named from “outArray_0” to “outArray42” with the values from “array[0]” to “array[42]”.

  thing["Array"] >> [](pson & out) {
  String name;
    for (int i = 0; i <= 42 ; i++)
    {
      String name = "outArray_";
      name += i;
      out[names.c_str()] = array[i];
    }
  };

Hope this helps.

You can do it the stupid way e.g in a property:
pson lequ;// 0…23=hour, 25=current, 26=lequ 24h, 27= leqDay, 28=leqNight, 29=Lden
lequ[“00h”] = leq[0];
lequ[“01h”] = leq[1];
lequ[“02h”] = leq[2];
lequ[“03h”] = leq[3];
lequ[“04h”] = leq[4];
lequ[“05h”] = leq[5];
lequ[“06h”] = leq[6];
lequ[“07h”] = leq[7];
lequ[“08h”] = leq[8];
lequ[“09h”] = leq[9];
lequ[“10h”] = leq[10];
lequ[“11h”] = leq[11];
lequ[“12h”] = leq[12];
lequ[“13h”] = leq[13];
lequ[“14h”] = leq[14];
lequ[“15h”] = leq[15];
lequ[“16h”] = leq[16];
lequ[“17h”] = leq[17];
lequ[“18h”] = leq[18];
lequ[“19h”] = leq[19];
lequ[“20h”] = leq[20];
lequ[“21h”] = leq[21];
lequ[“22h”] = leq[22];
lequ[“23h”] = leq[23];
lequ[“Leq”] = leq[25];
lequ[“Day”] = leq[26];
lequ[“Daytime”] = leq[27];
lequ[“Nighttime”] = leq[28];
lequ[“Lden”] = leq[29];
lequ[“L22-24h”] = leq[30];
thing.set_property(“lequ”, lequ);
}

@rin67630 thanks for your reply. However i must confess that I do not understand what you are suggesting…

@ega thanks for your reply.
This is the brute force approach (creating 42 variables) but it probably will solve the problem.
In the pson class definition from pson.h there is a enum field_type value for “bytes_field” and for “array_field”. What I would like to know is how to use these types.

That was just an example out of one of my sketches.
Just create a property and assign every element of the array to a name inside that property.
With set_property (after the assignment list) you upload the values to thinger.
With get_property (before the reversed assignment list) you retrieve the values (e.g. in setup).
You can even populate manually the values in the device properties from thinger and upload this way initial values to your array.

@rin67630 I understand it now. I will try it, Thanks

This ist the part to put in setup to recall the values:
pson lequ;
thing.get_property(“lequ”, lequ);
leq[0] = lequ[“00h”];
leq[1] = lequ[“01h”];
leq[2] = lequ[“02h”];
leq[3] = lequ[“03h”];
leq[4] = lequ[“04h”];
leq[5] = lequ[“05h”];

This is the (abbreviated) part to put in loop to update the values:
pson lequ;
lequ[“00h”] = leq[0];
lequ[“01h”] = leq[1];
lequ[“02h”] = leq[2];
lequ[“03h”] = leq[3];
lequ[“04h”] = leq[4];
lequ[“05h”] = leq[5];
lequ[“06h”] = leq[6];

thing.set_property(“lequ”, lequ);

You can create a thing which output is a pson_array which holds pson_objects.

For example:

thing["array_test"] >> [](pson_array& out) {
      pson_object & test_obj = out.add_object();
      test_obj["key1"] = 1234;
      test_obj["key2"] = true;
      test_obj["key3"] = "example_string";
};

This creates a pson object with any data and adds it to a pson_array which gets uploaded to thinger.io when the recource is called.

I had to update the pson library manually by replacing the pson.h file with the latest pson.h from here: GitHub - thinger-io/Protoson: Json Binary Encoding for Microcontrollers