STD Deviation library

I need an idea on how to calculate STD in particle photon.
I currently have temperature data monthly.
I need to calculate the standard deviation each months to predict some outcome.
I’ve search the libraries in Particle Web IDE, but none.

Can anyone help me?

Oh, sorry… before I forget, the monthly data will be gathered from google spreadsheets.


Generally, any C++ standard deviation code should work.

This library looks like it could help you.


I want to add a new topic about google spreadsheet and particle photon, but I think this conversation is related. So… I need help and guidance from the expert.

I have successfully send temperature data from Particle Photon to Google Spreadsheet.
Now, I want to read back the data from spreadsheet to particle photon, in order for me to calculate the STD (monthly) from the sheets.

I have search in google on how to do it, but the searching result is not as expected.

Can anyone suggest me some ideas that work this problem out?


This thread is four years old and you have posted the “same” in a separate - double posting is not really appreciated in any forum as it skatters the conversation over multiple threads and ties down resources without extra benefit.

Hence I’ve moved the double post from the old thread to your own dedicated one.

If you want to pull in expertise from other users, you can tag them via their forum handle like this --> @Semp

1 Like

Ok, I’ll try this…

However, I actually still need to read the data from google spreadsheet in order for me to use the math (std)…
As corrected and merged by @ScruffR on my posted about “Google Spreadsheet + Particle Photon”.

Do you have any idea on how to read back the data from spreadsheet to particle photon, in order for me to calculate the STD (monthly) from the sheets?

Hi, @Moors7
Can you help me with my “Google Spreadsheet + Particle Photon” problem.
I can send data from particle to spreadsheet. Now, I want to read the data in spreadsheet, in order for me to calculate the std of the data from the sheet.

Need you and everyone’s help.

@Semp, why do you need send data to Google Sheets then back again to the Photon? Why not keep the data in the Photon and do the statistics there?

I want to make it as IoT…
How can I keep the data in the Photon?

@Semp, you really need to better describe what you are trying to achieve such as:

  • What data are you sending to Google sheets?
  • How often are you collecting and sending data points?
  • How much data is collected every month?
  • Why did you chose a one month interval for calculating STD?
  • Is the Photon controlling anything?
  • Are you using a Google sheet to just store the collected data or are you processing it and only wanting to send the processed data back to the Photon?

Understanding what you are trying to do allows us to better help you.

1 Like

I will answer the questions.

  1. the data that I sent to Google sheets is body temperature.
  2. I’m often take the reading one data for one day.
  3. the number of data in a month is varied because it depends on women’s menstrual cycle. in range of 25 to 48 days.
  4. because it is important for me to do a prediction whether ‘something’ is happen or not for that month (menstrual cycle).
  5. particle photon act as Wi-Fi based to send/put the temperature data to the sheets as cloud data storage.

that is why, I need to read back the data in the storage in order to do the prediction.

do you have any idea to read back the data in the Google spreadsheet?

@semp, though you can send the data to the cloud for long term analysis, you can also store several months of data locally on the Photon itself. You can use EEPROM() to store data or attach a FRAM or microSD to store your data. You can then do your calculations on the Photon without needing the data back from Google sheets. One thing to be aware of is that even if you lose internet or cloud connectivity, you can operate independently with local storage.

1 Like

I’m aware of EEPROM.
But I’m eager to know whether it is possible to read back the data that we saved in the cloud? Because, I’m also have done some other work that used cloud storage; the data can be pushed, but it seems hard(impossible) to red back the data. I don’t know why.

I need your opinion,
possible or not to read back data in cloud storage. If possible, how.

@semp, I will have to defer to @rickkas7 on advice for getting data back to your device.

Oh, thank you so much sir.
I’ll be waiting for @rickkas7 reply here.

You may want to watch this video which shows what you’d need on the Google side of things. Once you got that sorted you can move on to the webhook (Particle Console | Build your connected product) to employ the Google APIs.

You can create a client ID and secret as shown here

For setting up the API authentication you need this URL

And the access token URI would be this

It’s not really refering to Google API but the general authentication flow should be not too different from this


Thank you, Sir.

I’ll look at the link and watch the video.
Will get back here later.

Hi, everyone…

I have some news about my problem.
Now, I’m almost sure that I can do statistics using data in EEPROM.
Here I attach the code.

void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);
  ButtonState = digitalRead(ButtonPin);
  EEPROM_END = count;
        //Particle.publish("EEPROM_ENDe: ", String::format("{\"number =\": %d}", count));
    if (buttonState == HIGH) {
      t = writeTemp();
        EEPROM.write(address, t);         //write value to current address counter address
        Particle.publish("Temp Value:", String::format("{\"temp =\": %0.2f}", t));
        Particle.publish("Sensor value stored at address:", String::format("{\"address =\": %d}", address));
        count = address + 0;
        Particle.publish("Testing value: ", String::format("{\"Contcount =\": %d}", count));
      //Particle.publish("Button press count:", String::format("{\"count =\": %d}", buttonPushCounter));
    else if (ButtonState == HIGH) {
        float mean;
        for (int i = EEPROM_START; i < EEPROM_END; i++)
            sum = sum +;
            Particle.publish("Summation:", String::format("{\"sum =\": %d}", sum));
        mean = sum / count;
        Particle.publish("Average Value:", String::format("{\"mean =\": %d}", mean));
      //Particle.publish("Button press count:", String::format("{\"count =\": %d}", ButtonPushCounter));

However, I’m getting 0 value when I’m doing sum operation.
Need your idea on how can I get the sum operation better.
Below is a screenshot of the web IDE console.

Hope, we can together improve the code.

EEPROM.write() and only write/read one single byte. float is using four.
EEPROM.put() and EEPROM.get() would be the functions you need to use instead.

For style, try using more descriptive and different names.
buttonPin vs. ButtonPin and buttonState vs. ButtonState are not the best of choices.
Also unifying multiple events into one and sending them as PRIVATE would be better too.

ok, I’ll rename the button.

but, I don’t understand on

can you explain again?

Instead of something like this

you could write

    char msg[64];
    if (buttonState == HIGH) {
      t = writeTemp();
      EEPROM.put(address, t);         //write value to current address counter address
      snprintf(msg, sizeof(msg)
              , "{\"temp\":%0.2f"
              , t
              , address
              , count);
      Particle.publish("ON1", msg, PRIVATE);
      address += sizeof(t);