Skip to content

Commit ed44731

Browse files
authored
Merge pull request #33 from squix78/master
Push data to Domotics instead of thingspeak
2 parents fde18b6 + 3e12096 commit ed44731

12 files changed

+903
-5
lines changed

.DS_Store

6 KB
Binary file not shown.

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
install:
1717
- pip install -U platformio
1818
- platformio lib install 561 562
19+
- platformio lib update
1920

2021
script:
2122
- platformio ci --lib="." --board=nodemcuv2

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ New version of the ESP8266 Weather Station
99

1010
## Arduino IDE
1111

12-
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
12+
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
1313

14-
## Setup
14+
## Setup Arduino IDE
1515

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

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

28+
## Setup for PlatformIO
29+
30+
If you are using the PlatformIO environment for building
31+
* choose one of the available IDE integration or the Atom based IDE
32+
* install libraries 561, 562 and 563 with "platformio lib install"
33+
* adapt the WeatherStationDemo.ino file to your needs (see details above)
34+
35+
36+
## Upgrade
37+
38+
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)
39+
2840
## Available Modules
2941
* **TimeClient**: simple class which uses the header date and time to set the clock
3042
* **NTPClient**: a NTP based time class written by Fabrice Weinberg

WundergroundClient.cpp

+150-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ See more at http://blog.squix.ch
2626
#include <ESP8266WiFi.h>
2727
#include <WiFiClient.h>
2828
#include "WundergroundClient.h"
29+
bool usePM = false; // Set to true if you want to use AM/PM time disaply
30+
bool isPM = false; // JJG added ///////////
2931

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

46+
// JJG added ////////////////////////////////
47+
void WundergroundClient::updateAstronomy(String apiKey, String language, String country, String city) {
48+
isForecast = true;
49+
doUpdate("/api/" + apiKey + "/astronomy/lang:" + language + "/q/" + country + "/" + city + ".json");
50+
}
51+
// end JJG add ////////////////////////////////////////////////////////////////////
52+
4453
void WundergroundClient::doUpdate(String url) {
4554
JsonStreamingParser parser;
4655
parser.setListener(this);
@@ -109,7 +118,97 @@ void WundergroundClient::value(String value) {
109118
localEpoc = value.toInt();
110119
localMillisAtUpdate = millis();
111120
}
112-
if (currentKey == "observation_time_rfc822") {
121+
122+
// JJG added ... //////////////////////// search for keys /////////////////////////
123+
if (currentKey == "percentIlluminated") {
124+
moonPctIlum = value;
125+
}
126+
127+
if (currentKey == "ageOfMoon") {
128+
moonAge = value;
129+
}
130+
131+
if (currentKey == "phaseofMoon") {
132+
moonPhase = value;
133+
}
134+
135+
136+
if (currentParent == "sunrise") { // Has a Parent key and 2 sub-keys
137+
if (currentKey == "hour") {
138+
int tempHour = value.toInt(); // do this to concert to 12 hour time (make it a function!)
139+
if (usePM && tempHour > 12){
140+
tempHour -= 12;
141+
isPM = true;
142+
}
143+
else isPM = false;
144+
sunriseTime = String(tempHour);
145+
//sunriseTime = value;
146+
}
147+
if (currentKey == "minute") {
148+
sunriseTime += ":" + value;
149+
if (isPM) sunriseTime += "pm";
150+
else if (usePM) sunriseTime += "am";
151+
}
152+
}
153+
154+
155+
if (currentParent == "sunset") { // Has a Parent key and 2 sub-keys
156+
if (currentKey == "hour") {
157+
int tempHour = value.toInt(); // do this to concert to 12 hour time (make it a function!)
158+
if (usePM && tempHour > 12){
159+
tempHour -= 12;
160+
isPM = true;
161+
}
162+
else isPM = false;
163+
sunsetTime = String(tempHour);
164+
// sunsetTime = value;
165+
}
166+
if (currentKey == "minute") {
167+
sunsetTime += ":" + value;
168+
if (isPM) sunsetTime += "pm";
169+
else if(usePM) sunsetTime += "am";
170+
}
171+
}
172+
173+
if (currentParent == "moonrise") { // Has a Parent key and 2 sub-keys
174+
if (currentKey == "hour") {
175+
int tempHour = value.toInt(); // do this to concert to 12 hour time (make it a function!)
176+
if (usePM && tempHour > 12){
177+
tempHour -= 12;
178+
isPM = true;
179+
}
180+
else isPM = false;
181+
moonriseTime = String(tempHour);
182+
// moonriseTime = value;
183+
}
184+
if (currentKey == "minute") {
185+
moonriseTime += ":" + value;
186+
if (isPM) moonriseTime += "pm";
187+
else if (usePM) moonriseTime += "am";
188+
189+
}
190+
}
191+
192+
if (currentParent == "moonset") { // Not used - has a Parent key and 2 sub-keys
193+
if (currentKey == "hour") {
194+
moonsetTime = value;
195+
}
196+
if (currentKey == "minute") {
197+
moonsetTime += ":" + value;
198+
}
199+
}
200+
201+
if (currentKey == "wind_mph") {
202+
windSpeed = value;
203+
}
204+
205+
if (currentKey == "wind_dir") {
206+
windDir = value;
207+
}
208+
209+
// end JJG add ////////////////////////////////////////////////////////////////////
210+
211+
if (currentKey == "observation_time_rfc822") {
113212
date = value.substring(0, 16);
114213
}
115214
if (currentKey == "temp_f" && !isMetric) {
@@ -139,6 +238,12 @@ void WundergroundClient::value(String value) {
139238
if (currentKey == "pressure_in" && !isMetric) {
140239
pressure = value + "in";
141240
}
241+
if (currentKey == "dewpoint_f" && !isMetric) {
242+
dewPoint = value;
243+
}
244+
if (currentKey == "dewpoint_c" && isMetric) {
245+
dewPoint = value;
246+
}
142247
if (currentKey == "precip_today_metric" && isMetric) {
143248
precipitationToday = value + "mm";
144249
}
@@ -239,6 +344,46 @@ long WundergroundClient::getCurrentEpoch() {
239344
return localEpoc + ((millis() - localMillisAtUpdate) / 1000);
240345
}
241346

347+
// JJG added ... /////////////////////////////////////////////////////////////////////////////////////////
348+
String WundergroundClient::getMoonPctIlum() {
349+
return moonPctIlum;
350+
}
351+
352+
String WundergroundClient::getMoonAge() {
353+
return moonAge;
354+
}
355+
356+
String WundergroundClient::getMoonPhase() {
357+
return moonPhase;
358+
}
359+
360+
String WundergroundClient::getSunriseTime() {
361+
return sunriseTime;
362+
}
363+
364+
String WundergroundClient::getSunsetTime() {
365+
return sunsetTime;
366+
}
367+
368+
String WundergroundClient::getMoonriseTime() {
369+
return moonriseTime;
370+
}
371+
372+
String WundergroundClient::getMoonsetTime() {
373+
return moonsetTime;
374+
}
375+
376+
String WundergroundClient::getWindSpeed() {
377+
return windSpeed;
378+
}
379+
380+
String WundergroundClient::getWindDir() {
381+
return windDir;
382+
}
383+
384+
// end JJG add ////////////////////////////////////////////////////////////////////////////////////////////
385+
386+
242387
String WundergroundClient::getCurrentTemp() {
243388
return currentTemp;
244389
}
@@ -255,6 +400,10 @@ String WundergroundClient::getPressure() {
255400
return pressure;
256401
}
257402

403+
String WundergroundClient::getDewPoint() {
404+
return dewPoint;
405+
}
406+
258407
String WundergroundClient::getPrecipitationToday() {
259408
return precipitationToday;
260409
}

WundergroundClient.h

+26
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,22 @@ class WundergroundClient: public JsonListener {
4040
String date = "-";
4141
boolean isMetric = true;
4242
String currentTemp;
43+
// JJG added ... ////////////////////////////////// define returns /////////////////////////////////
44+
String moonPctIlum; // not used
45+
String moonAge; // make this a long?
46+
String moonPhase;
47+
String sunriseTime;
48+
String sunsetTime;
49+
String moonriseTime;
50+
String moonsetTime;
51+
String windSpeed;
52+
String windDir;
53+
// end JJG add ////////////////////////////////////////////////////////////////////////////////////
4354
String weatherIcon;
4455
String weatherText;
4556
String humidity;
4657
String pressure;
58+
String dewPoint;
4759
String precipitationToday;
4860
void doUpdate(String url);
4961

@@ -60,10 +72,22 @@ class WundergroundClient: public JsonListener {
6072
WundergroundClient(boolean isMetric);
6173
void updateConditions(String apiKey, String language, String country, String city);
6274
void updateForecast(String apiKey, String language, String country, String city);
75+
void updateAstronomy(String apiKey, String language, String country, String city); // JJG added
6376
String getHours();
6477
String getMinutes();
6578
String getSeconds();
6679
String getDate();
80+
// JJG added ... ///////////////////function name to string ////////////////////////////
81+
String getMoonPctIlum();
82+
String getMoonAge();
83+
String getMoonPhase();
84+
String getSunriseTime();
85+
String getSunsetTime();
86+
String getMoonriseTime();
87+
String getMoonsetTime();
88+
String getWindSpeed();
89+
String getWindDir();
90+
// end JJG add ///////////////////////////////////////////////////////////////////////
6791
long getCurrentEpoch();
6892

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

79103
String getPressure();
80104

105+
String getDewPoint();
106+
81107
String getPrecipitationToday();
82108

83109
String getForecastIcon(int period);

examples/.DS_Store

8 KB
Binary file not shown.

0 commit comments

Comments
 (0)