-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclock.h
59 lines (50 loc) · 1.76 KB
/
clock.h
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
#include <TimeLib.h>
boolean check = true;
int daychecker = 0;
int Hou;
int Min;
int Ho;
int Mi;
int seco;
String Day="";
String DayDate="";
void WATCH_display(){
if(check){
HTTPClient http; //Declare object of class HTTPClient
DynamicJsonBuffer jsonBuffer;
//http.begin("http://dataservice.accuweather.com/currentconditions/v1/202439?apikey=GYpocjiLIX4Vb9RLeArUSc9jsDXY5Bku&details=true");
//http.begin("http://dataservice.accuweather.com/locations/v1/cities/search?apikey=GYpocjiLIX4Vb9RLeArUSc9jsDXY5Bku&q=Mumbai");
http.begin("http://api.thingspeak.com/channels/324854/feeds.json?api_key=6QQNWSESYKN1IH9I&results=1");
delay(200);
int httpCode = http.GET(); //Send the request
String payload = http.getString();
//Serial.println(httpCode); //Print HTTP return code 200 correct data 401 invalid data 404 Error
//Serial.println(payload); //Print request response payload
JsonObject& root = jsonBuffer.parseObject(payload);
if(!root.success()){
Serial.println("Nope");
}
else{
JsonArray& feeds = root["feeds"];
JsonObject& feeds1 = feeds[0];
String H = feeds1["field1"];
String M = feeds1["field2"];
// String S = feeds1["field3"];
Ho = H.toInt();
Mi = M.toInt();
//watch(Ho,Mi);
}
check = false;
}
Hou = hour();
Min = minute();
seco = second();
Hou = Hou + Ho;
Min = Min + Mi;
Serial.print(Hou);
Serial.print(" : ");
Serial.print(Min);
Serial.print(" : ");
Serial.println(seco);
delay(1000);
}