How to store complex measurements (in cloud variables)


I do have a device using Photon at its core to measure spectrums (visible part). The measusrements end up as an array of floats/doubles for each one. Currently looking at the cloud functions and variables it is possible to only use simple measurements that are limited to one value (or store them in some flattened way in a string - but that is limited by string length). Ideally I’d want to have a functionality where a measurement could be requested from a computer/Android/iPhone app and results can be passed back. Ideally as I understand this would call a registered function on a device to do the measurement and place a result in a variable. So it would be nice to have a support for variable to be able to hold an array of doubles or array of integers in addition to current single integer/double. At the moment I can only do it via several string variables (several because the whole measurement does not fit into one - my spectral measurements has 290 measured floating point values).

Maybe you want to try use a struct/class to define an object that has the arrays and functions that pass the data:

struct MyObject{
  double measure1[290];
  int measure2[290];
  double getFloat() { };  // you could even create member functions that pass back the variables within the struct/class
  int getInt() { };       // for example

is that sort-of what you had in mind?

How does that help me to store it in cloud variables??

I have no difficulty with capturing and storing them internally - passing them back to the cloud is an issue

Since you are stuck with int, double and string - I would convert the data to a json string that you can parse on the other end.

1 Like

yes, and moving the data via TCP (or UDP)

moving the data via TCP (or UDP)

That is in no way flexible and needs lots of setting up and coding. Hence the questionor even request here if anyone did something like that using Cloud functions on Photon.

The problem is a single string is too small. I am currently resorting to simpler approach to store it in string as CSV list and then chunk it up to 622 character portions and storing in 4 variables. It’s messy but sort of works. It would be nice if that could be supported natively as an array of simple types…

I guess you know your data… if you have fixed-width precision or not… we couldn’t know that.

What is there to know - 622 max characters in a string variable divided by 290 measurements gives you 2.14 characters per measurement. You cannot possibly hope to store fixed or floating point number in 2 characters including separator.

Can you send the data elsewhere? You could call a function to collect the data, post it to an external API and then publish an event to let you know you can go get it?

@AlexeyDanilchenko Can you just send this data to instead?

They also have some math functions you can run on your data in the cloud also if that helps any.


Thanks - that looks very good and seems on a surface to do exactly what’s missing from Particle cloud, store variable as object. I’ll give that a go - thanks for the help.

Glad I could help out :wink: