-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathexample.ino
More file actions
35 lines (28 loc) · 709 Bytes
/
example.ino
File metadata and controls
35 lines (28 loc) · 709 Bytes
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
#include "openweathermap.h"
#include "HttpClient.h"
unsigned int nextTime = 0; // next time to contact the server
Weather* weather;
HttpClient* httpClient;
void setup() {
Serial.begin(9600);
httpClient = new HttpClient();
weather = new Weather("London,UK", httpClient,
"INSERT your api key here!");
weather->setFahrenheit();
}
void loop() {
if (nextTime > millis()) {
// keep the same color while waiting
return;
}
// print weather
weather_response_t resp = weather->cachedUpdate();
if (resp.isSuccess) {
Serial.print(resp.temp_low);
Serial.print("-");
Serial.print(resp.temp_high);
Serial.println(resp.descr);
}
// check again in 5 seconds:
nextTime = millis() + 5000;
}