Difference between revisions of "EBC Exercise 37 Logging to Sheets"

From eLinux.org
Jump to: navigation, search
(Initial Page)
 
m (Run the example: Added)
Line 9: Line 9:
 
* Give the sheet a meaningful name
 
* Give the sheet a meaningful name
 
* Enter some column labels
 
* Enter some column labels
[[File:BlankSheet.png|frame|Blank Google Sheet]]
+
[[File:BlankSheet.png|480px|Blank Google Sheet]]
 
* Note the sheetID in the path
 
* Note the sheetID in the path
[[File:SheetID.png|frame|SheetID]]
+
[[File:SheetID.png|SheetID]]
  
 +
== Get Credentials ==
 +
Go to the class repo and change to the sheets directory
 +
bone$ '''cd exercises/iot/google/sheets'''
  
 +
If you are using JavaScipt, go to
 +
[https://developers.google.com/sheets/api/quickstart/nodejs https://developers.google.com/sheets/api/quickstart/nodejs] and follow step 1.
  
 +
If you are using Python, got to
 +
[https://developers.google.com/sheets/api/quickstart/python https://developers.google.com/sheets/api/quickstart/python] and follow step 1.
 +
 +
Either way put the '''credentials.json''' file in the sheets directory.
 +
 +
== Run the example ==
 +
Edit either '''demo.js''' or '''demo.py''' and change the sheetsID string to the string you noted above.
 +
 +
The, run the example on your Bone.  The arguments are the values to be logged on the sheet.
 +
 +
bone$ '''./demo.js 3.14 10'''
 +
or
 +
bone$ '''./demo.py 3.14 10'''
 +
 +
Go to your Google sheet and the new data, and a time stamp should be there.
 
{{YoderFoot}}
 
{{YoderFoot}}

Revision as of 10:57, 10 October 2018

thumb‎ Embedded Linux Class by Mark A. Yoder


Here are instructions on how to log data to a Google Sheet from JavaScript.

Create a new Sheet

Create a new sheet by:

  • Going to https://sheets.google.com and clicking to Start a new spreadsheet, Blank
  • Give the sheet a meaningful name
  • Enter some column labels

Blank Google Sheet

  • Note the sheetID in the path

SheetID

Get Credentials

Go to the class repo and change to the sheets directory

bone$ cd exercises/iot/google/sheets

If you are using JavaScipt, go to https://developers.google.com/sheets/api/quickstart/nodejs and follow step 1.

If you are using Python, got to https://developers.google.com/sheets/api/quickstart/python and follow step 1.

Either way put the credentials.json file in the sheets directory.

Run the example

Edit either demo.js or demo.py and change the sheetsID string to the string you noted above.

The, run the example on your Bone. The arguments are the values to be logged on the sheet.

bone$ ./demo.js 3.14 10

or

bone$ ./demo.py 3.14 10

Go to your Google sheet and the new data, and a time stamp should be there.



thumb‎ Embedded Linux Class by Mark A. Yoder