electronicsguy / ESP8266

ESP8266 Projects
242 stars 183 forks source link

Need Simple arduino code to post data #60

Closed gardendave closed 6 years ago

gardendave commented 6 years ago

I am not a programmer and your example has too much code that is not easily understood by beginners like me.

I have spent a few days trying to get it to work, but all get posted to my sheet is 'undefined' 'undefined'

I would like to request that you post a simple ino file for arduino/esp etc. for just posting some data to a sheet.

by not including reading A1 or the calendar, the bits necessary to use your library will be more obvious to the beginner.

void GetData(){ // put your data gathering here. remember to use global variables // this random is to generate numbers to fill the cells. add your sensor and remove these lines data1 =random(99) ; // generate a random number no higher than 98 data2 = random(200)*.7 ; // generates a floating point value with decimal places data3 = random(1000); // just a 3rd value to give something to post

gardendave commented 6 years ago

one other column, time of the post.

bigFin commented 6 years ago

Hey @gardendave,

We probably should get a more simple example up front.

It looks like you're successfully getting some numbers into variables and assembling them into a URL String. Does that look something like this?

String url = String("script.google.com/macros/s/") + GScriptId + "/exec?data1=" + data1;

Did you define those variables in the google app script? var data1 = e.parameter.data1; and so on...

and then to write the value passed in the url Sheet.getRange('A1').setValue(data1);

And voila, random data in cell A1.

gardendave commented 6 years ago

I sure did not mean to berate anyone. just because he knows what he is doing and I am stumbling like any noob. The three actions, post data, read calendar and read A1, are integrated more than I can figure. If I could see just one action, I could see how it is different than the other two. I later realized that there is the code AND the script....

bigFin commented 6 years ago

@gardendave okie dokie, sounds like you're on the right track now. Have you got it working for your application?

electronicsguy commented 6 years ago

@bigFin thanks for the comments. Dave, I'm going ahead and closing this issue. I may post a simple example, but can't guarantee since I've other projects in the pipeline right now. This is not for absolute beginners. I suggest you read up on C++, Arduino and ESP8266 in general to better understand it.