Skip to content

Commit

Permalink
Refactoring the Wunderground client
Browse files Browse the repository at this point in the history
  • Loading branch information
squix78 committed Jun 20, 2017
1 parent d6dae68 commit 4b134fb
Show file tree
Hide file tree
Showing 17 changed files with 496 additions and 41 deletions.
Binary file removed .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -9,3 +9,7 @@ examples/.DS_Store
.project
RemoteSystemsTempFiles

.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
Expand Up @@ -26,29 +26,30 @@ SOFTWARE.

#include <ESP8266WiFi.h>
#include <JsonListener.h>
#include "WundergroundClient.h"
#include "WundergroundConditions.h"

/**
* Wunderground Settings
*/
const String WUNDERGRROUND_API_KEY = "<YOUR-WUNDERGROUND-API-KEY>";
const String WUNDERGRROUND_API_KEY = "808ba87ed77c4501";
const boolean IS_METRIC = true;
const boolean USE_PM = false;
// to retrieve the ZMW-Code use
// http://api.wunderground.com/api/<API-KEY>/conditions/q/<COUNTRY-CODE>/<CITY-NAME>.json
// for example and grab for the zmw ...
const String WUNDERGROUND_ZMW_CODE = "00000.215.10348"; // Braunschweig-Flughafen -> EDVE
const String WUNDERGRROUND_LANGUAGE = "DL";
const String WUNDERGROUND_ZMW_CODE = "00000.215.10348"; // Braunschweig-Flughafen -> EDVE
const String WUNDERGRROUND_LANGUAGE = "DE";

// initiate the WundergoundClient
WundergroundClient wunderground(IS_METRIC);
WundergroundConditions wunderground(IS_METRIC, USE_PM);


/**
* WiFi Settings
*/
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
const char* WIFI_SSID = "<YOUR-WIFI-SSID>";
const char* WIFI_PASSWORD = "<YOUR-WIFI-PASSWORD>";
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

// initiate the WifiClient
WiFiClient wifiClient;
Expand All @@ -70,6 +71,7 @@ void connectWifi() {
}
Serial.println("");
Serial.println("WiFi connected!");
Serial.println(WiFi.localIP());
Serial.println();
}

Expand All @@ -83,6 +85,29 @@ void setup() {

connectWifi();

Serial.println();
Serial.println("\n\nNext Loop-Step: " + String(millis()) + ":");

wunderground.updateConditions(WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_ZMW_CODE);

Serial.println("wundergroundDate: " + wunderground.getDate());

Serial.println("wundergroundWindSpeed: " + wunderground.getWindSpeed());
Serial.println("wundergroundWindDir: " + wunderground.getWindDir());

Serial.println("wundergroundCurrentTemp: " + wunderground.getCurrentTemp());
Serial.println("wundergroundTodayIcon: " + wunderground.getTodayIcon());
Serial.println("wundergroundTodayIconText: " + wunderground.getTodayIconText());
Serial.println("wundergroundMeteoconIcon: " + wunderground.getMeteoconIcon(wunderground.getTodayIconText()));
Serial.println("wundergroundWeatherText: " + wunderground.getWeatherText());
Serial.println("wundergroundHumidity: " + wunderground.getHumidity());
Serial.println("wundergroundPressure: " + wunderground.getPressure());
Serial.println("wundergroundDewPoint: " + wunderground.getDewPoint());
Serial.println("wundergroundPrecipitationToday: " + wunderground.getPrecipitationToday());

Serial.println();
Serial.println("---------------------------------------------------/\n");

}


Expand All @@ -91,38 +116,4 @@ void setup() {
*/
void loop() {

if ((millis() % (60 * 1000)) == 0) { // just call once a minute @see: https://www.wunderground.com/weather/api/d/pricing.html
Serial.println();
Serial.println("\n\nNext Loop-Step: " + String(millis()) + ":");

wunderground.updateConditions(WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_ZMW_CODE);

Serial.println("wundergroundHours: " + wunderground.getHours());
Serial.println("wundergroundMinutes: " + wunderground.getMinutes());
Serial.println("wundergroundSeconds: " + wunderground.getSeconds());
Serial.println("wundergroundDate: " + wunderground.getDate());

Serial.println("wundergroundMoonPctIlum: " + wunderground.getMoonPctIlum());
Serial.println("wundergroundMoonAge: " + wunderground.getMoonAge());
Serial.println("wundergroundMoonPhase: " + wunderground.getMoonPhase());
Serial.println("wundergroundSunriseTime: " + wunderground.getSunriseTime());
Serial.println("wundergroundSunsetTime: " + wunderground.getSunsetTime());
Serial.println("wundergroundMoonriseTime: " + wunderground.getMoonriseTime());
Serial.println("wundergroundMoonsetTime: " + wunderground.getMoonsetTime());
Serial.println("wundergroundWindSpeed: " + wunderground.getWindSpeed());
Serial.println("wundergroundWindDir: " + wunderground.getWindDir());

Serial.println("wundergroundCurrentTemp: " + wunderground.getCurrentTemp());
Serial.println("wundergroundTodayIcon: " + wunderground.getTodayIcon());
Serial.println("wundergroundTodayIconText: " + wunderground.getTodayIconText());
Serial.println("wundergroundMeteoconIcon: " + wunderground.getMeteoconIcon(wunderground.getTodayIconText()));
Serial.println("wundergroundWeatherText: " + wunderground.getWeatherText());
Serial.println("wundergroundHumidity: " + wunderground.getHumidity());
Serial.println("wundergroundPressure: " + wunderground.getPressure());
Serial.println("wundergroundDewPoint: " + wunderground.getDewPoint());
Serial.println("wundergroundPrecipitationToday: " + wunderground.getPrecipitationToday());

Serial.println();
Serial.println("---------------------------------------------------/\n");
}
}
36 changes: 36 additions & 0 deletions lib/readme.txt
@@ -0,0 +1,36 @@

This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.

The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".

For example, see how can be organized `Foo` and `Bar` libraries:

|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c

Then in `src/main.c` you should use:

#include <Foo.h>
#include <Bar.h>

// rest H/C/CPP code

PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.

More information about PlatformIO Library Dependency Finder
- http://docs.platformio.org/page/librarymanager/ldf.html
17 changes: 17 additions & 0 deletions platformio.ini
@@ -0,0 +1,17 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
upload_speed = 921600
board_f_cpu = 160000000L
lib_deps = JsonStreamingParser
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4b134fb

Please sign in to comment.