Weather Station with ESP32 (with OLED), Nextion & BME280 (and now Virtuino)

I have been puttering with this one for awhile on a NodeMCU and seperate OLED… and just recently switched to a TTGO ESP32 with built in OLED.

I am using the following parts…

  • TTGO ESP32 with integrated 18650 LiPo (holder) and SSD1306 OLED (I2C)
  • Nextion 2.4" HMI touchscreen (not using any touch features in this project, thus connected via TX only, so doesn’t conflict with IDE programming)
  • BME280 - I2C based Temperature, Humidity and Barometric sensor

And getting weather forcast data from openweathermap.org

I used a simple random() generation to move the OLED display around… as well as blank it out every few seconds to prevent burn-in (I totally killed a smaller OLED wired to an ESP8266 due to static display… very bad burn-in made the display all blotchy and hard to read for other purposes).

)

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#include <U8g2lib.h>  // For LCD
#define OLED_SDA 5
#define OLED_SCL 4
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R2, OLED_SCL, OLED_SDA, U8X8_PIN_NONE);

#define ARDUINOJSON_ENABLE_PROGMEM 0
#include <Adafruit_BME280.h>  //https://github.com/Takatsuki0204/BME280-I2C-ESP32
#include <ArduinoJson.h>   //https://github.com/bblanchon/ArduinoJson
#define ALTITUDE 23.0  // Altitude in my location
String CityID = "xxxxx";  // My city location
String APIKEY = "xxxxx";
char auth[] = "xxxxxxxxxx";  // Local Server
char ssid[] = "xxxxx";
char pass[] = "xxxxx";
char server[] = "xxx.xxx.xxx.xxx";
int port = 8080;
#define I2C_SDA 17
#define I2C_SCL 18
#define LED_PIN 16
#define BME280_ADDRESS 0x76  // If the sensor does not work, try the 0x77 address as well
float temperature = 0;
float temperature2;
float humidity = 0;
float pressure = 0;
int weatherID = 0;
int  iterations = 1800;
String weatherDescription = "";
String weatherLocation = "";
char* servername = "api.openweathermap.org"; // remote server we will connect to
String result;
int Counter = 0;
int antiBurn;

Adafruit_BME280 bme(I2C_SDA, I2C_SCL);
BlynkTimer timer;
WidgetLED led2(V5);

/// ========== Images Start ==========

// Thunder cloud
#define pic_3_width 57
#define pic_3_height 32
static unsigned char pic_3_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sunny
#define pic_4_width 57
#define pic_4_height 32
static unsigned char pic_4_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x70, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x7c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7c,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x7e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x83, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x01, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01,
  0x1e, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe, 0x07, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00,
  0xfe, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe, 0x07, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03,
  0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x87, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7c, 0x7e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x7c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x7c,
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x70, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sun and cloud
#define pic_5_width 57
#define pic_5_height 32
static unsigned char pic_5_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xe0, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x78, 0xf8, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x60, 0x78, 0xfc,
  0xc3, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x78, 0xfe, 0x80, 0x3f, 0x00, 0x00,
  0x00, 0xf0, 0x79, 0x3f, 0x00, 0x7e, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f,
  0x00, 0x7c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xf8, 0x00, 0x00,
  0x00, 0x80, 0xc7, 0x07, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc0, 0xc3, 0x03,
  0x00, 0xf0, 0x01, 0x00, 0x00, 0xfe, 0xf1, 0x03, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0xfe, 0xf9, 0x01, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xfe, 0xfd, 0x00,
  0x00, 0xc0, 0x03, 0x00, 0x00, 0xfc, 0x3d, 0x00, 0x00, 0xc0, 0x03, 0x00,
  0x00, 0x80, 0x3f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x1f, 0x00,
  0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00,
  0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xf0, 0x1f, 0x00,
  0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x1e, 0x00, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0x60, 0x3e, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
  0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Light rain
#define pic_6_width 57
#define pic_6_height 32
static unsigned char pic_6_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31,
  0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc6,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sun, cloud and rain
#define pic_7_width 57
#define pic_7_height 32
static unsigned char pic_7_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x39, 0xfb, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x80, 0xbb, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfd,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0xc0, 0x87, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x03,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x80, 0xfb, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf9, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31,
  0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc6,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Snow
#define pic_8_width 57
#define pic_8_height 32
static unsigned char pic_8_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x22,
  0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Cloudy
#define pic_9_width 57
#define pic_9_height 32
static unsigned char pic_9_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
  0xfc, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xf0, 0x03, 0x00, 0x00,
  0x00, 0x00, 0xf0, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
  0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x80, 0x07, 0x00, 0x00,
  0x00, 0x00, 0x3e, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0xe0, 0x07, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x1e, 0x00, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
  0x00, 0x1e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x80, 0x0f, 0x00, 0x00,
  0x00, 0xe0, 0x03, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
  0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Showers
#define pic_10_width 57
#define pic_10_height 32
static unsigned char pic_10_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x30, 0xc6, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x63,
  0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x31, 0x06, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc6, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x8c,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0xc6, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Light Snow
#define pic_11_width 57
#define pic_11_height 32
static unsigned char pic_11_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Windy
#define pic_12_width 57
#define pic_12_height 32
static unsigned char pic_12_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x18, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0xf7, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x80, 0x33, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0x33, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0xff, 0x11, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0x33, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x0e, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0xf3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
  0xe7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Fog
#define pic_13_width 57
#define pic_13_height 32
static unsigned char pic_13_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x11, 0x11,
  0x91, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xdf, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x06, 0xf8, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0xfc, 0x00,
  0x00, 0x03, 0x00, 0x00, 0x00, 0xfc, 0x9f, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x00, 0x03, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x13, 0x11,
  0x11, 0x31, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00,
  0x00, 0x18, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
  0x4b, 0x06, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};
/// ========== Images End ==========


void setup()
{
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);  // For Nextion Display
  u8g2.begin();

  u8g2.enableUTF8Print();
  u8g2.setFont(u8g2_font_crox4hb_tf);
  //u8g2.setFontMode(0);
  //u8g2.setDrawColor(1);

  WiFi.begin(ssid, pass);
  delay(2000);

  initSensor();
  
  Blynk.config(auth, server, port);
  Blynk.connect();  
  
  // Timed Lambda Function -   // First forcast run
  timer.setTimeout(1000L, []() {
    getWeatherData();
  });  // END Timer Function

  timer.setInterval(4000L, nextionSend);  // Update Nextion Values
  timer.setInterval(1800000L, getWeatherData);  // Update Nextion Forcast

  // Timed Lambda Function - UpTime counter
  timer.setInterval(1000L, []() {  // Run every second
    Blynk.virtualWrite(V3, millis() / 60000);  // Display the UpTime in Minutes
  });  // END Timer Function
}



void loop() {
  Blynk.run();
  timer.run();
}



void nextionSend() {
  antiBurn = random(0, 30);
  u8g2.clearDisplay();
  digitalWrite(LED_PIN, LOW);
  delay(2000);
  digitalWrite(LED_PIN, HIGH);
  printWeatherIcon(weatherID);
  getTemperature();
  sendTemperatureToNextion();
  getHumidity();
  sendHumidityToNextion();
  getPressure();
  sendPressureToNextion();
}



void initSensor() {
  //bool status = bme.begin(BME280_ADDRESS);
  bool status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
}



BLYNK_WRITE(V4) {
  int pinValue = param.asInt();

  if (pinValue == 1) {
    led2.on();
  }
  if (pinValue == 0) {
    led2.off();
  }
}



float getTemperature() {
  temperature = bme.readTemperature();
  Blynk.virtualWrite(V0, String(temperature, 1));
  u8g2.setCursor(15, 14 + antiBurn);
  do {
    u8g2.print(String(temperature, 1) + " C");
  } while (
    u8g2.nextPage() );
  return 0;
}

float getHumidity() {
  humidity = bme.readHumidity();
  Blynk.virtualWrite(V1, String(humidity, 1));
  u8g2.setCursor(15, 31 + antiBurn);
  do {
    u8g2.print(String(humidity, 1) + " %");
  } while (
    u8g2.nextPage() );
  return 0;
}

float getPressure() {
  pressure = bme.readPressure();
  pressure = bme.seaLevelForAltitude(ALTITUDE, pressure);
  pressure = pressure / 100.0F;
  Blynk.virtualWrite(V2, String(pressure, 1));
  return 0;
}

void getWeatherData() {  //client function to send/receive GET request data.
  String result = "";
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(servername, httpPort)) {
    return;
  }
  // We now create a URI for the request
  String url = "/data/2.5/forecast?id=" + CityID + "&units=metric&cnt=1&APPID=" + APIKEY;

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + servername + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      client.stop();
      return;
    }
  }
  // Read all the lines of the reply from server
  while (client.available()) {
    result = client.readStringUntil('\r');
  }
  result.replace('[', ' ');
  result.replace(']', ' ');
  char jsonArray [result.length() + 1];
  result.toCharArray(jsonArray, sizeof(jsonArray));
  jsonArray[result.length() + 1] = '\0';
  StaticJsonBuffer<1024> json_buf;
  JsonObject &root = json_buf.parseObject(jsonArray);
  if (!root.success()) {
    Serial.print("parseObject() failed");
  }
  String location = root["city"]["name"];
  String temperature = root["list"]["main"]["temp"];
  String weather = root["list"]["weather"]["main"];
  String description = root["list"]["weather"]["description"];
  String idString = root["list"]["weather"]["id"];
  String timeS = root["list"]["dt_txt"];
  weatherID = idString.toInt();
  Serial.print(weatherID);
  endNextionCommand(); //We need that in order the nextion to recognise the first command after the serial print
}

void showConnectingIcon() {
  //Serial.println();
  String command = "weatherIcon.pic=3";
  Serial.print(command);
  endNextionCommand();
}

void sendHumidityToNextion() {
  String command = "humidity.txt=\"" + String(humidity, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void sendTemperatureToNextion() {
  String command = "temperature.txt=\"" + String(temperature, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void sendPressureToNextion() {
  String command = "pressure.txt=\"" + String(pressure, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void endNextionCommand() {
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
}

void printWeatherIcon(int id) {
  switch (id) {
    case 800: drawClearWeather(); break;
    case 801: drawFewClouds(); break;
    case 802: drawFewClouds(); break;
    case 803: drawCloud(); break;
    case 804: drawCloud(); break;

    case 200: drawThunderstorm(); break;
    case 201: drawThunderstorm(); break;
    case 202: drawThunderstorm(); break;
    case 210: drawThunderstorm(); break;
    case 211: drawThunderstorm(); break;
    case 212: drawThunderstorm(); break;
    case 221: drawThunderstorm(); break;
    case 230: drawThunderstorm(); break;
    case 231: drawThunderstorm(); break;
    case 232: drawThunderstorm(); break;

    case 300: drawLightRain(); break;
    case 301: drawLightRain(); break;
    case 302: drawLightRain(); break;
    case 310: drawLightRain(); break;
    case 311: drawLightRain(); break;
    case 312: drawLightRain(); break;
    case 313: drawLightRain(); break;
    case 314: drawLightRain(); break;
    case 321: drawLightRain(); break;

    case 500: drawLightRainWithSunOrMoon(); break;
    case 501: drawLightRainWithSunOrMoon(); break;
    case 502: drawLightRainWithSunOrMoon(); break;
    case 503: drawLightRainWithSunOrMoon(); break;
    case 504: drawLightRainWithSunOrMoon(); break;
    case 511: drawLightRain(); break;
    case 520: drawModerateRain(); break;
    case 521: drawModerateRain(); break;
    case 522: drawHeavyRain(); break;
    case 531: drawHeavyRain(); break;

    case 600: drawLightSnowfall(); break;
    case 601: drawModerateSnowfall(); break;
    case 602: drawHeavySnowfall(); break;
    case 611: drawLightSnowfall(); break;
    case 612: drawLightSnowfall(); break;
    case 615: drawLightSnowfall(); break;
    case 616: drawLightSnowfall(); break;
    case 620: drawLightSnowfall(); break;
    case 621: drawModerateSnowfall(); break;
    case 622: drawHeavySnowfall(); break;

    case 701: drawFog(); break;
    case 711: drawFog(); break;
    case 721: drawFog(); break;
    case 731: drawFog(); break;
    case 741: drawFog(); break;
    case 751: drawFog(); break;
    case 761: drawFog(); break;
    case 762: drawFog(); break;
    case 771: drawFog(); break;
    case 781: drawFog(); break;

    default: break;
  }
}

void drawFog() {
  String command = "weatherIcon.pic=13";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69,  0 + antiBurn, pic_13_width, pic_13_height, pic_13_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawHeavySnowfall()
{
  String command = "weatherIcon.pic=8";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_8_width, pic_8_height, pic_8_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawModerateSnowfall()
{
  String command = "weatherIcon.pic=8";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_8_width, pic_8_height, pic_8_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightSnowfall()
{
  String command = "weatherIcon.pic=11";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_11_width, pic_11_height, pic_11_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawHeavyRain()
{
  String command = "weatherIcon.pic=10";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_10_width, pic_10_height, pic_10_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawModerateRain()
{
  String command = "weatherIcon.pic=6";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_6_width, pic_6_height, pic_6_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightRain()
{
  String command = "weatherIcon.pic=6";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_6_width, pic_6_height, pic_6_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightRainWithSunOrMoon()
{
  String command = "weatherIcon.pic=7";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_7_width, pic_7_height, pic_7_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}
void drawThunderstorm()
{
  String command = "weatherIcon.pic=3";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_3_width, pic_3_height, pic_3_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawClearWeather()
{
  String command = "weatherIcon.pic=4";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_4_width, pic_4_height, pic_4_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawCloud()
{
  String command = "weatherIcon.pic=9";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_9_width, pic_9_height, pic_9_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawFewClouds()
{
  String command = "weatherIcon.pic=5";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_5_width, pic_5_height, pic_5_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

Sorry, no custom Nextion data to post here… I don’t like signing up to those data storage sites or posting perma-links here :stuck_out_tongue: But If you are really interested (and have a 2.4" Nextion display) you can always PM and ask for the *.HMI file

Meanwhile you can use the base format I started with and extract, resize and edit the images as I did…

9 Likes

I know you Canucks like to butcher the Queen’s English in a similar way to your Mercan neighbours, but “Preassure” is a new one on me :joy::joy::joy:

Nice project!

Pete.

Darn dyslexic tendencies… always messin with my speeeeling abilities :stuck_out_tongue_winking_eye: And since that is graphically embedded (thus no spell check), I need to make a whole new backdrop… lets see what I can mess up 2nd time round :smile:

OK… Fixed it!! :rofl:

image

Now stop preassuring me for preafection :crazy_face:

2 Likes

Was actually easy to fix… good old MS Paint.

1

(Fixed the actual display and first photo above as well… as well as in the App… was missing the R :blush: )

1 Like

I just added Virtuino to my ESP32 + Blynk + Nextion Weather Station now with 33.3% more GUI via the Virtuino App…

(Hopefully I spelt everything correctly :wink: )

Virtuino allows imagery as well… so I am thinking about adding in the Nextion forecast graphics… time will tell.

I commented all additional Virtuino code with // FOR VIRTUINO

Enjoy

//#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESPmDNS.h>  // For OTA
#include <WiFiUdp.h>  // For OTA
#include <ArduinoOTA.h>  // For OTA

#include "Virtuino_ESP_WifiServer.h"  // For VIRTUINO

#include <U8g2lib.h>  // For LCD
#define OLED_SDA 5
#define OLED_SCL 4
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R2, OLED_SCL, OLED_SDA, U8X8_PIN_NONE);   // All Boards without Reset of the Display

#define ARDUINOJSON_ENABLE_PROGMEM 0
#include <Adafruit_BME280.h>  // https://github.com/Takatsuki0204/BME280-I2C-ESP32
#include <ArduinoJson.h>  // https://github.com/bblanchon/ArduinoJson
#define ALTITUDE 23.0  // Altitude in city
String CityID = "xxxxx";  // City 
String APIKEY = "xxxxxxxxxx";
char auth[] = "xxxxxxxxxx";  // Local Server
char ssid[] = "xxxxx";
char pass[] = "xxxxx";
char Blynkserver[] = "xxx.xxx.xxx.xxx";
int port = 8080;
#define I2C_SDA 17
#define I2C_SCL 18
#define LED_PIN 16
#define BME280_ADDRESS 0x76  // If the sensor does not work, try the 0x77 address as well
float temperature = 0;
float humidity = 0;
float pressure = 0;
int weatherID = 0;
String weatherDescription = "";
String weatherLocation = "";
char* servername = "api.openweathermap.org";  // remote server we will connect to
String result;
int Counter = 0;
int antiBurn;

Adafruit_BME280 bme(I2C_SDA, I2C_SCL);
BlynkTimer timer;
WidgetLED led2(V5);


WiFiServer server(8000);  //  For VIRTUINO - Virtuno Server Port
Virtuino_ESP_WifiServer virtuino(&server);  //  For VIRTUINO


/// ========== Images Start ==========

// Thunder cloud
#define pic_3_width 57
#define pic_3_height 32
static unsigned char pic_3_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sunny
#define pic_4_width 57
#define pic_4_height 32
static unsigned char pic_4_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x70, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x7c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7c,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x7e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x83, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x01, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01,
  0x1e, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe, 0x07, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00,
  0xfe, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe, 0x07, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03,
  0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x87, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7c, 0x7e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x7c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x7c,
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x70, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sun and cloud
#define pic_5_width 57
#define pic_5_height 32
static unsigned char pic_5_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xe0, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x78, 0xf8, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x60, 0x78, 0xfc,
  0xc3, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x78, 0xfe, 0x80, 0x3f, 0x00, 0x00,
  0x00, 0xf0, 0x79, 0x3f, 0x00, 0x7e, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f,
  0x00, 0x7c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xf8, 0x00, 0x00,
  0x00, 0x80, 0xc7, 0x07, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc0, 0xc3, 0x03,
  0x00, 0xf0, 0x01, 0x00, 0x00, 0xfe, 0xf1, 0x03, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0xfe, 0xf9, 0x01, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xfe, 0xfd, 0x00,
  0x00, 0xc0, 0x03, 0x00, 0x00, 0xfc, 0x3d, 0x00, 0x00, 0xc0, 0x03, 0x00,
  0x00, 0x80, 0x3f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x1f, 0x00,
  0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00,
  0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xf0, 0x1f, 0x00,
  0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x1e, 0x00, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0x60, 0x3e, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
  0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Light rain
#define pic_6_width 57
#define pic_6_height 32
static unsigned char pic_6_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31,
  0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc6,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sun, cloud and rain
#define pic_7_width 57
#define pic_7_height 32
static unsigned char pic_7_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x39, 0xfb, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x80, 0xbb, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfd,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0xc0, 0x87, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x03,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x80, 0xfb, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf9, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31,
  0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc6,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Snow
#define pic_8_width 57
#define pic_8_height 32
static unsigned char pic_8_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x22,
  0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Cloudy
#define pic_9_width 57
#define pic_9_height 32
static unsigned char pic_9_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
  0xfc, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xf0, 0x03, 0x00, 0x00,
  0x00, 0x00, 0xf0, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
  0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x80, 0x07, 0x00, 0x00,
  0x00, 0x00, 0x3e, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0xe0, 0x07, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x1e, 0x00, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
  0x00, 0x1e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x80, 0x0f, 0x00, 0x00,
  0x00, 0xe0, 0x03, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
  0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Showers
#define pic_10_width 57
#define pic_10_height 32
static unsigned char pic_10_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x30, 0xc6, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x63,
  0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x31, 0x06, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc6, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x8c,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0xc6, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Light Snow
#define pic_11_width 57
#define pic_11_height 32
static unsigned char pic_11_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Windy
#define pic_12_width 57
#define pic_12_height 32
static unsigned char pic_12_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x18, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0xf7, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x80, 0x33, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0x33, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0xff, 0x11, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0x33, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x0e, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0xf3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
  0xe7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Fog
#define pic_13_width 57
#define pic_13_height 32
static unsigned char pic_13_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x11, 0x11,
  0x91, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xdf, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x06, 0xf8, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0xfc, 0x00,
  0x00, 0x03, 0x00, 0x00, 0x00, 0xfc, 0x9f, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x00, 0x03, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x13, 0x11,
  0x11, 0x31, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00,
  0x00, 0x18, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
  0x4b, 0x06, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};
/// ========== Images End ==========





void setup()
{
   //----- Virtuino settings
  virtuino.DEBUG=true;  //  For VIRTUINO - set this value TRUE to enable the serial monitor status
  virtuino.password="1234";  //  For VIRTUINO - Set a password or prefix to your web server for more protection
  // avoid special characters like ! $ = @ # % & * on your password. Use only numbers or text characters
  
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);  // For Nextion Display
  u8g2.begin();

  u8g2.enableUTF8Print();
  u8g2.setFont(u8g2_font_crox4hb_tf);

  WiFi.mode(WIFI_STA);  //  For VIRTUINO - Config module as station only.
  WiFi.begin(ssid, pass);  // Connect to Network
  server.begin();  // For Virtuino
  delay(2000);

  // For VIRTUINO - Display IP for App
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println(WiFi.localIP());
  // -----------

  initSensor();

  Blynk.config(auth, Blynkserver, port);
  Blynk.connect();

  // Timed Lambda Function -   // First forcast run
  timer.setTimeout(1000L, []() {
    getWeatherData();
  });  // END Timer Function

  timer.setInterval(4000L, nextionSend);  // Update Nextion Values
  timer.setInterval(1800000L, getWeatherData);  // Update Nextion Forcast

  // Timed Lambda Function - UpTime counter
  timer.setInterval(1000L, []() {  // Run every second
    Blynk.virtualWrite(V3, millis() / 60000);  // Display the UpTime in Minutes
  });  // END Timer Function
}



void loop() {
  Blynk.run();
  virtuino.run();  //  For VIRTUINO
  timer.run();
}



void nextionSend() {
  antiBurn = random(0, 30);
  u8g2.clearDisplay();
  digitalWrite(LED_PIN, LOW);
  delay(2000);
  digitalWrite(LED_PIN, HIGH);
  printWeatherIcon(weatherID);
  getTemperature();
  sendTemperatureToNextion();
  getHumidity();
  sendHumidityToNextion();
  getPressure();
  sendPressureToNextion();
}



void initSensor() {
  //bool status = bme.begin(BME280_ADDRESS);
  bool status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
}



BLYNK_WRITE(V4) {
  int pinValue = param.asInt();

  if (pinValue == 1) {
    led2.on();
  }
  if (pinValue == 0) {
    led2.off();
  }
}



float getTemperature() {
  temperature = bme.readTemperature();

  virtuino.vMemoryWrite(0, temperature);  // For VIRTUINO -  write to Virtuino pin V0

  Blynk.virtualWrite(V0, String(temperature, 1));
  u8g2.setCursor(15, 14 + antiBurn);
  do {
    u8g2.print(String(temperature, 1) + " C");
  } while (
    u8g2.nextPage() );
  return 0;
}

float getHumidity() {
  humidity = bme.readHumidity();

  virtuino.vMemoryWrite(1, humidity);  // For VIRTUINO - write to Virtuino pin V1

  Blynk.virtualWrite(V1, String(humidity, 1));
  u8g2.setCursor(15, 31 + antiBurn);
  do {
    u8g2.print(String(humidity, 1) + " %");
  } while (
    u8g2.nextPage() );
  return 0;
}

float getPressure() {
  pressure = bme.readPressure();
  pressure = bme.seaLevelForAltitude(ALTITUDE, pressure);
  pressure = pressure / 100.0F;

  virtuino.vMemoryWrite(2, pressure);  // For VIRTUINO -  write to Virtuino pin V2

  Blynk.virtualWrite(V2, String(pressure, 1));
  return 0;
}

void getWeatherData() {  //client function to send/receive GET request data.
  String result = "";
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(servername, httpPort)) {
    return;
  }
  // We now create a URI for the request
  String url = "/data/2.5/forecast?id=" + CityID + "&units=metric&cnt=1&APPID=" + APIKEY;

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + servername + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      client.stop();
      return;
    }
  }
  // Read all the lines of the reply from server
  while (client.available()) {
    result = client.readStringUntil('\r');
  }
  result.replace('[', ' ');
  result.replace(']', ' ');
  char jsonArray [result.length() + 1];
  result.toCharArray(jsonArray, sizeof(jsonArray));
  jsonArray[result.length() + 1] = '\0';
  StaticJsonBuffer<1024> json_buf;
  JsonObject &root = json_buf.parseObject(jsonArray);
  if (!root.success()) {
    Serial.print("parseObject() failed");
  }
  String location = root["city"]["name"];
  String temperature = root["list"]["main"]["temp"];
  String weather = root["list"]["weather"]["main"];
  String description = root["list"]["weather"]["description"];
  String idString = root["list"]["weather"]["id"];
  String timeS = root["list"]["dt_txt"];
  weatherID = idString.toInt();
  Serial.print(weatherID);
  endNextionCommand(); //We need that in order the nextion to recognise the first command after the serial print
}

void showConnectingIcon() {
  //Serial.println();
  String command = "weatherIcon.pic=3";
  Serial.print(command);
  endNextionCommand();
}

void sendHumidityToNextion() {
  String command = "humidity.txt=\"" + String(humidity, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void sendTemperatureToNextion() {
  String command = "temperature.txt=\"" + String(temperature, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void sendPressureToNextion() {
  String command = "pressure.txt=\"" + String(pressure, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void endNextionCommand() {
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
}

void printWeatherIcon(int id) {
  switch (id) {
    case 800: drawClearWeather(); break;
    case 801: drawFewClouds(); break;
    case 802: drawFewClouds(); break;
    case 803: drawCloud(); break;
    case 804: drawCloud(); break;

    case 200: drawThunderstorm(); break;
    case 201: drawThunderstorm(); break;
    case 202: drawThunderstorm(); break;
    case 210: drawThunderstorm(); break;
    case 211: drawThunderstorm(); break;
    case 212: drawThunderstorm(); break;
    case 221: drawThunderstorm(); break;
    case 230: drawThunderstorm(); break;
    case 231: drawThunderstorm(); break;
    case 232: drawThunderstorm(); break;

    case 300: drawLightRain(); break;
    case 301: drawLightRain(); break;
    case 302: drawLightRain(); break;
    case 310: drawLightRain(); break;
    case 311: drawLightRain(); break;
    case 312: drawLightRain(); break;
    case 313: drawLightRain(); break;
    case 314: drawLightRain(); break;
    case 321: drawLightRain(); break;

    case 500: drawLightRainWithSunOrMoon(); break;
    case 501: drawLightRainWithSunOrMoon(); break;
    case 502: drawLightRainWithSunOrMoon(); break;
    case 503: drawLightRainWithSunOrMoon(); break;
    case 504: drawLightRainWithSunOrMoon(); break;
    case 511: drawLightRain(); break;
    case 520: drawModerateRain(); break;
    case 521: drawModerateRain(); break;
    case 522: drawHeavyRain(); break;
    case 531: drawHeavyRain(); break;

    case 600: drawLightSnowfall(); break;
    case 601: drawModerateSnowfall(); break;
    case 602: drawHeavySnowfall(); break;
    case 611: drawLightSnowfall(); break;
    case 612: drawLightSnowfall(); break;
    case 615: drawLightSnowfall(); break;
    case 616: drawLightSnowfall(); break;
    case 620: drawLightSnowfall(); break;
    case 621: drawModerateSnowfall(); break;
    case 622: drawHeavySnowfall(); break;

    case 701: drawFog(); break;
    case 711: drawFog(); break;
    case 721: drawFog(); break;
    case 731: drawFog(); break;
    case 741: drawFog(); break;
    case 751: drawFog(); break;
    case 761: drawFog(); break;
    case 762: drawFog(); break;
    case 771: drawFog(); break;
    case 781: drawFog(); break;

    default: break;
  }
}

void drawFog() {
  String command = "weatherIcon.pic=13";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69,  0 + antiBurn, pic_13_width, pic_13_height, pic_13_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawHeavySnowfall()
{
  String command = "weatherIcon.pic=8";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_8_width, pic_8_height, pic_8_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawModerateSnowfall()
{
  String command = "weatherIcon.pic=8";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_8_width, pic_8_height, pic_8_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightSnowfall()
{
  String command = "weatherIcon.pic=11";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_11_width, pic_11_height, pic_11_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawHeavyRain()
{
  String command = "weatherIcon.pic=10";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_10_width, pic_10_height, pic_10_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawModerateRain()
{
  String command = "weatherIcon.pic=6";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_6_width, pic_6_height, pic_6_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightRain()
{
  String command = "weatherIcon.pic=6";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_6_width, pic_6_height, pic_6_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightRainWithSunOrMoon()
{
  String command = "weatherIcon.pic=7";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_7_width, pic_7_height, pic_7_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}
void drawThunderstorm()
{
  String command = "weatherIcon.pic=3";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_3_width, pic_3_height, pic_3_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawClearWeather()
{
  String command = "weatherIcon.pic=4";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_4_width, pic_4_height, pic_4_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawCloud()
{
  String command = "weatherIcon.pic=9";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_9_width, pic_9_height, pic_9_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawFewClouds()
{
  String command = "weatherIcon.pic=5";
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_5_width, pic_5_height, pic_5_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

yes !
Blynk will do soon … soon… soon…
but not tomorow
:wink:

2 Likes

Well, I bit the bullet and purchased the Virtuino Pro… it was about the same cost of a loaf of Gluten Free bread… so it was a sacrificial choice :stuck_out_tongue_winking_eye: eating is overrated anyhow.

But that opened up many features that I haven’t even begun to sample yet. but now I have a nice clean font.

I also discovered that one can overlay widgets :smile: (with or without a clear background) on top of another… so now I combined the title and the value…

BLYNK, aside from needing BIG font scaling options… please also take note of these beneficial UI design abilities :pray:

PS, Super Chart is still the best full feature chart… but I am starting to see the benefits of an (optional?) grid :wink:

2 Likes

Same here Gunner, I bought Virtuino, although I am not using it, to support them, because is an excellent app making just from a single man, a Greek teacher. If you search for the past post, you will find an old post from me, introducing Virtuino to this forum…

@mikekgr Interesting… I had actually searched this site for the keyword virtuino before, but hadn’t found any prior posts to my own.

I started with Blynk for the GUI… never was much into this whole IoT phenomenon, IMHO it can be too much of a security risk for vital utilisation, unless you really know what you are doing.

After the great Blynk fonticide :innocent: I started looking around to see how other Arduino/ESP GUIs utilise fonts…Thankfully scalable fonts ARE a thing :wink: Also, I am liking it because it can easily coexist with, operates similar too and complements my already existing Blynk projects with minimal changes in how I communicate between device and App(s).

Now I can work with what I am already comfortable with and has so many great features (Blynk), but also get some of the missing realistic looking widget and aesthetic features I want (Virtuino).

So, depending on the display type or connectivity options I want for any given project (i.e Wall mounted displays and/or serverless WiFi), I can enjoy BOTH Peanut Butter AND Jelly!! :smiley: Albeit on two separate slices of bread that can only be eaten in separate bytes :smile:

Great, so in case that I need a little help, I can think of the Best Man to asking for!

1 Like

Updated Blynk and Virtuino to show the forecasted weather image :smiley:

EDIT - Updated images to *.PNG with transparent backgrounds… much nicer :smiley:


3 4 5 6 7 8 9 10 11 12 13


And the code is posted in two halves as it is getting too large for single post.

//#define BLYNK_PRINT Serial
//#include <ESP8266WiFi.h>
//#include <BlynkSimpleEsp8266.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESPmDNS.h>  // For OTA
#include <WiFiUdp.h>  // For OTA
#include <ArduinoOTA.h>  // For OTA

#include "Virtuino_ESP_WifiServer.h"  // For VIRTUINO

//#include <SPI.h>  // For LCD
#include <U8g2lib.h>  // For LCD
#define OLED_SDA 5
#define OLED_SCL 4
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R2, OLED_SCL, OLED_SDA, U8X8_PIN_NONE);   // All Boards without Reset of the Display
//U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, U8X8_PIN_NONE, OLED_SCL, OLED_SDA);   // ESP32 Thing, HW I2C with pin remapping



#define ARDUINOJSON_ENABLE_PROGMEM 0
#include <Adafruit_BME280.h>  // https://github.com/Takatsuki0204/BME280-I2C-ESP32
#include <ArduinoJson.h>  // https://github.com/bblanchon/ArduinoJson
#define ALTITUDE 23.0  // Altitude in Agassiz, BC CAN
String CityID = "5882534";  //Agassiz, BC CAN
String APIKEY = "b81fce8e8cf907588022cd32a8bcaa38";
char auth[] = "803ca069e2a94533906c34c0743c85cd";  // Local Server
char ssid[] = "GunnersZone";
char pass[] = "MySonJesseRob";
char Blynkserver[] = "10.10.3.13";
int port = 8080;
#define I2C_SDA 17
#define I2C_SCL 18
#define LED_PIN 16
#define BME280_ADDRESS 0x76  // If the sensor does not work, try the 0x77 address as well
float temperature = 0;
float humidity = 0;
float pressure = 0;
int weatherID = 0;
String weatherDescription = "";
String weatherLocation = "";
char* servername = "api.openweathermap.org";  // remote server we will connect to
String result;
int Counter = 0;
int antiBurn;

Adafruit_BME280 bme(I2C_SDA, I2C_SCL);
BlynkTimer timer;
WidgetLED led2(V5);


WiFiServer server(8000);  //  For VIRTUINO - Virtuno Server Port
Virtuino_ESP_WifiServer virtuino(&server);


/// ========== Images Start ==========

// Thunder cloud
#define pic_3_width 57
#define pic_3_height 32
static unsigned char pic_3_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sunny
#define pic_4_width 57
#define pic_4_height 32
static unsigned char pic_4_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x70, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x7c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7c,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x7e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x83, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x01, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01,
  0x1e, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe, 0x07, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00,
  0xfe, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe, 0x07, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03,
  0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x87, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7c, 0x7e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x7c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x7c,
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x70, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sun and cloud
#define pic_5_width 57
#define pic_5_height 32
static unsigned char pic_5_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
  0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xe0, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x78, 0xf8, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x60, 0x78, 0xfc,
  0xc3, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x78, 0xfe, 0x80, 0x3f, 0x00, 0x00,
  0x00, 0xf0, 0x79, 0x3f, 0x00, 0x7e, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f,
  0x00, 0x7c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xf8, 0x00, 0x00,
  0x00, 0x80, 0xc7, 0x07, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc0, 0xc3, 0x03,
  0x00, 0xf0, 0x01, 0x00, 0x00, 0xfe, 0xf1, 0x03, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0xfe, 0xf9, 0x01, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xfe, 0xfd, 0x00,
  0x00, 0xc0, 0x03, 0x00, 0x00, 0xfc, 0x3d, 0x00, 0x00, 0xc0, 0x03, 0x00,
  0x00, 0x80, 0x3f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x1f, 0x00,
  0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00,
  0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xf0, 0x1f, 0x00,
  0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x1e, 0x00, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0x60, 0x3e, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
  0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Light rain
#define pic_6_width 57
#define pic_6_height 32
static unsigned char pic_6_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31,
  0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc6,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Sun, cloud and rain
#define pic_7_width 57
#define pic_7_height 32
static unsigned char pic_7_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x39, 0xfb, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x80, 0xbb, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfd,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0xc0, 0x87, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x03,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x80, 0xfb, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf9, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31,
  0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc6,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Snow
#define pic_8_width 57
#define pic_8_height 32
static unsigned char pic_8_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x22,
  0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Cloudy
#define pic_9_width 57
#define pic_9_height 32
static unsigned char pic_9_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
  0xfc, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xf0, 0x03, 0x00, 0x00,
  0x00, 0x00, 0xf0, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
  0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x80, 0x07, 0x00, 0x00,
  0x00, 0x00, 0x3e, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0xe0, 0x07, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00,
  0x00, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x1e, 0x00, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
  0x00, 0x1e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
  0x00, 0xf8, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x80, 0x0f, 0x00, 0x00,
  0x00, 0xe0, 0x03, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
  0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Showers
#define pic_10_width 57
#define pic_10_height 32
static unsigned char pic_10_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x30, 0xc6, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x63,
  0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x31, 0x06, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc6, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x8c,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0xc6, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Light Snow
#define pic_11_width 57
#define pic_11_height 32
static unsigned char pic_11_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x3e, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xc0, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
  0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x78, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
  0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Windy
#define pic_12_width 57
#define pic_12_height 32
static unsigned char pic_12_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x18, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0xf7, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x80, 0x33, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0x33, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
  0x00, 0xc0, 0xff, 0xff, 0x11, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
  0x33, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x0e, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0xf3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
  0xe7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};

// Fog
#define pic_13_width 57
#define pic_13_height 32
static unsigned char pic_13_bits[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x11, 0x11,
  0x91, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xdf, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x06, 0xf8, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0xfc, 0x00,
  0x00, 0x03, 0x00, 0x00, 0x00, 0xfc, 0x9f, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x00, 0x03, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x13, 0x11,
  0x11, 0x31, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00,
  0x00, 0x18, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
  0x4b, 0x06, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00
};
/// ========== Images End ==========





void setup()
{
  //----- Virtuino settings
  virtuino.DEBUG = true;       // set this value TRUE to enable the serial monitor status
  virtuino.password = "1234";  // Set a password or prefix to your web server for more protection
  // avoid special characters like ! $ = @ # % & * on your password. Use only numbers or text characters

  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);  // For Nextion Display
  u8g2.begin();

  u8g2.enableUTF8Print();
  u8g2.setFont(u8g2_font_crox4hb_tf);

  WiFi.mode(WIFI_STA);  // Config module as station only.
  WiFi.begin(ssid, pass);  // Connect to Network
  server.begin();  // For Virtuino
  delay(2000);

  // For VIRTUINO - Display IP for App
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println(WiFi.localIP());
  // -----------

  initSensor();

  Blynk.config(auth, Blynkserver, port);
  Blynk.connect();

  // Timed Lambda Function -   // First forcast run
  timer.setTimeout(1000L, []() {
    getWeatherData();
  });  // END Timer Function

  timer.setInterval(4000L, nextionSend);  // Update Nextion Values
  timer.setInterval(1800000L, getWeatherData);  // Update Nextion Forcast

  // Timed Lambda Function - UpTime counter
  timer.setInterval(1000L, []() {  // Run every second
    Blynk.virtualWrite(V3, millis() / 60000);  // Display the UpTime in Minutes
  });  // END Timer Function
}



void loop() {
  Blynk.run();
  virtuino.run();
  timer.run();
}

// end of part 1 of split code
// start of part 2 of split code

void nextionSend() {
  antiBurn = random(0, 30);
  u8g2.clearDisplay();
  digitalWrite(LED_PIN, LOW);
  delay(2000);
  digitalWrite(LED_PIN, HIGH);
  printWeatherIcon(weatherID);
  getTemperature();
  sendTemperatureToNextion();
  getHumidity();
  sendHumidityToNextion();
  getPressure();
  sendPressureToNextion();
}



void initSensor() {
  //bool status = bme.begin(BME280_ADDRESS);
  bool status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
}



BLYNK_WRITE(V4) {
  int pinValue = param.asInt();

  if (pinValue == 1) {
    led2.on();
  }
  if (pinValue == 0) {
    led2.off();
  }
}



float getTemperature() {
  temperature = bme.readTemperature();

  virtuino.vMemoryWrite(0, temperature);  // For VIRTUINO -  write to Virtuino pin V0

  Blynk.virtualWrite(V0, String(temperature, 1));
  u8g2.setCursor(15, 14 + antiBurn);
  do {
    u8g2.print(String(temperature, 1) + " C");
  } while (
    u8g2.nextPage() );
  return 0;
}

float getHumidity() {
  humidity = bme.readHumidity();

  virtuino.vMemoryWrite(1, humidity);  // For VIRTUINO - write to Virtuino pin V1

  Blynk.virtualWrite(V1, String(humidity, 1));
  u8g2.setCursor(15, 31 + antiBurn);
  do {
    u8g2.print(String(humidity, 1) + " %");
  } while (
    u8g2.nextPage() );
  return 0;
}

float getPressure() {
  pressure = bme.readPressure();
  pressure = bme.seaLevelForAltitude(ALTITUDE, pressure);
  pressure = pressure / 100.0F;

  virtuino.vMemoryWrite(2, pressure);  // For VIRTUINO -  write to Virtuino pin V2

  Blynk.virtualWrite(V2, String(pressure, 1));
  return 0;
}

void getWeatherData() {  //client function to send/receive GET request data.
  String result = "";
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(servername, httpPort)) {
    return;
  }
  // We now create a URI for the request
  String url = "/data/2.5/forecast?id=" + CityID + "&units=metric&cnt=1&APPID=" + APIKEY;

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + servername + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      client.stop();
      return;
    }
  }
  // Read all the lines of the reply from server
  while (client.available()) {
    result = client.readStringUntil('\r');
  }
  result.replace('[', ' ');
  result.replace(']', ' ');
  char jsonArray [result.length() + 1];
  result.toCharArray(jsonArray, sizeof(jsonArray));
  jsonArray[result.length() + 1] = '\0';
  StaticJsonBuffer<1024> json_buf;
  JsonObject &root = json_buf.parseObject(jsonArray);
  if (!root.success()) {
    Serial.print("parseObject() failed");
  }
  String location = root["city"]["name"];
  String temperature = root["list"]["main"]["temp"];
  String weather = root["list"]["weather"]["main"];
  String description = root["list"]["weather"]["description"];
  String idString = root["list"]["weather"]["id"];
  String timeS = root["list"]["dt_txt"];
  weatherID = idString.toInt();
  Serial.print(weatherID);
  endNextionCommand(); //We need that in order the nextion to recognise the first command after the serial print
}

void showConnectingIcon() {
  //Serial.println();
  String command = "weatherIcon.pic=3";
  Blynk.virtualWrite(V4, 3);
  virtuino.vMemoryWrite(10, 0);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
}

void sendHumidityToNextion() {
  String command = "humidity.txt=\"" + String(humidity, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void sendTemperatureToNextion() {
  String command = "temperature.txt=\"" + String(temperature, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void sendPressureToNextion() {
  String command = "pressure.txt=\"" + String(pressure, 1) + "\"";
  Serial.print(command);
  endNextionCommand();
}

void endNextionCommand() {
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
}

void printWeatherIcon(int id) {
  switch (id) {
    case 800: drawClearWeather(); break;
    case 801: drawFewClouds(); break;
    case 802: drawFewClouds(); break;
    case 803: drawCloud(); break;
    case 804: drawCloud(); break;

    case 200: drawThunderstorm(); break;
    case 201: drawThunderstorm(); break;
    case 202: drawThunderstorm(); break;
    case 210: drawThunderstorm(); break;
    case 211: drawThunderstorm(); break;
    case 212: drawThunderstorm(); break;
    case 221: drawThunderstorm(); break;
    case 230: drawThunderstorm(); break;
    case 231: drawThunderstorm(); break;
    case 232: drawThunderstorm(); break;

    case 300: drawLightRain(); break;
    case 301: drawLightRain(); break;
    case 302: drawLightRain(); break;
    case 310: drawLightRain(); break;
    case 311: drawLightRain(); break;
    case 312: drawLightRain(); break;
    case 313: drawLightRain(); break;
    case 314: drawLightRain(); break;
    case 321: drawLightRain(); break;

    case 500: drawLightRainWithSunOrMoon(); break;
    case 501: drawLightRainWithSunOrMoon(); break;
    case 502: drawLightRainWithSunOrMoon(); break;
    case 503: drawLightRainWithSunOrMoon(); break;
    case 504: drawLightRainWithSunOrMoon(); break;
    case 511: drawLightRain(); break;
    case 520: drawModerateRain(); break;
    case 521: drawModerateRain(); break;
    case 522: drawHeavyRain(); break;
    case 531: drawHeavyRain(); break;

    case 600: drawLightSnowfall(); break;
    case 601: drawModerateSnowfall(); break;
    case 602: drawHeavySnowfall(); break;
    case 611: drawLightSnowfall(); break;
    case 612: drawLightSnowfall(); break;
    case 615: drawLightSnowfall(); break;
    case 616: drawLightSnowfall(); break;
    case 620: drawLightSnowfall(); break;
    case 621: drawModerateSnowfall(); break;
    case 622: drawHeavySnowfall(); break;

    case 701: drawFog(); break;
    case 711: drawFog(); break;
    case 721: drawFog(); break;
    case 731: drawFog(); break;
    case 741: drawFog(); break;
    case 751: drawFog(); break;
    case 761: drawFog(); break;
    case 762: drawFog(); break;
    case 771: drawFog(); break;
    case 781: drawFog(); break;

    default: break;
  }
}

void drawFog() {
  String command = "weatherIcon.pic=13";
  Blynk.virtualWrite(V4, 13);
  virtuino.vMemoryWrite(10, 13);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69,  0 + antiBurn, pic_13_width, pic_13_height, pic_13_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawHeavySnowfall()
{
  String command = "weatherIcon.pic=8";
  Blynk.virtualWrite(V4, 8);
  virtuino.vMemoryWrite(10, 8);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_8_width, pic_8_height, pic_8_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawModerateSnowfall()
{
  String command = "weatherIcon.pic=8";
  Blynk.virtualWrite(V4, 8);
  virtuino.vMemoryWrite(10, 11);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_8_width, pic_8_height, pic_8_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightSnowfall()
{
  String command = "weatherIcon.pic=11";
  Blynk.virtualWrite(V4, 11);
  virtuino.vMemoryWrite(10, 11);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_11_width, pic_11_height, pic_11_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawHeavyRain()
{
  String command = "weatherIcon.pic=10";
  Blynk.virtualWrite(V4, 10);
  virtuino.vMemoryWrite(10, 10);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_10_width, pic_10_height, pic_10_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawModerateRain()
{
  String command = "weatherIcon.pic=6";
  Blynk.virtualWrite(V4, 6);
  virtuino.vMemoryWrite(10, 6);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_6_width, pic_6_height, pic_6_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightRain()
{
  String command = "weatherIcon.pic=6";
  Blynk.virtualWrite(V4, 6);
  virtuino.vMemoryWrite(10, 6);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_6_width, pic_6_height, pic_6_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawLightRainWithSunOrMoon()
{
  String command = "weatherIcon.pic=7";
  Blynk.virtualWrite(V4, 7);
  virtuino.vMemoryWrite(10, 7);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_7_width, pic_7_height, pic_7_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}
void drawThunderstorm()
{
  String command = "weatherIcon.pic=3";
  Blynk.virtualWrite(V4, 3);
  virtuino.vMemoryWrite(10, 3);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_3_width, pic_3_height, pic_3_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawClearWeather()
{
  String command = "weatherIcon.pic=4";
  Blynk.virtualWrite(V4, 4);
  virtuino.vMemoryWrite(10, 4);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_4_width, pic_4_height, pic_4_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawCloud()
{
  String command = "weatherIcon.pic=9";
  Blynk.virtualWrite(V4, 9);
  virtuino.vMemoryWrite(10, 9);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_9_width, pic_9_height, pic_9_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}

void drawFewClouds()
{
  String command = "weatherIcon.pic=5";
  Blynk.virtualWrite(V4, 5);
  virtuino.vMemoryWrite(10, 5);  // For VIRTUINO
  Serial.print(command);
  endNextionCommand();
  do {
    u8g2.drawXBM(69, 0 + antiBurn, pic_5_width, pic_5_height, pic_5_bits);  // Sunny
  } while (
    u8g2.nextPage() );
}
4 Likes