Uploading Electron Data to Google Drive

Oh my I just made the classic mistake of not checking first. My apologies! I typed in “Electron Google drive” and nothing seemed to show that was recent so I sort of just went for the lazy ask for guidance solution. I’ll look into searching around more and will come back with followup questions maybe. Thank you for your time and your answer!

3 Likes

hey, some time ago I did a project with a photon that was storing data in a google docs, so maybe it can help you at this time?
I described all I did here:

and the project I used it is here:

Gustavo.

4 Likes

Hi Gustavo!

Thank you for the links! They seem exactly like the thing I’m trying to achieve. My concern is(and I understand that you might not have the answer) how I can get the electron to communicate with the google sheets script. I don’t want to be constantly collecting data but more during certain periods of time. Would I be able to start the script using the electron? For example in your pool data example: lets say that I want to only collect data when the sun is out and I have a photosensor to do that. I don’t want to be sitting around pressing collect on the script each time I see the sun but rather I want to automate the system. (I will look into it too, but I was just wondering if you had any thoughts on that matter)

Once again thank you for the links! They really did help!

–Darthreya

2 Likes

Hum, I see.
In you case, I guess the electron (or a photon, or a core) will have to initiate the conversation to the google sheet, in the form of publishing an event. Once this event is published, I imagine a particle cloud webhook matching that event getting triggered. This webhook will have to be the one calling the google script it some way (that I really hope google provides).
Since my hardware is on all the time, I have not had the need for such a mechanism, but if I figure something out (or hopefully you do) then I’ll post back here.
Just did a search on hitting a google api, and this is one of the results:

Looks promising!
Gustavo.

@darthreya: alternatively, you can use a service like ubidots (or others) instead of google docs and have exactly what you want:
http://ubidots.com
Gustavo.

1 Like

hey,
I found the way to save data pushed from your particle into a google sheet.

I followed these instructions for the google sheet configuration:
http://railsrescue.com/blog/2015-05-28-step-by-step-setup-to-send-form-data-to-google-sheets/

Then created a particle webhook with:
event name: googleDocs
full url: what you get from google docs (example: https://script.google.com/macros/s/1236278936489127634-2876348/exec)
POST
form: key=name value={{my-name}}
headers: “Content-Type”: “application/x-www-form-urlencoded; charset=UTF-8”
include defaults: no

then in your firmware:
Particle.publish(“googleDocs”, “{“my-name”:“aloha”}”, 60);

I learned few tricks on the webhook custom features here:

Screenshot of my particles reporting events to my google sheet:

It worked for me. Hope it helps,
Gustavo.
PS: I have a few “undefined” fields but hey, that will be fixed next time

1 Like

I have done Google Doc to store data and then I tried Ubidots and it was so much easier and better at displaying your data that never looked back at the Google Docs or spreadsheet for data storage.

Ubidots is free so might as well give it a try, I’m sure you will be happy with it.

I have now documented all this in this hackster article:


Gustavo.

1 Like

Thanks for all the help! I was travelling so I didn’t get much time to work on the device more. I ended up working out the scheduling functions instead in the meantime. Ubidots seems like a great resource and I will most definitely check it out. Also thanks again @gusgonnet for the super helpful guide! I’ll see if I can make headway on my project and let you all know how it goes and maybe make a post about it.

1 Like

Hi Gustavo,

I am trying to do same and followed every single steps carefully as you mentioned. I using electron to perform this.

However, hook sent is always undefined.

I tried FORMS and JSON formats but none works.

In the Form I feel
key = name
value = {{my-name}}

in JSON, I write
{
“key”: “name”,
“value”: “{{my-name}}”
}

but none of this option works.

I created google form to push the data to spread sheet. It works fine. So it appears that something I am messing it up either at the webhook or in the firmware.

In the firmware, I wrote following:
Particle.publish(“googleDocs”, “{“my-name”:“aloha”}”, 60);

So when I monitor logs, it says
googledocs {“my-name”:“aloha”}
data "{“my-name”:“aloha”}"
hook-sent/googleDocs undefined

Not sure where I am making mistake

1 Like

I tried to see the response on requestBin

I see following there
{“event”:“googleDocs”,“data”:"{“my-name”:“aloha”}",“published_at”:“2017-03-30T18:07:03.170Z”,“coreid”:“XXXXXXXXXXXXXX”,“value”:“aloha”,“key”:“name”}

So it looks like the data is parsed and displayed here but something might be going wrong for googledocs

Hi,
this is how a webhook looks like in my console:

if nothing is reaching the spreadsheet, I recommend you publish it again as described in section “Setup the Google Docs Side”, specially this step from the linked site:
// 3. Publish > Deploy as web app
// - enter Project Version name and click ‘Save New Version’
// - set security level and enable service (most likely execute as ‘me’ and access 'anyone, even anonymously)

hope it helps
Gustavo.

1 Like

Hi Gustavo,

Many thanks. It worked. I was making mistake in Webhook.

I was using two rows:
“key” = “name”
“value” = “{{my-name}}”

when I changed it to one row
"name" = “{{my-name}}”

it worked. I now understand how the form data works.

Thanks again.

1 Like

I’m happy to hear that you got it working!
enjoy,
Gustavo.

Hey there,
I know, it might be a little late to reply. But in case if anyone looking for a working example “how to use goggle spreadsheet using electron” can use https://github.com/subhendukundu/Electron-GoogleSheet
Hope this will help.
Thanks

@gusgonnet if you happen to still keep an eye on this thread, I first want to thank you for putting together such an incredible document! It’s exactly what I’ve been looking for and made it very straightforward to start the Google Sheets logging process.

I’m wondering if you can help me debug something: I have a field-deployed sensor with an Electron with firmware that I’d like not to change, if at all possible, which is sending data to the cloud with name "CpHOx" and a string of ASCII data in "data" like this:
{
“name”: “CpHOx”,
“data”:“2018/04/19,00:00:25,18.650,0.08194,-0.82938,4.68200,8.10295,323.98099,14.55660,33.59880,4.04,82.70”,
“ttl”: 60,
“published_at”: “2018-04-19T00:12:42.319Z”,
“coreid”: “xxxx”
}

I have my form fields set as follows but am not seeing any actual data come into the Google Sheet (I do see new, accurate timestamps in the Google sheet every time Particle.publish() is called but name, email, phone, and message are just filled with “undefined” in each new row. I also tried to use {{my-name}} next to value but that didn’t work either.

Any chance you might be able to offer a suggestion to help me get data from that publish call to the Google Sheet? Thanks!

Switched my form to just:


And now I’m getting something back from the Electron, but there’s a hiccup on the sensor side so I can’t yet verify if it’s all working.

If you do take a look at this thread again, @gusgonnet, I’d be really curious why it appears that you have two entries in FORM FIELDS (viz “key”: “name”, “value”: “{{my-name}}”) but that “key”:“name” pair doesn’t appear to be necessary (also seen in the following quote).

Anyway, thanks again for the great tutorial!

Hi Phil,

I’m happy that you found the write-up useful!

Now, I cannot figure out why I wrote in Hackster form: key=name value={{my-name}} when I have today in my webhook:

{
“name”: “{{my-name}}”
}

EDIT: Oh I remember now. I believe the particle web console representation of the form changed. I did not mean to add two lines, it’s ONE line where the key is name and the value is {{my-name}} which in JSON looks like:
“name”: “{{my-name}}”

I hope you are able to get away with your data untouched in your CpHOx event:

“data”:“2018/04/19,00:00:25,18.650,0.08194,-0.82938,4.68200,8.10295,323.98099,14.55660,33.59880,4.04,82.70”,

Not sure if the google sheets webapp will accept the commas in that string, but hey! nothing is lost if you try.
Good luck and report back please,
Gustavo.
EDIT 2: Here’s a screenshot of my webhook today:


EDIT 3: I have updated the Hackster write-up now with more details about this

1 Like

It’s working! It seems a little temperamental, though I think that’s on my firmware side, not webhook/console side. My above post, or, equivalently this as my form


ended up doing the trick. With that piece figured out, calling the webhook by the name I’d already chosen, and otherwise following your Hackster piece, it seems to be performing nicely. This could greatly aid our workflow so thank you again for taking the time to write it all up (not to mention chime back into a year+ old post)!

oh wow, that is great to hear!
Thanks for letting me know,
Gustavo.
PS: is this for the smartfin project?

1 Like