Skip to content

Commit 8189586

Browse files
committed
Merge pull request #31 from squix78/development
Development back to master
2 parents 1623164 + fde18b6 commit 8189586

File tree

10 files changed

+1479
-1026
lines changed

10 files changed

+1479
-1026
lines changed

.travis.yml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
language: python
22
python:
3-
- '2.7'
3+
- "2.7"
4+
5+
# Cache PlatformIO packages using Travis CI container-based infrastructure
46
sudo: false
57
cache:
6-
directories:
7-
- ~/.platformio
8+
directories:
9+
- "~/.platformio"
10+
811
env:
9-
- PLATFORMIO_CI_SRC=examples/WeatherStationDemo
10-
- PLATFORMIO_CI_SRC=examples/WorldClockDemo
12+
- PLATFORMIO_CI_SRC=examples/WeatherStationDemo
13+
- PLATFORMIO_CI_SRC=examples/WorldClockDemo
14+
15+
1116
install:
12-
- pip install -U platformio
13-
- platformio lib install 561 562
14-
script:
15-
- mkdir /tmp/build
16-
- ls -altr /tmp
17-
- platformio ci --build-dir="/tmp/build" --keep-build-dir --lib="." --board=nodemcuv2
18-
- ls -altr /tmp
19-
- find /tmp/build -name firmware.elf
17+
- pip install -U platformio
18+
- platformio lib install 561 562
2019

21-
deploy:
22-
skip_cleanup: true
23-
provider: releases
24-
overwrite: true
25-
api_key:
26-
secure: W72OSGx+s+ky9s4nS6L2wOQ8bgvyapLfF5bgWW8qHpLZvNVz5moW5h4TwIrkvIrxitmeIiqqyLPjCKr/XhUHEOoLMq9/IhCjLwI0H4nGAEzAFxNh0s7BEDd7OlkDwwuCamcCXb6gmdJcsOtBSxvmB8/kjq7jPvJi3kfb7iPPVfcS8g+QA0XvPGD4cp5HPhsdbo819RELwfnxtIq6192vDgUo49W2MuD+LClONbvWuxm8ZPXV37kc5RO2l91WHohonKXPXdbQWp6OyoXIiYs3TQD+vzAfIZCk96sGiH6NOnybRTQ2gwIjX03brPVh4VXtAUjufXWO0YEh2F8kMVSrILYiNQ04C5asFpouins3x+GDQbujewPINBU6mN36inwyot0Awnyys6ehuG/Nc4bLTPgzkZR0OX97TKgsfHuZuHingI22+Rwjp4iQwmAkk+ecdr1/IT2GjxpV9PA2b0eYSfQjg3m8cxd5NS7XEfSP3OfxX/eIJtJ579o6McqnifnSq9SE4AeWkiFem2ODCWN71oIfuWdX0jDgpdqwGezohzvXbszukjtAreSJ2DTTYwOCdhD54GLrRubw4279/XhM71BbUyacCrc14odVIGj6NKwjjHOG4XVBbRGq36gIBam1T2YWrtBN13p16L1KRPGDmuLNGp/vwu/rB7c6U+lr5H8=
27-
file: "/tmp/build/.pioenvs/nodemcuv2/firmware.elf"
28-
on:
29-
repo: squix78/esp8266-weather-station
20+
script:
21+
- platformio ci --lib="." --board=nodemcuv2

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ Make sure you use a version of the Arduino IDE which is supported by the ESP8266
1414
## Setup
1515

1616
* Install the following libraries with your Arduino Library Manager in Sketch > Include Library > Manage Libraries...
17+
1718
* ESP8266 Weather Station
1819
* Json Streaming Parser (by Daniel Eichhorn)
19-
* ESP8266 Oled Driver for SSD1306 display (by me as well). **Make sure that you use Version 2.0.0 or bigger!**
20+
* ESP8266 Oled Driver for SSD1306 display (by me as well). **Make sure that you use Version 3.0.0 or bigger!**
2021
* Go to http://wunderground.com, create an account and get an API Key
2122
* In the Arduino IDE go to File > Examples > ESP8266 Weather Station
2223
* Enter the Wunderground API Key

ThingspeakClient.cpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33

44
ThingspeakClient::ThingspeakClient() {
5-
5+
66
}
7-
7+
88
void ThingspeakClient::getLastChannelItem(String channelId, String readApiKey) {
99
JsonStreamingParser parser;
1010
parser.setListener(this);
@@ -13,26 +13,32 @@ void ThingspeakClient::getLastChannelItem(String channelId, String readApiKey) {
1313
// http://api.thingspeak.com/channels/CHANNEL_ID/feeds.json?results=2&api_key=API_KEY
1414
const char host[] = "api.thingspeak.com";
1515
String url = "/channels/" + channelId +"/feeds.json?results=1&api_key=" + readApiKey;
16-
16+
1717
const int httpPort = 80;
1818
if (!client.connect(host, httpPort)) {
1919
Serial.println("connection failed");
2020
return;
2121
}
2222

23-
23+
2424
Serial.print("Requesting URL: ");
2525
Serial.println(url);
26-
26+
2727
// This will send the request to the server
2828
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
29-
"Host: " + host + "\r\n" +
29+
"Host: " + host + "\r\n" +
3030
"Connection: close\r\n\r\n");
31+
32+
int retryCounter = 0;
3133
while(!client.available()) {
3234
Serial.println(".");
33-
delay(1000);
35+
delay(1000);
36+
retryCounter++;
37+
if (retryCounter > 10) {
38+
return;
39+
}
3440
}
35-
41+
3642
int pos = 0;
3743
boolean isBody = false;
3844
char c;
@@ -49,23 +55,23 @@ void ThingspeakClient::getLastChannelItem(String channelId, String readApiKey) {
4955
parser.parse(c);
5056
}
5157
}
52-
}
58+
}
5359
}
5460

5561
void ThingspeakClient::whitespace(char c) {
56-
62+
5763
}
5864

5965
void ThingspeakClient::startDocument() {
60-
66+
6167
}
6268

6369
void ThingspeakClient::key(String key) {
6470
if (key == "channel") {
6571
isHeader = true;
6672
} else if (key == "feeds") {
6773
isHeader = false;
68-
}
74+
}
6975
currentKey = key;
7076
}
7177

@@ -74,19 +80,19 @@ void ThingspeakClient::value(String value) {
7480

7581
for (int i = 1; i < 9; i++) {
7682
String fieldKey = "field" + String(i);
77-
83+
7884
if (currentKey == fieldKey) {
7985
if (isHeader) {
8086
fieldLabels[i-1] = value;
8187
} else {
8288
lastFields[i-1] = value;
8389
Serial.println(fieldKey + ": " + value);
8490
}
85-
91+
8692
}
8793
}
88-
89-
94+
95+
9096
}
9197

9298

@@ -103,21 +109,21 @@ String ThingspeakClient::getCreatedAt() {
103109
}
104110

105111
void ThingspeakClient::endArray() {
106-
112+
107113
}
108114

109115
void ThingspeakClient::endObject() {
110-
116+
111117
}
112118

113119
void ThingspeakClient::endDocument() {
114-
120+
115121
}
116122

117123
void ThingspeakClient::startArray() {
118-
124+
119125
}
120126

121127
void ThingspeakClient::startObject() {
122-
128+
123129
}

WorldClockClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ void WorldClockClient::updateTime() {
7878

7979
client.println(request);
8080

81+
int retryCounter = 0;
8182
while(!client.available()) {
8283
Serial.println(".");
8384
delay(1000);
85+
retryCounter++;
86+
if (retryCounter > 10) {
87+
return;
88+
}
8489
}
8590

8691
int pos = 0;

WundergroundClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ void WundergroundClient::doUpdate(String url) {
5858
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
5959
"Host: api.wunderground.com\r\n" +
6060
"Connection: close\r\n\r\n");
61+
int retryCounter = 0;
6162
while(!client.available()) {
6263
delay(1000);
64+
retryCounter++;
65+
if (retryCounter > 10) {
66+
return;
67+
}
6368
}
6469

6570
int pos = 0;

0 commit comments

Comments
 (0)