-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.ino
More file actions
55 lines (55 loc) · 1.48 KB
/
Log.ino
File metadata and controls
55 lines (55 loc) · 1.48 KB
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
void logData()
{
if(LOG_BUTTON_LABEL)
{
if(testWiFi())
{
value0 ++;
if(LABEL_180)
{
value1 = Finangle_180;
}
else if(LABEL_90)
{
value1 = Finangle_90;
}
static bool flag = false;
if (!flag)
{
client = new HTTPSRedirect(httpsPort);
client->setInsecure();
flag = true;
client->setPrintResponseBody(true);
client->setContentTypeHeader("application/json");
}
if (client != nullptr)
{
if (!client->connected())
{
client->connect(host, httpsPort);
}
}
else
{
Serial.println("Error creating client object!");
}
payload = payload_base + "\"" + value0 + "," + value1 +"\"}"; // Create json object string to send to Google Sheets
Serial.println("Publishing data...");
Serial.println(payload); // Publish data to Google Sheets
if(client->POST(url, host, payload))
{
display(5,35,"Data Logged Success");
}
else
{
Serial.println("Error while connecting"); // do stuff here if publish was not successful
}
}
else
{
display(5, 35, "WiFi Not Connected");
Serial.println("Wifi Not Connected");
}
}
LOG_BUTTON_LABEL = LOW;
}