-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathWiFi Test Log Java Script .txt
119 lines (85 loc) · 2.91 KB
/
WiFi Test Log Java Script .txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
This needs to be applied using the script editor tool within google spreadsheets in order to function.
Specifics on how to set this up can be found here. https://www.hackster.io/detox/transmit-esp8266-data-to-google-sheets-8fc617
Code:
//-----------------------------------------------
//Originally published by Mogsdad@Stackoverflow
//Modified for The OPEnS Lab
//Modified by Thomas DeBell
//-----------------------------------------------
/*
GET request query:
https://script.google.com/macros/s/<gscript id>/exec?celData=data_here
----------------------------------------------------------------------
GScript, PushingBox and Arduino/ESP8266 Variables in order:
Variables for Evaporameter in order (Ethernet Shield) *Important Note* Variable name must match exactly to Ethenet sketch
IDtag
TimeStamp
TempC
Humid
LoadCell
IRLight
FullLight
BatVolt
----------------------------------------------------
*/
/* Using spreadsheet API */
function doGet(e) {
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == undefined) {
result = 'No Parameters';
}
else {
var id = '1GBV7n5VxR_GrZbz92TAMLo0iQUdiJlx7OLBuS5_CrPE';//specific to the spreadsheet you are working on. this is id is found //directly after "docs.google.com/spreadsheetURL/d" in the URL.
var sheet = SpreadsheetApp.openById(id).getActiveSheet();
var newRow = sheet.getLastRow() + 1;
var rowData = [];
//var waktu = new Date();
rowData[0] = new Date(); // Timestamp in column A
for (var param in e.parameter) {
Logger.log('In for loop, param='+param);
var value = stripQuotes(e.parameter[param]);
//Logger.log(param + ':' + e.parameter[param]);
switch (param) {
case 'IDtag': //Parameter
rowData[1] = value; //Value in column B
break;
case 'TimeStamp':
rowData[2] = value;
break;
case 'TempC':
rowData[3] = value;
break;
case 'Humid':
rowData[4] = value;
break;
case 'LoadCell':
rowData[5] = value;
break;
case 'IRLight':
rowData[6] = value;
break;
case 'FullLight':
rowData[7] = value;
break;
case 'BatVolt':
rowData[8] = value;
break;
default:
result = "unsupported parameter";
}
}
Logger.log(JSON.stringify(rowData));
// Write new row below
var newRange = sheet.getRange(newRow, 1, 1, rowData.length);
newRange.setValues([rowData]);
}
// Return result of operation
return ContentService.createTextOutput(result);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}