Skip to content

Development back to master #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
language: python
python:
- '2.7'
- "2.7"

# Cache PlatformIO packages using Travis CI container-based infrastructure
sudo: false
cache:
directories:
- ~/.platformio
directories:
- "~/.platformio"

env:
- PLATFORMIO_CI_SRC=examples/WeatherStationDemo
- PLATFORMIO_CI_SRC=examples/WorldClockDemo
- PLATFORMIO_CI_SRC=examples/WeatherStationDemo
- PLATFORMIO_CI_SRC=examples/WorldClockDemo


install:
- pip install -U platformio
- platformio lib install 561 562
script:
- mkdir /tmp/build
- ls -altr /tmp
- platformio ci --build-dir="/tmp/build" --keep-build-dir --lib="." --board=nodemcuv2
- ls -altr /tmp
- find /tmp/build -name firmware.elf
- pip install -U platformio
- platformio lib install 561 562

deploy:
skip_cleanup: true
provider: releases
overwrite: true
api_key:
secure: W72OSGx+s+ky9s4nS6L2wOQ8bgvyapLfF5bgWW8qHpLZvNVz5moW5h4TwIrkvIrxitmeIiqqyLPjCKr/XhUHEOoLMq9/IhCjLwI0H4nGAEzAFxNh0s7BEDd7OlkDwwuCamcCXb6gmdJcsOtBSxvmB8/kjq7jPvJi3kfb7iPPVfcS8g+QA0XvPGD4cp5HPhsdbo819RELwfnxtIq6192vDgUo49W2MuD+LClONbvWuxm8ZPXV37kc5RO2l91WHohonKXPXdbQWp6OyoXIiYs3TQD+vzAfIZCk96sGiH6NOnybRTQ2gwIjX03brPVh4VXtAUjufXWO0YEh2F8kMVSrILYiNQ04C5asFpouins3x+GDQbujewPINBU6mN36inwyot0Awnyys6ehuG/Nc4bLTPgzkZR0OX97TKgsfHuZuHingI22+Rwjp4iQwmAkk+ecdr1/IT2GjxpV9PA2b0eYSfQjg3m8cxd5NS7XEfSP3OfxX/eIJtJ579o6McqnifnSq9SE4AeWkiFem2ODCWN71oIfuWdX0jDgpdqwGezohzvXbszukjtAreSJ2DTTYwOCdhD54GLrRubw4279/XhM71BbUyacCrc14odVIGj6NKwjjHOG4XVBbRGq36gIBam1T2YWrtBN13p16L1KRPGDmuLNGp/vwu/rB7c6U+lr5H8=
file: "/tmp/build/.pioenvs/nodemcuv2/firmware.elf"
on:
repo: squix78/esp8266-weather-station
script:
- platformio ci --lib="." --board=nodemcuv2
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Make sure you use a version of the Arduino IDE which is supported by the ESP8266
## Setup

* Install the following libraries with your Arduino Library Manager in Sketch > Include Library > Manage Libraries...

* ESP8266 Weather Station
* Json Streaming Parser (by Daniel Eichhorn)
* ESP8266 Oled Driver for SSD1306 display (by me as well). **Make sure that you use Version 2.0.0 or bigger!**
* ESP8266 Oled Driver for SSD1306 display (by me as well). **Make sure that you use Version 3.0.0 or bigger!**
* Go to http://wunderground.com, create an account and get an API Key
* In the Arduino IDE go to File > Examples > ESP8266 Weather Station
* Enter the Wunderground API Key
Expand Down
48 changes: 27 additions & 21 deletions ThingspeakClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


ThingspeakClient::ThingspeakClient() {

}

void ThingspeakClient::getLastChannelItem(String channelId, String readApiKey) {
JsonStreamingParser parser;
parser.setListener(this);
Expand All @@ -13,26 +13,32 @@ void ThingspeakClient::getLastChannelItem(String channelId, String readApiKey) {
// http://api.thingspeak.com/channels/CHANNEL_ID/feeds.json?results=2&api_key=API_KEY
const char host[] = "api.thingspeak.com";
String url = "/channels/" + channelId +"/feeds.json?results=1&api_key=" + readApiKey;

const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}


Serial.print("Requesting URL: ");
Serial.println(url);

// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");

int retryCounter = 0;
while(!client.available()) {
Serial.println(".");
delay(1000);
delay(1000);
retryCounter++;
if (retryCounter > 10) {
return;
}
}

int pos = 0;
boolean isBody = false;
char c;
Expand All @@ -49,23 +55,23 @@ void ThingspeakClient::getLastChannelItem(String channelId, String readApiKey) {
parser.parse(c);
}
}
}
}
}

void ThingspeakClient::whitespace(char c) {

}

void ThingspeakClient::startDocument() {

}

void ThingspeakClient::key(String key) {
if (key == "channel") {
isHeader = true;
} else if (key == "feeds") {
isHeader = false;
}
}
currentKey = key;
}

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

for (int i = 1; i < 9; i++) {
String fieldKey = "field" + String(i);

if (currentKey == fieldKey) {
if (isHeader) {
fieldLabels[i-1] = value;
} else {
lastFields[i-1] = value;
Serial.println(fieldKey + ": " + value);
}

}
}


}


Expand All @@ -103,21 +109,21 @@ String ThingspeakClient::getCreatedAt() {
}

void ThingspeakClient::endArray() {

}

void ThingspeakClient::endObject() {

}

void ThingspeakClient::endDocument() {

}

void ThingspeakClient::startArray() {

}

void ThingspeakClient::startObject() {

}
5 changes: 5 additions & 0 deletions WorldClockClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ void WorldClockClient::updateTime() {

client.println(request);

int retryCounter = 0;
while(!client.available()) {
Serial.println(".");
delay(1000);
retryCounter++;
if (retryCounter > 10) {
return;
}
}

int pos = 0;
Expand Down
5 changes: 5 additions & 0 deletions WundergroundClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ void WundergroundClient::doUpdate(String url) {
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: api.wunderground.com\r\n" +
"Connection: close\r\n\r\n");
int retryCounter = 0;
while(!client.available()) {
delay(1000);
retryCounter++;
if (retryCounter > 10) {
return;
}
}

int pos = 0;
Expand Down
Loading