Pushing data from the photon into google sheets

i have been trying for weeks using different tutorials online but i cant really fully understand the whole tutorial since i am new to programming and not really good at it either. if someone has an easy to follow tutorial to push data into google sheets that would be great. also the data i’m trying to push is intigers. thank you if you can help.

-Shane

1 Like

@Shane_Mats
Would this guide by @gusgonnet be helpful?

1 Like

i have tried that and it seems to not work that well since

What seems to be the problem?

setting up the google docs part does not make sense to me, although i followed it correctly it cant connect to my photon

I think you could also use IFTTT, because it is much easier.

Your webhook would just have to look like:

{
    "eventName": "to_google_sheets",
    "url": "https://maker.ifttt.com/trigger/to_google_sheets/with/key/PUT_YOUR_IFTTT_KEY_HERE",
    "requestType": "POST",
    "json": {
        "value1": "{{SPARK_EVENT_VALUE}}"
    },
    "mydevices": true
}

Replace PUT_YOUR_IFTTT_KEY_HERE with your key from the IFTTT Maker Channel.

To log data, you would just make your Photon do:

Particle.publish("to_google_sheets", "Data_you_want_to_Publish");
1 Like

You can also write to a Google spreadsheet by using the Particle channel in IFTTT; you don’t need a webhook at all. I did it in this project:

3 Likes

I have found the Particle Channel on IFTTT to be slower than using a Webhook. This is probably because it is using the pull method rather than the push method. Also with Webhooks, you get more control than the Particle Channel.

Hey Shane, google won't connect to your photon since it's your photon who's connecting to google via a webhook.
What do you mean with this below?

Maybe you can describe better what is not working and we can figure out what is wrong...
I promise the way it's described works fine, and the procedure was tested by other people too :smile:
Gustavo

2 Likes

Thank you for replying. I was just not reading carefully through setting up the google docs but I have it all done now. It was I forgot to add the sprintf function in my script. Thanks again.
-Shane

2 Likes

Victory! glad to hear

1 Like

On the particle console I’m getting the following message:
“Congratulations! You’ve fired the to_google_sheets event”",“ttl”:60,“published_at”:“2018-01-12T21:37:24.080Z”,“coreid”:“particle-internal”,“name”:“hook-response/to_google_sheets/0”}

But nothing shows on the google sheet.

My web hook looks like following:

The code is simple:
The webBased LED app from particle:

int led2 = D7;

void setup()
{

   pinMode(led2, OUTPUT);
   Particle.subscribe("hook-response/to_google_sheets", myHandler, MY_DEVICES);

   Particle.function("led",ledToggle);

   digitalWrite(led2, LOW);

}

void myHandler(const char *event, const char *data) {
  // Handle the integration response
}

void loop()
{
   // Nothing to do here
}

int ledToggle(String command) {

    if (command=="on") {
        digitalWrite(led2,HIGH);
        String data = "It's on";
        Particle.publish("to_google_sheets", data, PRIVATE);
        return 1;
    }
    else if (command=="off") {
        digitalWrite(led2,LOW);
        String data = "It's off";
        Particle.publish("to_google_sheets", data, PRIVATE);
        return 0;
    }
    else {
        return -1;
    }
}

I’m really new to IOT. Would really appreciate some help.

And also this says, the applet was never run.

I would have liked to help, but Google prevents me from using a free test account since I’m located in Europe.

Does Google really do that to you? :cold_sweat:

1 Like

I feel discriminated :see_no_evil:

1 Like

Hi,
if you follow TO THE LETTER this tutorial:

I believe you'll be able to do what you want.
But remember when I said to the letter? The reason is that you may feel tempted to change a field name or something else, and it will not work at the end (and it will be hard to troubleshoot - so redoing the steps will most likely be the cure).

Good luck!
Gustavo.

What do you mean by this? I have never had to sign up for any test account, I use my plain google account...
Just curious
Gustavo.

And when I follow the provided links I end up at some FAQs that state this (translated from German as this is not displayed when viewing the page in English)

oh I think I get it now, your comment may apply to google docs via IFTTT, not to my tutorial on Hackster.

Am I right?