Skip to content

Push data to Domotics instead of thingspeak #33

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 11 commits into from
Sep 8, 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
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
install:
- pip install -U platformio
- platformio lib install 561 562
- platformio lib update

script:
- platformio ci --lib="." --board=nodemcuv2
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ New version of the ESP8266 Weather Station

## Arduino IDE

Make sure you use a version of the Arduino IDE which is supported by the ESP8266 platform. You can find it here: https://www.arduino.cc/en/Main/OldSoftwareReleases#previous
Make sure you use a version of the Arduino IDE which is supported by the ESP8266 platform. You can find it here: https://www.arduino.cc/en/Main/OldSoftwareReleases

## Setup
## Setup Arduino IDE

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

Expand All @@ -25,6 +25,18 @@ Make sure you use a version of the Arduino IDE which is supported by the ESP8266
* Adjust the location according to Wunderground API, e.g. Zurich, CH
* Adjust UTC offset

## Setup for PlatformIO

If you are using the PlatformIO environment for building
* choose one of the available IDE integration or the Atom based IDE
* install libraries 561, 562 and 563 with "platformio lib install"
* adapt the WeatherStationDemo.ino file to your needs (see details above)


## Upgrade

The ESP8266 Oled Library changed a lot with the latest release of version 3.0.0. We fixed many bugs and improved performance and changed the API a little bit. This means that you might have to adapt your Weather Station Code if you created it using the older 2.x.x version of the library. Either compare your code to the updated WeatherStationDemo or read through the Upgrade Guide here: [Upgrade Guide](https://github.com/squix78/esp8266-oled-ssd1306/blob/master/UPGRADE-3.0.md)

## Available Modules
* **TimeClient**: simple class which uses the header date and time to set the clock
* **NTPClient**: a NTP based time class written by Fabrice Weinberg
Expand Down
151 changes: 150 additions & 1 deletion WundergroundClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ See more at http://blog.squix.ch
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include "WundergroundClient.h"
bool usePM = false; // Set to true if you want to use AM/PM time disaply
bool isPM = false; // JJG added ///////////

WundergroundClient::WundergroundClient(boolean _isMetric) {
isMetric = _isMetric;
Expand All @@ -41,6 +43,13 @@ void WundergroundClient::updateForecast(String apiKey, String language, String c
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/" + country + "/" + city + ".json");
}

// JJG added ////////////////////////////////
void WundergroundClient::updateAstronomy(String apiKey, String language, String country, String city) {
isForecast = true;
doUpdate("/api/" + apiKey + "/astronomy/lang:" + language + "/q/" + country + "/" + city + ".json");
}
// end JJG add ////////////////////////////////////////////////////////////////////

void WundergroundClient::doUpdate(String url) {
JsonStreamingParser parser;
parser.setListener(this);
Expand Down Expand Up @@ -109,7 +118,97 @@ void WundergroundClient::value(String value) {
localEpoc = value.toInt();
localMillisAtUpdate = millis();
}
if (currentKey == "observation_time_rfc822") {

// JJG added ... //////////////////////// search for keys /////////////////////////
if (currentKey == "percentIlluminated") {
moonPctIlum = value;
}

if (currentKey == "ageOfMoon") {
moonAge = value;
}

if (currentKey == "phaseofMoon") {
moonPhase = value;
}


if (currentParent == "sunrise") { // Has a Parent key and 2 sub-keys
if (currentKey == "hour") {
int tempHour = value.toInt(); // do this to concert to 12 hour time (make it a function!)
if (usePM && tempHour > 12){
tempHour -= 12;
isPM = true;
}
else isPM = false;
sunriseTime = String(tempHour);
//sunriseTime = value;
}
if (currentKey == "minute") {
sunriseTime += ":" + value;
if (isPM) sunriseTime += "pm";
else if (usePM) sunriseTime += "am";
}
}


if (currentParent == "sunset") { // Has a Parent key and 2 sub-keys
if (currentKey == "hour") {
int tempHour = value.toInt(); // do this to concert to 12 hour time (make it a function!)
if (usePM && tempHour > 12){
tempHour -= 12;
isPM = true;
}
else isPM = false;
sunsetTime = String(tempHour);
// sunsetTime = value;
}
if (currentKey == "minute") {
sunsetTime += ":" + value;
if (isPM) sunsetTime += "pm";
else if(usePM) sunsetTime += "am";
}
}

if (currentParent == "moonrise") { // Has a Parent key and 2 sub-keys
if (currentKey == "hour") {
int tempHour = value.toInt(); // do this to concert to 12 hour time (make it a function!)
if (usePM && tempHour > 12){
tempHour -= 12;
isPM = true;
}
else isPM = false;
moonriseTime = String(tempHour);
// moonriseTime = value;
}
if (currentKey == "minute") {
moonriseTime += ":" + value;
if (isPM) moonriseTime += "pm";
else if (usePM) moonriseTime += "am";

}
}

if (currentParent == "moonset") { // Not used - has a Parent key and 2 sub-keys
if (currentKey == "hour") {
moonsetTime = value;
}
if (currentKey == "minute") {
moonsetTime += ":" + value;
}
}

if (currentKey == "wind_mph") {
windSpeed = value;
}

if (currentKey == "wind_dir") {
windDir = value;
}

// end JJG add ////////////////////////////////////////////////////////////////////

if (currentKey == "observation_time_rfc822") {
date = value.substring(0, 16);
}
if (currentKey == "temp_f" && !isMetric) {
Expand Down Expand Up @@ -139,6 +238,12 @@ void WundergroundClient::value(String value) {
if (currentKey == "pressure_in" && !isMetric) {
pressure = value + "in";
}
if (currentKey == "dewpoint_f" && !isMetric) {
dewPoint = value;
}
if (currentKey == "dewpoint_c" && isMetric) {
dewPoint = value;
}
if (currentKey == "precip_today_metric" && isMetric) {
precipitationToday = value + "mm";
}
Expand Down Expand Up @@ -239,6 +344,46 @@ long WundergroundClient::getCurrentEpoch() {
return localEpoc + ((millis() - localMillisAtUpdate) / 1000);
}

// JJG added ... /////////////////////////////////////////////////////////////////////////////////////////
String WundergroundClient::getMoonPctIlum() {
return moonPctIlum;
}

String WundergroundClient::getMoonAge() {
return moonAge;
}

String WundergroundClient::getMoonPhase() {
return moonPhase;
}

String WundergroundClient::getSunriseTime() {
return sunriseTime;
}

String WundergroundClient::getSunsetTime() {
return sunsetTime;
}

String WundergroundClient::getMoonriseTime() {
return moonriseTime;
}

String WundergroundClient::getMoonsetTime() {
return moonsetTime;
}

String WundergroundClient::getWindSpeed() {
return windSpeed;
}

String WundergroundClient::getWindDir() {
return windDir;
}

// end JJG add ////////////////////////////////////////////////////////////////////////////////////////////


String WundergroundClient::getCurrentTemp() {
return currentTemp;
}
Expand All @@ -255,6 +400,10 @@ String WundergroundClient::getPressure() {
return pressure;
}

String WundergroundClient::getDewPoint() {
return dewPoint;
}

String WundergroundClient::getPrecipitationToday() {
return precipitationToday;
}
Expand Down
26 changes: 26 additions & 0 deletions WundergroundClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@ class WundergroundClient: public JsonListener {
String date = "-";
boolean isMetric = true;
String currentTemp;
// JJG added ... ////////////////////////////////// define returns /////////////////////////////////
String moonPctIlum; // not used
String moonAge; // make this a long?
String moonPhase;
String sunriseTime;
String sunsetTime;
String moonriseTime;
String moonsetTime;
String windSpeed;
String windDir;
// end JJG add ////////////////////////////////////////////////////////////////////////////////////
String weatherIcon;
String weatherText;
String humidity;
String pressure;
String dewPoint;
String precipitationToday;
void doUpdate(String url);

Expand All @@ -60,10 +72,22 @@ class WundergroundClient: public JsonListener {
WundergroundClient(boolean isMetric);
void updateConditions(String apiKey, String language, String country, String city);
void updateForecast(String apiKey, String language, String country, String city);
void updateAstronomy(String apiKey, String language, String country, String city); // JJG added
String getHours();
String getMinutes();
String getSeconds();
String getDate();
// JJG added ... ///////////////////function name to string ////////////////////////////
String getMoonPctIlum();
String getMoonAge();
String getMoonPhase();
String getSunriseTime();
String getSunsetTime();
String getMoonriseTime();
String getMoonsetTime();
String getWindSpeed();
String getWindDir();
// end JJG add ///////////////////////////////////////////////////////////////////////
long getCurrentEpoch();

String getCurrentTemp();
Expand All @@ -78,6 +102,8 @@ class WundergroundClient: public JsonListener {

String getPressure();

String getDewPoint();

String getPrecipitationToday();

String getForecastIcon(int period);
Expand Down
Binary file added examples/.DS_Store
Binary file not shown.
Loading