ThingPulse / esp8266-weather-station

ESP8266 Weather Station library supporting OpenWeatherMap, Aeris and other sources
MIT License
1.06k stars 362 forks source link

esp8266-weather-station (with Blynk) #105

Closed tsavasci closed 5 years ago

tsavasci commented 6 years ago

Hi, I just added the Blynk to WeatherStationDemoExtendedDST.ino code.. nothing more.

  1. Include this library, define Blynk print and Blynk Timer instead of ticker #include <BlynkSimpleEsp8266.h> #define BLYNK_PRINT Serial BlynkTimer timer;

  2. Include your auth token for Blynk char auth[] = "xxxxxxxxxxxxx";

  3. Add virtual pin defs before void.setup BLYNK_WRITE(V0) // writes current weather temp to blynk app V0 pin { float pinValue = param.asFloat(); } BLYNK_WRITE(V2) // writes current weather text to blynk app V2 pin { String pinValue = param.asString(); } BLYNK_WRITE(V3) // writes wifi quality to blynk app V3 pin { int pinValue = param.asInt(); }

  4. In void.Setup section add Blynk config and connect. (I use local server so i declare my server ip and port, if you dont delete ip address and port. //Blynk.config(auth); // for Blynk server Blynk.config(auth, IPAddress(192, xxx, xxx, xxx), 8080); //for local server Blynk.connect();

  5. I use blynk timer //ticker.attach(UPDATE_INTERVAL_SECS, setReadyForWeatherUpdate); //ticker.attach(60, setReadyForDHTUpdate); timer.setInterval(200000L, setReadyForWeatherUpdate); timer.setInterval(130000L, setReadyForDHTUpdate);

  6. In void loop section add this lines if (remainingTimeBudget > 0) { Blynk.run(); timer.run(); }

7.Add this two bold lines in void drawCurrentWeather function void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { display->setFont(ArialMT_Plain_10); display->setTextAlignment(TEXT_ALIGN_LEFT); display->drawString(60 + x, 5 + y, wunderground.getWeatherText()); Blynk.virtualWrite(V2, wunderground.getWeatherText());

display->setFont(ArialMT_Plain_24); String temp = wunderground.getCurrentTemp() + (IS_METRIC ? "°C" : "°F"); Blynk.virtualWrite(V0, wunderground.getCurrentTemp()); display->drawString(60 + x, 15 + y, temp); int tempWidth = display->getStringWidth(temp);

display->setFont(Meteocons_Plain_42); String weatherIcon = wunderground.getTodayIcon(); int weatherIconWidth = display->getStringWidth(weatherIcon); display->drawString(32 + x - weatherIconWidth / 2, 05 + y, weatherIcon); }

  1. Finally send wifi quality to Blynk app in setReadyForDHTUpdate function.

void setReadyForDHTUpdate() { Serial.println("Setting readyForDHTUpdate to true"); readyForDHTUpdate = true; Blynk.virtualWrite(V3, WiFi.RSSI()); }

and result...

secreen

Condition icon changes by the weather text. In my project I set them for Turkish you can change them to your language in Blynk eventor

conditions

Here is the Blynk QR of my project. You can clone it easily with Blynk app blynk qr

OLED and Nodemcu works very good too...

project

Italque commented 6 years ago

Great! simple and amazing! Thanks for share!

Italque commented 6 years ago

I hope there is a way to upload data to ThingSpeak and Wunderground both. I didn't find a solution at the moment.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.