Pushing data from the photon into google sheets


#1

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


#2

@Shane_Mats
Would this guide by @gusgonnet be helpful?


#3

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


#4

What seems to be the problem?


#5

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


#6

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");

#7

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:


#8

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.


#9

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


#10

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


#11

Victory! glad to hear


#12

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.


#13

And also this says, the applet was never run.


#15

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


#16

Does Google really do that to you? :cold_sweat:


#17

I feel discriminated :see_no_evil:


#18

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.


#19

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.


#20

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)


#21

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?