├── Gerber ESP8266-Weather-Station-V3.zip └── esp8266_weather_forcast_with_display_v3.ino /Gerber ESP8266-Weather-Station-V3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shveytank/ESP8266-Weather-Station-V3/1d9a5df8fadf6482fb78512e35e9d645c656177d/Gerber ESP8266-Weather-Station-V3.zip -------------------------------------------------------------------------------- /esp8266_weather_forcast_with_display_v3.ino: -------------------------------------------------------------------------------- 1 | #include // include Adafruit graphics library 2 | #include // include Adafruit ST7735 TFT library 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "OpenWeatherMapCurrent.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | OpenWeatherMapCurrent client; 20 | 21 | // ST7735 TFT module connections 22 | #define TFT_RST D4 // TFT RST pin is connected to NodeMCU pin D4 (GPIO2) 23 | #define TFT_CS D3 // TFT CS pin is connected to NodeMCU pin D4 (GPIO0) 24 | #define TFT_DC D2 // TFT DC pin is connected to NodeMCU pin D4 (GPIO4) 25 | 26 | Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 27 | 28 | 29 | String OPEN_WEATHER_MAP_APP_ID = "**************************"; 30 | String OPEN_WEATHER_MAP_LOCATION = "*******"; 31 | String OPEN_WEATHER_MAP_LANGUAGE = "en"; 32 | boolean IS_METRIC = true; 33 | 34 | const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId(); 35 | const char* WIFI_SSID = "*********"; 36 | const char* WIFI_PASSWORD = "*********"; 37 | 38 | const long utcOffsetInSeconds = 19800; 39 | char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; 40 | WiFiUDP ntpUDP; 41 | NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds); 42 | uint16_t colors[7]={0xF800, 0xFB20, 0xFFE0, 0x87E0, 0x04E0, 0x07FF, 0x03DF}; 43 | uint16_t col=0; 44 | const unsigned char thunder[] PROGMEM = { 45 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 46 | B00000000,B00000000,B00000000,B00111110,B00000000,B00000000,B00000000, 47 | B00000000,B00000000,B00000001,B11100011,B11000000,B00000000,B00000000, 48 | B00000000,B00000000,B00000011,B00000000,B01100000,B00000000,B00000000, 49 | B00000000,B00000000,B00000100,B00000000,B00110000,B00000000,B00000000, 50 | B00000000,B00000000,B00001000,B00000000,B00011000,B00000000,B00000000, 51 | B00000000,B00000000,B00010000,B00000000,B00001100,B00000000,B00000000, 52 | B00000000,B00000000,B00110000,B00000000,B00000111,B11000000,B00000000, 53 | B00000000,B00000000,B00100000,B00000000,B00000000,B01100000,B00000000, 54 | B00000000,B00001111,B11100000,B00000000,B00000000,B00010000,B00000000, 55 | B00000000,B00011000,B00000000,B00000000,B00000000,B00011000,B00000000, 56 | B00000000,B00100000,B00000000,B00000000,B00000000,B00001000,B00000000, 57 | B00000000,B01100000,B00000000,B00000000,B00000000,B00001100,B00000000, 58 | B00000000,B01000000,B00000000,B00000000,B00000000,B00001100,B00000000, 59 | B00000000,B11000000,B00000000,B00000000,B00000000,B00001100,B00000000, 60 | B00001111,B10000000,B00000000,B00000100,B00000000,B00001000,B00000000, 61 | B00011000,B00000000,B00000000,B00000100,B00000000,B00001100,B00000000, 62 | B00110000,B00000000,B00000000,B00001100,B00000000,B00000110,B00000000, 63 | B00100000,B00000000,B00000000,B00001000,B00000000,B00000010,B00000000, 64 | B01100000,B00000000,B00000000,B00011000,B00000000,B00000011,B00000000, 65 | B01000000,B00000000,B00000000,B00010000,B00000000,B00000001,B00000000, 66 | B01000000,B00000000,B00010000,B00110000,B00000000,B00000001,B00000000, 67 | B01000000,B00000000,B00110000,B00100000,B00000000,B00000001,B00000000, 68 | B01100000,B00000000,B00100000,B00100000,B00000000,B00000011,B00000000, 69 | B00100000,B00000000,B01100000,B01111111,B10000000,B00000010,B00000000, 70 | B00010000,B00000000,B01000000,B01111111,B10000000,B00000110,B00000000, 71 | B00011100,B00000000,B01111000,B00000001,B00000000,B00011100,B00000000, 72 | B00000111,B11111100,B00001000,B00000011,B00111111,B11110000,B00000000, 73 | B00000000,B00000000,B00011000,B00000010,B00000000,B00000000,B00000000, 74 | B00000000,B00000000,B00010000,B00000010,B00000000,B00000000,B00000000, 75 | B00000000,B00000000,B00110000,B00000100,B00000000,B00000000,B00000000, 76 | B00000000,B00000000,B00100000,B00000100,B00000000,B00000000,B00000000, 77 | B00000000,B00000000,B01100000,B00001100,B00000000,B00000000,B00000000, 78 | B00000000,B00000000,B01000000,B00001000,B00000000,B00000000,B00000000, 79 | B00010000,B00000110,B00000000,B10000000,B00010000,B00000100,B00000000, 80 | B00110000,B00000100,B00000001,B10000000,B00100000,B00000100,B00000000, 81 | B00100000,B00001100,B00000001,B00000000,B00100000,B00001100,B00000000, 82 | B01100000,B00001000,B00000001,B00000000,B01100000,B00001000,B00000000, 83 | B01000000,B00001000,B00000011,B00000000,B01000000,B00011000,B00000000, 84 | B01000000,B00000000,B00000010,B00000000,B01000000,B00010000,B00000000 85 | }; 86 | 87 | 88 | const unsigned char drizzle[] PROGMEM = { 89 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 90 | B00000000,B00000000,B00000000,B01111111,B11000000,B00000000,B00000000, 91 | B00000000,B00000000,B00000000,B11100000,B11100000,B00000000,B00000000, 92 | B00000000,B00000000,B00000011,B10000000,B00111000,B00000000,B00000000, 93 | B00000000,B00000000,B00000110,B00000000,B00001100,B00000000,B00000000, 94 | B00000000,B00000000,B00000100,B00000000,B00000110,B00000000,B00000000, 95 | B00000000,B00000000,B00001100,B00000000,B00000010,B00000000,B00000000, 96 | B00000000,B00000000,B00011000,B00000000,B00000011,B11100000,B00000000, 97 | B00000000,B00000000,B00010000,B00000000,B00000001,B11111000,B00000000, 98 | B00000000,B00000011,B11110000,B00000000,B00000000,B00001100,B00000000, 99 | B00000000,B00001110,B01110000,B00000000,B00000000,B00000110,B00000000, 100 | B00000000,B00011000,B00000000,B00000000,B00000000,B00000110,B00000000, 101 | B00000000,B00100000,B00000000,B00000000,B00000000,B00000010,B00000000, 102 | B00000000,B01100000,B00000000,B00000000,B00000000,B00000011,B00000000, 103 | B00000000,B01000000,B00000000,B00000000,B00000000,B00000011,B00000000, 104 | B00000000,B11000000,B00000000,B00000000,B00000000,B00000011,B00000000, 105 | B00000111,B11000000,B00000000,B00000000,B00000000,B00000010,B00000000, 106 | B00011100,B00000000,B00000000,B00000000,B00000000,B00000011,B00000000, 107 | B00010000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000, 108 | B00100000,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000, 109 | B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000, 110 | B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000, 111 | B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000, 112 | B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000, 113 | B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000, 114 | B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000, 115 | B00100000,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000, 116 | B00110000,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000, 117 | B00011000,B00000000,B00000000,B00000000,B00000000,B00000011,B00000000, 118 | B00001110,B00000000,B00000000,B00000000,B00000000,B00001110,B00000000, 119 | B00000111,B11111111,B11111111,B11111111,B11111111,B11111100,B00000000, 120 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 121 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 122 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 123 | B00000000,B11000000,B00110000,B00001100,B00000011,B00000000,B00000000, 124 | B00000000,B11000000,B00100000,B00001000,B00000010,B00000000,B00000000, 125 | B00000000,B10000000,B00100000,B00011000,B00000110,B00000000,B00000000, 126 | B00000001,B10000000,B01100000,B00010000,B00000100,B00000000,B00000000, 127 | B00000001,B00000000,B01000000,B00110000,B00000100,B00000000,B00000000, 128 | B00000001,B00000000,B01000000,B00110000,B00001100,B00000000,B00000000 129 | }; 130 | 131 | 132 | const unsigned char rain[] PROGMEM = { 133 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 134 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 135 | B00000000,B00000000,B11111110,B00000000,B00000000,B00000000,B00000000, 136 | B00000000,B00000011,B00000001,B10001111,B11110000,B00000000,B00000000, 137 | B00000000,B00000110,B00000000,B11110000,B00001100,B00000000,B00000000, 138 | B00000000,B00001100,B00000000,B01000000,B00000110,B00000000,B00000000, 139 | B00000000,B01111000,B00000000,B10000000,B00000011,B00000000,B00000000, 140 | B00000001,B10000000,B00000001,B10000000,B00000001,B11100000,B00000000, 141 | B00000001,B00000000,B00000001,B00000000,B00000000,B00011000,B00000000, 142 | B00000001,B00000000,B01111111,B00000000,B00000000,B00001100,B00000000, 143 | B00000001,B00000000,B11000000,B00000000,B00000000,B00000110,B00000000, 144 | B00000001,B00000001,B10000000,B00000000,B00000000,B00000010,B00000000, 145 | B00000011,B00000001,B00000000,B00000000,B00000000,B00000010,B00000000, 146 | B00000110,B00000111,B00000000,B00000000,B00000000,B00000010,B00000000, 147 | B00000100,B00111000,B00000000,B00000000,B00000000,B00000110,B00000000, 148 | B00000100,B01100000,B00000000,B00000000,B00000000,B00000011,B00000000, 149 | B00000100,B01000000,B00000000,B00000000,B00000000,B00000001,B00000000, 150 | B00000110,B11000000,B00000000,B00000000,B00000000,B00000000,B10000000, 151 | B00000011,B10000000,B00000000,B00000000,B00000000,B00000000,B10000000, 152 | B00000001,B10000000,B00000000,B00000000,B00000000,B00000000,B10000000, 153 | B00000000,B01000000,B00000000,B00000000,B00000000,B00000001,B10000000, 154 | B00000000,B01000000,B00000000,B00000000,B00000000,B00000001,B00000000, 155 | B00000000,B00100000,B00000000,B00000000,B00000000,B00000010,B00000000, 156 | B00000000,B00011111,B11111111,B11111111,B11111111,B11111100,B00000000, 157 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 158 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 159 | B00000010,B00000001,B00000000,B10000000,B01000000,B00110000,B00000000, 160 | B00000100,B00000010,B00000001,B10000000,B01000000,B00100000,B00000000, 161 | B00000100,B00000010,B00000001,B00000000,B10000000,B01100000,B00000000, 162 | B00001000,B00000100,B00000011,B00000000,B10000000,B01000000,B00000000, 163 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 164 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 165 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 166 | B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000, 167 | B00100000,B00010000,B00001000,B00000110,B00000001,B00000000,B00000000, 168 | B01100000,B00110000,B00001000,B00000100,B00000010,B00000000,B00000000, 169 | B01000000,B00100000,B00010000,B00001100,B00000010,B00000000,B00000000, 170 | B11000000,B01100000,B00010000,B00001000,B00000100,B00000000,B00000000, 171 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 172 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000 173 | }; 174 | 175 | const unsigned char snow[] PROGMEM = { 176 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 177 | B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000, 178 | B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000, 179 | B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000, 180 | B00000000,B00000000,B00010000,B00100000,B01000000,B00000000,B00000000, 181 | B00000000,B00000000,B00011000,B00100000,B11000000,B00000000,B00000000, 182 | B00000000,B00000000,B00000110,B00100001,B10000000,B00000000,B00000000, 183 | B00000000,B00000000,B00000011,B00100110,B00000000,B00000000,B00000000, 184 | B00000000,B00100000,B00000000,B10101100,B00000000,B00100000,B00000000, 185 | B00000000,B00010000,B00000000,B01110000,B00000000,B01100000,B00000000, 186 | B00000000,B00010000,B00000000,B00100000,B00000000,B01000000,B00000000, 187 | B00011100,B00011000,B00000000,B00100000,B00000000,B11000001,B11000000, 188 | B00000011,B00001000,B00000000,B01110000,B00000000,B10000111,B00000000, 189 | B00000000,B11101100,B00000000,B11111000,B00000000,B10111000,B00000000, 190 | B00000000,B00011100,B00000011,B00100110,B00000001,B11000000,B00000000, 191 | B00000000,B11111111,B11111100,B00100001,B11111111,B11111000,B00000000, 192 | B00011111,B00000001,B11100000,B00100000,B00111100,B00000111,B11000000, 193 | B00000000,B00000000,B11011000,B00100000,B11111000,B00000000,B00000000, 194 | B00000000,B00000000,B01000111,B00100011,B00011000,B00000000,B00000000, 195 | B00000000,B00000000,B01000001,B11111100,B00010000,B00000000,B00000000, 196 | B00000000,B00000000,B01000000,B01111000,B00010000,B00000000,B00000000, 197 | B00000000,B00000000,B01000011,B10100110,B00010000,B00000000,B00000000, 198 | B00000000,B00000000,B11011100,B00100001,B11011000,B00000000,B00000000, 199 | B00011100,B00000000,B11100000,B00100000,B00111100,B00000001,B11000000, 200 | B00000011,B11110011,B11111000,B00100000,B11111110,B01111110,B00000000, 201 | B00000000,B00011110,B00000111,B00100011,B10000001,B11000000,B00000000, 202 | B00000000,B01111100,B00000001,B10101100,B00000001,B10110000,B00000000, 203 | B00000001,B10001000,B00000000,B01111000,B00000000,B10001110,B00000000, 204 | B00001110,B00001000,B00000000,B00110000,B00000000,B11000011,B10000000, 205 | B00010000,B00011000,B00000000,B00100000,B00000000,B01000000,B00000000, 206 | B00000000,B00010000,B00000000,B01110000,B00000000,B01100000,B00000000, 207 | B00000000,B00110000,B00000000,B11111000,B00000000,B00100000,B00000000, 208 | B00000000,B00100000,B00000001,B10100110,B00000000,B00100000,B00000000, 209 | B00000000,B00000000,B00000110,B00100011,B00000000,B00000000,B00000000, 210 | B00000000,B00000000,B00001100,B00100001,B10000000,B00000000,B00000000, 211 | B00000000,B00000000,B00010000,B00100000,B01100000,B00000000,B00000000, 212 | B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000, 213 | B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000, 214 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 215 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000 216 | }; 217 | 218 | const unsigned char mist[] PROGMEM = { 219 | B00000000,B00000000,B00000011,B11111000,B00000000,B00000000,B00000000, 220 | B00000000,B00000000,B00001111,B11111111,B10000000,B00000000,B00000000, 221 | B00000000,B00000000,B00111000,B00000011,B11000000,B00000000,B00000000, 222 | B00000000,B00000000,B01110000,B00000000,B01100000,B00000000,B00000000, 223 | B00000000,B00000000,B11000000,B00000000,B00111000,B00000000,B00000000, 224 | B00000000,B00000011,B10000000,B00000000,B00011111,B11110000,B00000000, 225 | B00000000,B00000011,B00000000,B00000000,B00011111,B11111110,B00000000, 226 | B00000000,B00000111,B00000000,B00000000,B00000000,B00001111,B00000000, 227 | B00000000,B11111111,B11000000,B00000000,B00000000,B00000001,B11000000, 228 | B00000111,B11000000,B11111000,B00000000,B00000000,B00000001,B11000000, 229 | B00001111,B00000000,B00111100,B00000000,B00000000,B00000000,B11100000, 230 | B00011000,B00000000,B00001111,B00000000,B00000000,B00000000,B11100000, 231 | B01110000,B00000000,B00000111,B10111100,B00000000,B00000000,B11100000, 232 | B01110000,B00000000,B00000011,B11111111,B11000000,B00000000,B11100000, 233 | B01100000,B00000000,B00000000,B10000001,B11100000,B00000000,B11100000, 234 | B11100000,B00000000,B00000000,B00000000,B00111000,B00000000,B11100000, 235 | B11100000,B00000000,B00000000,B00000000,B00011000,B00000000,B11000000, 236 | B11100000,B00000000,B00000000,B00000000,B00011100,B00000001,B11000000, 237 | B11100000,B00000000,B00000000,B00000000,B00011100,B00000011,B00000000, 238 | B11100000,B00000000,B00000000,B00000000,B00000100,B00011110,B00000000, 239 | B11100000,B00000000,B00000000,B00000000,B00000111,B11111100,B00000000, 240 | B01100000,B00000000,B00000000,B00000000,B00000111,B11000000,B00000000, 241 | B01110000,B00000000,B00000000,B00000000,B00011100,B00000000,B00000000, 242 | B00011000,B00000000,B00000000,B00000000,B00011100,B00000000,B00000000, 243 | B00011110,B00000000,B00000000,B00000000,B00111000,B00000000,B00000000, 244 | B00001111,B00000000,B00000000,B00000000,B01100000,B00000000,B00000000, 245 | B00000001,B11000000,B00000000,B00000011,B11000000,B00000000,B00000000, 246 | B00000000,B11111111,B11111111,B11111111,B10000000,B00000000,B00000000, 247 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 248 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 249 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 250 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 251 | B00000000,B11000011,B11110000,B11111001,B11111000,B01100000,B00000000, 252 | B00000000,B11111111,B11111111,B10111111,B11111111,B11100000,B00000000, 253 | B00000000,B00111100,B00001111,B00011110,B00000111,B10000000,B00000000, 254 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 255 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 256 | B00000000,B11000011,B11110000,B11111001,B11111000,B01100000,B00000000, 257 | B00000000,B11111111,B11111111,B10111111,B11111111,B11100000,B00000000, 258 | B00000000,B00111100,B00001111,B00011110,B00000111,B10000000,B00000000 259 | }; 260 | 261 | const unsigned char clearS[] PROGMEM = { 262 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 263 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 264 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 265 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 266 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 267 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 268 | B00000000,B00000110,B00000000,B01000000,B00001100,B00000000,B00000000, 269 | B00000000,B00000011,B00000000,B01000000,B00011000,B00000000,B00000000, 270 | B00000000,B00000001,B00000000,B01000000,B00010000,B00000000,B00000000, 271 | B00000000,B00000000,B10000000,B10100000,B00100000,B00000000,B00000000, 272 | B00000000,B00000000,B01011111,B00011111,B01000000,B00000000,B00000000, 273 | B00111000,B00000000,B01100000,B00000000,B11100000,B00000001,B10000000, 274 | B00000110,B00000001,B10000000,B00000000,B00011000,B00001100,B00000000, 275 | B00000001,B11000110,B00000000,B00000000,B00001100,B01110000,B00000000, 276 | B00000000,B00101100,B00000000,B00000000,B00000110,B11000000,B00000000, 277 | B00000000,B00001000,B00000000,B00000000,B00000011,B00000000,B00000000, 278 | B00000000,B00010000,B00000000,B00000000,B00000001,B00000000,B00000000, 279 | B00000000,B00110000,B00000000,B00000000,B00000001,B10000000,B00000000, 280 | B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000, 281 | B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000, 282 | B00111111,B11100000,B00000000,B00000000,B00000000,B11111111,B11000000, 283 | B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000, 284 | B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000, 285 | B00000000,B00110000,B00000000,B00000000,B00000001,B10000000,B00000000, 286 | B00000000,B00010000,B00000000,B00000000,B00000001,B00000000,B00000000, 287 | B00000000,B00001000,B00000000,B00000000,B00000011,B00000000,B00000000, 288 | B00000000,B01101100,B00000000,B00000000,B00000110,B11000000,B00000000, 289 | B00000001,B11000110,B00000000,B00000000,B00001100,B01110000,B00000000, 290 | B00001110,B00000001,B10000000,B00000000,B00110000,B00001110,B00000000, 291 | B00110000,B00000000,B01100000,B00000000,B11000000,B00000001,B10000000, 292 | B00000000,B00000000,B01011111,B00011111,B01100000,B00000000,B00000000, 293 | B00000000,B00000000,B10000000,B00000000,B00100000,B00000000,B00000000, 294 | B00000000,B00000001,B00000000,B01000000,B00010000,B00000000,B00000000, 295 | B00000000,B00000011,B00000000,B01000000,B00001000,B00000000,B00000000, 296 | B00000000,B00000110,B00000000,B01000000,B00001100,B00000000,B00000000, 297 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 298 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 299 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 300 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000, 301 | B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000 302 | }; 303 | 304 | const unsigned char clearS1[] PROGMEM = { 305 | B00000000,B00000000,B00000000,B00000000,B00000000, 306 | B00000000,B00000000,B00100000,B00000000,B00000000, 307 | B00000000,B00000000,B00100000,B00000000,B00000000, 308 | B00000000,B00000000,B00100000,B00000000,B00000000, 309 | B00000000,B00000000,B00100000,B00000000,B00000000, 310 | B00000000,B00000000,B00100000,B00000000,B00000000, 311 | B00000000,B00100000,B00100000,B00100000,B00000000, 312 | B00000000,B00100000,B00100000,B01000000,B00000000, 313 | B00000000,B00010000,B00100000,B01000000,B00000000, 314 | B00000000,B00001000,B01110000,B10000000,B00000000, 315 | B00000000,B00001011,B10001111,B10000000,B00000000, 316 | B00110000,B00001100,B00000001,B10000000,B01100000, 317 | B00001100,B00010000,B00000000,B11000001,B10000000, 318 | B00000110,B00100000,B00000000,B00100110,B00000000, 319 | B00000001,B01000000,B00000000,B00111100,B00000000, 320 | B00000000,B01000000,B00000000,B00010000,B00000000, 321 | B00000000,B10000000,B00000000,B00001000,B00000000, 322 | B00000000,B10000000,B00000000,B00001000,B00000000, 323 | B00000000,B10000000,B00000000,B00001000,B00000000, 324 | B00000001,B00000000,B00000000,B00001000,B00000000, 325 | B00111111,B00000000,B00000000,B00001111,B11100000, 326 | B00000001,B00000000,B00000000,B00001000,B00000000, 327 | B00000000,B10000000,B00000000,B00001000,B00000000, 328 | B00000000,B10000000,B00000000,B00001000,B00000000, 329 | B00000000,B10000000,B00000000,B00001000,B00000000, 330 | B00000000,B01000000,B00000000,B00010000,B00000000, 331 | B00000001,B01000000,B00000000,B00111100,B00000000, 332 | B00000110,B00100000,B00000000,B00100010,B00000000, 333 | B00001100,B00010000,B00000000,B11000001,B10000000, 334 | B00110000,B00001100,B00000001,B10000000,B01100000, 335 | B00000000,B00001011,B10001111,B10000000,B00000000, 336 | B00000000,B00011000,B01000000,B10000000,B00000000, 337 | B00000000,B00010000,B00100000,B01000000,B00000000, 338 | B00000000,B00100000,B00100000,B01000000,B00000000, 339 | B00000000,B00100000,B00100000,B00100000,B00000000, 340 | B00000000,B00000000,B00100000,B00000000,B00000000, 341 | B00000000,B00000000,B00100000,B00000000,B00000000, 342 | B00000000,B00000000,B00100000,B00000000,B00000000, 343 | B00000000,B00000000,B00100000,B00000000,B00000000, 344 | B00000000,B00000000,B00100000,B00000000,B00000000 345 | }; 346 | 347 | const unsigned char clouds[] PROGMEM = { 348 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 349 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, 350 | B00000000,B00000000,B01100000,B00000000,B00000000,B00000000,B00000000, 351 | B00000000,B00000011,B11111100,B00000000,B00000000,B00000000,B00000000, 352 | B00000000,B00000111,B00001110,B00001111,B11000000,B00000000,B00000000, 353 | B00000000,B00001100,B00000011,B00011110,B11110000,B00000000,B00000000, 354 | B00000000,B00011000,B00000001,B11110000,B00011000,B00000000,B00000000, 355 | B00000000,B00010000,B00000000,B11000000,B00001100,B00000000,B00000000, 356 | B00000000,B01110000,B00000000,B10000000,B00000110,B00000000,B00000000, 357 | B00000001,B11100000,B00000001,B10000000,B00000011,B00000000,B00000000, 358 | B00000011,B00000000,B00000001,B00000000,B00000001,B00000000,B00000000, 359 | B00000110,B00000000,B00000011,B00000000,B00000001,B11110000,B00000000, 360 | B00000100,B00000000,B00000010,B00000000,B00000000,B10111000,B00000000, 361 | B00001100,B00000000,B01111110,B00000000,B00000000,B00001100,B00000000, 362 | B00001000,B00000000,B11100110,B00000000,B00000000,B00000100,B00000000, 363 | B00001000,B00000001,B10000000,B00000000,B00000000,B00000010,B00000000, 364 | B00001000,B00000011,B00000000,B00000000,B00000000,B00000010,B00000000, 365 | B00000100,B00000010,B00000000,B00000000,B00000000,B00000010,B00000000, 366 | B00001100,B00000100,B00000000,B00000000,B00000000,B00000011,B00000000, 367 | B00011000,B00000100,B00000000,B00000000,B00000000,B00000011,B00000000, 368 | B00010000,B00011100,B00000000,B00000000,B00000000,B00000010,B00000000, 369 | B00010000,B01111100,B00000000,B00000000,B00000000,B00000010,B00000000, 370 | B00110000,B11000000,B00000000,B00000000,B00000000,B00000011,B00000000, 371 | B00110001,B10000000,B00000000,B00000000,B00000000,B00000001,B00000000, 372 | B00110001,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000, 373 | B00010011,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000, 374 | B00010010,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000, 375 | B00011010,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000, 376 | B00001110,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000, 377 | B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000, 378 | B00000010,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000, 379 | B00000011,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000, 380 | B00000001,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000, 381 | B00000001,B10000000,B00000000,B00000000,B00000000,B00000001,B00000000, 382 | B00000000,B11000000,B00000000,B00000000,B00000000,B00000011,B00000000, 383 | B00000000,B01111111,B11111111,B11111111,B11111111,B11111110,B00000000, 384 | B00000000,B00011111,B11111111,B11111111,B11111111,B11111000,B00000000, 385 | B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000 386 | }; 387 | 388 | 389 | const unsigned char weather1[] PROGMEM = { 390 | B00000000,B00000000,B00000000,B00000000,B00000000, 391 | B00000000,B00000000,B00011111,B11000000,B00000000, 392 | B00000000,B00000000,B01100000,B01100000,B00000000, 393 | B00000000,B00000000,B10000000,B00010000,B00000000, 394 | B00000000,B00000001,B00000000,B00001000,B00000000, 395 | B00000000,B00000011,B00000000,B00000111,B00000000, 396 | B00000000,B00000010,B00000000,B00000000,B11000000, 397 | B00000000,B01111110,B00000000,B00000000,B01100000, 398 | B00000000,B10000000,B00000000,B00000000,B00110000, 399 | B00000001,B00000000,B00000000,B00000000,B00010000, 400 | B00000011,B00000000,B00000000,B00000000,B00010000, 401 | B00000110,B00000000,B00000000,B00000000,B00010000, 402 | B00011100,B00000000,B00000000,B00000000,B00010000, 403 | B00100000,B00000000,B00000000,B00000000,B00011000, 404 | B01000000,B00000000,B00000000,B00000000,B00001000, 405 | B01000000,B00000000,B00000000,B00000000,B00000100, 406 | B11000000,B00000000,B00000000,B00000000,B00000100, 407 | B01000000,B00000000,B00000000,B00000000,B00000100, 408 | B01000000,B00000000,B00000000,B00000000,B00001100, 409 | B01000000,B00000000,B00000000,B00000000,B00001000, 410 | B00100000,B00000000,B00000000,B00000000,B00010000, 411 | B00011111,B11111111,B11111111,B11111111,B11100000, 412 | B00000000,B00000000,B00000000,B00000000,B00000000, 413 | B00000000,B00000000,B00000000,B00000000,B00000000 414 | }; 415 | 416 | 417 | String main=""; 418 | String desc=""; 419 | float temp=0; 420 | uint16_t pres=0; 421 | uint8_t humidity=0; 422 | float wind=0; 423 | int tempF=0; 424 | 425 | int tempMin1=100; 426 | int tempMin2=100; 427 | int tempMin3=100; 428 | int tempMin4=100; 429 | int tempMax1=0; 430 | int tempMax2=0; 431 | int tempMax3=0; 432 | int tempMax4=0; 433 | int humidity1=0; 434 | int humidity2=0; 435 | int humidity3=0; 436 | int humidity4=0; 437 | int cnt=0; 438 | String date1=""; 439 | String date=""; 440 | String country=""; 441 | 442 | 443 | int getD=-1; 444 | int getH=-1; 445 | int getM=-1; 446 | int getS=-1; 447 | String fDate=""; 448 | String dayName=""; 449 | WiFiClient wifiClient; 450 | 451 | void connectWifi() { 452 | WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 453 | Serial.print("Connecting to "); 454 | Serial.println(WIFI_SSID); 455 | while (WiFi.status() != WL_CONNECTED) { 456 | delay(500); 457 | Serial.print("."); 458 | } 459 | Serial.println(""); 460 | Serial.println("WiFi connected!"); 461 | Serial.println(WiFi.localIP()); 462 | Serial.println(); 463 | } 464 | 465 | void initScreen() 466 | { 467 | tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab 468 | //tft.setRotation(1); 469 | tft.fillScreen(ST7735_BLACK); 470 | //layout 471 | tft.drawFastHLine(0, 0, tft.width(), ST7735_WHITE); 472 | tft.drawFastHLine(1, 159, tft.width(), ST7735_WHITE); 473 | tft.drawFastVLine(0, 0, tft.height(), ST7735_WHITE); 474 | tft.drawFastVLine(127, 0, tft.height(), ST7735_WHITE); 475 | tft.drawFastHLine(1, 140, tft.width(), ST7735_WHITE); 476 | tft.drawFastHLine(1, 19, tft.width(), ST7735_WHITE); 477 | } 478 | void setup() { 479 | Serial.begin(9600); 480 | delay(500); 481 | connectWifi(); 482 | timeClient.begin(); 483 | getTime(); 484 | getForecastData(); 485 | //delay(10000); 486 | initScreen(); 487 | } 488 | 489 | void loop() { 490 | // put your main code here, to run repeatedly: 491 | getTime(); 492 | screen1(); 493 | delay(10000); 494 | getCurrentData(); 495 | screen2(); 496 | delay(10000); 497 | getForecastData(); 498 | screen3(); 499 | delay(10000); 500 | } 501 | 502 | void getTime() 503 | { 504 | timeClient.update(); 505 | getD=timeClient.getDay(); 506 | getH=timeClient.getHours(); 507 | getM=timeClient.getMinutes(); 508 | getS=timeClient.getSeconds(); 509 | fDate=timeClient.getFormattedTime(); 510 | dayName=daysOfTheWeek[getD]; 511 | Serial.print(getD); 512 | Serial.print(dayName); 513 | Serial.print(", "); 514 | Serial.print(getH); 515 | Serial.print(":"); 516 | Serial.print(getM); 517 | Serial.print(":"); 518 | Serial.println(getS); 519 | Serial.println(timeClient.getFormattedTime()); 520 | } 521 | 522 | void getCurrentData() 523 | { 524 | OpenWeatherMapCurrentData data; 525 | client.setLanguage(OPEN_WEATHER_MAP_LANGUAGE); 526 | client.setMetric(IS_METRIC); 527 | client.updateCurrent(&data, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION); 528 | 529 | main=data.main.c_str(); 530 | desc=data.description.c_str(); 531 | temp=data.temp; 532 | tempF=(int)(temp); 533 | pres=data.pressure; 534 | humidity=data.humidity; 535 | wind=data.windSpeed; 536 | Serial.println("main: "+ main); 537 | Serial.println("description: "+ desc); 538 | Serial.printf("temp: %f\n", temp); 539 | Serial.printf("pressure: %d\n", pres); 540 | Serial.printf("humidity: %d\n", humidity); 541 | Serial.printf("windSpeed: %f\n", wind); 542 | 543 | } 544 | 545 | void getForecastData() 546 | { 547 | String serverPath = "http://api.openweathermap.org/data/2.5/forecast?q=" + OPEN_WEATHER_MAP_LOCATION + "&appid=" + OPEN_WEATHER_MAP_APP_ID + "&units=metric&lang=" + OPEN_WEATHER_MAP_LANGUAGE; 548 | String json = httpGETRequest(serverPath.c_str()); 549 | //updateForecastData(json); 550 | tempMin1=100; 551 | tempMin2=100; 552 | tempMin3=100; 553 | tempMin4=100; 554 | tempMax1=0; 555 | tempMax2=0; 556 | tempMax3=0; 557 | tempMax4=0; 558 | humidity1=0; 559 | humidity2=0; 560 | humidity3=0; 561 | humidity4=0; 562 | int t=-1; 563 | t=json.indexOf("dt"); 564 | json=json.substring(t+3,json.length()); 565 | t=-1; 566 | t=json.indexOf("country"); 567 | country=json.substring(t+10,t+12); 568 | t=-1; 569 | date1=""; 570 | t=json.indexOf("dt_txt"); 571 | date1=json.substring(t+9,t+19); 572 | if(cnt==0) 573 | { 574 | date=date1; 575 | cnt++; 576 | } 577 | int tc=json.substring(t+20,t+22).toInt(); 578 | t=-1; 579 | tc=(((tc*(-1))+21)/3)+1; 580 | for(int i=0;itemp) 590 | tempMin1=temp; 591 | t=-1; 592 | t=s.indexOf("temp_max"); 593 | temp=s.substring(t+10,t+12).toInt(); 594 | if(tempMax1temp) 613 | tempMin2=temp; 614 | t=-1; 615 | t=s.indexOf("temp_max"); 616 | temp=s.substring(t+10,t+12).toInt(); 617 | if(tempMax2temp) 636 | tempMin3=temp; 637 | t=-1; 638 | t=s.indexOf("temp_max"); 639 | temp=s.substring(t+10,t+12).toInt(); 640 | if(tempMax3temp) 659 | tempMin4=temp; 660 | t=-1; 661 | t=s.indexOf("temp_max"); 662 | temp=s.substring(t+10,t+12).toInt(); 663 | if(tempMax40) { 696 | Serial.print("HTTP Response code: "); 697 | Serial.println(httpResponseCode); 698 | payload = http.getString(); 699 | } 700 | else { 701 | Serial.print("Error code: "); 702 | Serial.println(httpResponseCode); 703 | } 704 | http.end(); 705 | 706 | return payload; 707 | } 708 | 709 | void screen1() 710 | { 711 | tft.setFont(); 712 | tft.setTextColor(ST7735_WHITE); 713 | tft.setCursor(10,7); 714 | tft.print(OPEN_WEATHER_MAP_LOCATION); 715 | tft.setCursor(110,7); 716 | tft.print(country); 717 | tft.fillRect(3, 142 , 123, 16, ST7735_BLACK); 718 | tft.setCursor(10,146); 719 | if(getH<10) 720 | tft.print(0); 721 | tft.print(getH); 722 | tft.print(":"); 723 | if(getM<10) 724 | tft.print(0); 725 | tft.print(getM); 726 | tft.setCursor(60,146); 727 | tft.print(date); 728 | tft.fillRect(3, 22 , 123, 116, ST7735_BLACK); 729 | tft.setFont(&FreeSansBold18pt7b); 730 | //tft.setTextColor(ST7735_WHITE); 731 | tft.setTextSize(1); 732 | tft.setCursor(22,60); 733 | tft.setTextColor(colors[2]); 734 | if(getH<10) 735 | tft.print(0); 736 | tft.print(getH); 737 | tft.print(":"); 738 | if(getM<10) 739 | tft.print(0); 740 | tft.print(getM); 741 | tft.setFont(&FreeSans9pt7b); 742 | int daylen=0; 743 | daylen=dayName.length(); 744 | if(daylen==6) 745 | tft.setCursor(35,90); 746 | else if (daylen==7) 747 | tft.setCursor(27,90); 748 | else if (daylen==8) 749 | tft.setCursor(21,90); 750 | else if (daylen==9) 751 | tft.setCursor(15,90); 752 | tft.setTextColor(colors[getD]); 753 | tft.print(dayName); 754 | tft.setTextColor(ST7735_WHITE); 755 | tft.setCursor(19,120); 756 | tft.print(date); 757 | } 758 | 759 | void screen2() 760 | { 761 | tft.fillRect(3, 22 , 123, 116, ST7735_BLACK); 762 | //tft.drawBitmap(8, 25, clouds, 51, 38,ST7735_WHITE); 763 | displayweatherbitmap_screen2(); 764 | tft.setFont(&FreeSansBold9pt7b); 765 | tft.setTextColor(ST7735_WHITE); 766 | //tft.setTextColor(ST7735_WHITE); 767 | tft.setTextSize(1); 768 | tft.setCursor(2,80); 769 | tft.setTextColor(col); 770 | tft.print(main); 771 | tft.setCursor(64,50); 772 | // int range = map(tempF, 0, 60, 0, 6); 773 | // tft.setTextColor(colors[range]); 774 | if(tempF<=0) 775 | { 776 | tft.setTextColor(0x07FF); 777 | } 778 | else if(tempF>0 && tempF<5) 779 | { 780 | tft.setTextColor(0x03DF); 781 | } 782 | else if(tempF>6 && tempF<16) 783 | { 784 | tft.setTextColor(0x87E0); 785 | } 786 | else if(tempF>16 && tempF<27) 787 | { 788 | tft.setTextColor(0xFC00); 789 | } 790 | else if(tempF>27 && tempF<37) 791 | { 792 | tft.setTextColor(0xFA20); 793 | } 794 | else 795 | { 796 | tft.setTextColor(0xF800); 797 | } 798 | tft.print(tempF); 799 | tft.setFont(); 800 | tft.setCursor(87,35); 801 | tft.print("C"); 802 | 803 | tft.setTextColor(ST7735_WHITE); 804 | if(humidity<10) 805 | { 806 | tft.setTextColor(0x04E0); 807 | } 808 | else if(humidity<20 && humidity>10) 809 | { 810 | tft.setTextColor(0x87E0); 811 | } 812 | else if(humidity<30 && humidity>20) 813 | { 814 | tft.setTextColor(0xFFE0); 815 | } 816 | else if(humidity<40 && humidity>30) 817 | { 818 | tft.setTextColor(0xFB20); 819 | } 820 | else if(humidity>40) 821 | { 822 | tft.setTextColor(0xF800); 823 | } 824 | tft.setFont(&FreeSansBold9pt7b); 825 | tft.setCursor(94,50); 826 | tft.print(humidity); 827 | tft.setFont(); 828 | tft.setCursor(118,35); 829 | tft.print("%"); 830 | tft.setCursor(4,85); 831 | tft.setTextColor(col); 832 | String s=desc; 833 | String s1=""; 834 | String s2=""; 835 | if(s.length()>20) 836 | { 837 | char c[s.length()]; 838 | s.toCharArray(c,s.length()); 839 | for(int i=20;i>0;i--) 840 | { 841 | if(c[i]==' ') 842 | { 843 | s1=s.substring(0,i+1); 844 | int j=20-i; 845 | for(int k=0;k6) 876 | day2=day2-7; 877 | int day3=day2+1; 878 | if(day3>6) 879 | day3=day3-7; 880 | int day4=day3+1; 881 | if(day4>6) 882 | day4=day4-7; 883 | tft.fillRect(2, 22 , 124, 116, ST7735_BLACK); 884 | tft.drawBitmap(8, 28, weather1, 39, 24,colors[day2]); 885 | tft.drawBitmap(8, 68, weather1, 39, 24,colors[day3]); 886 | tft.drawBitmap(8, 108, weather1, 39, 24,colors[day4]); 887 | tft.setFont(); 888 | tft.setTextColor(colors[day2]); 889 | tft.setCursor(65,25); 890 | tft.print(daysOfTheWeek[day2]); 891 | tft.setCursor(97,38); 892 | tft.print("C"); 893 | tft.setCursor(105,44); 894 | tft.print(humidity2); 895 | tft.print("%"); 896 | tft.setFont(&FreeSansBold9pt7b); 897 | tft.setCursor(50,50); 898 | tft.print(tempMin2); 899 | tft.print("/"); 900 | tft.print(tempMax2); 901 | tft.setFont(); 902 | tft.setTextColor(colors[day3]); 903 | tft.setCursor(65,65); 904 | tft.print(daysOfTheWeek[day3]); 905 | tft.setCursor(97,78); 906 | tft.print("C"); 907 | tft.setCursor(105,84); 908 | tft.print(humidity3); 909 | tft.print("%"); 910 | tft.setFont(&FreeSansBold9pt7b); 911 | tft.setCursor(50,90); 912 | tft.print(tempMin3); 913 | tft.print("/"); 914 | tft.print(tempMax3); 915 | tft.setFont(); 916 | tft.setTextColor(colors[day4]); 917 | tft.setCursor(65,105); 918 | tft.print(daysOfTheWeek[day4]); 919 | tft.setCursor(97,118); 920 | tft.print("C"); 921 | tft.setCursor(105,124); 922 | tft.print(humidity4); 923 | tft.print("%"); 924 | tft.setFont(&FreeSansBold9pt7b); 925 | tft.setCursor(50,130); 926 | tft.print(tempMin4); 927 | tft.print("/"); 928 | tft.print(tempMax4); 929 | } 930 | 931 | void displayweatherbitmap_screen2() 932 | { 933 | if(main.equals("Clouds")) 934 | { 935 | col=0xFFE0; 936 | tft.drawBitmap(8, 25, clouds, 51, 38,0xFFE0); 937 | } 938 | else if(main.equals("Rain")) 939 | { 940 | col=0x07FF; 941 | tft.drawBitmap(8, 25, rain, 51, 40,0x07FF); 942 | } 943 | else if(main.equals("Thunderstorm")) 944 | { 945 | col=0x03DF; 946 | tft.drawBitmap(8, 25, thunder, 51, 40,0x03DF); 947 | } 948 | else if(main.equals("Clear")) 949 | { 950 | col=0xFFE0; 951 | tft.drawBitmap(8, 25, clearS1, 37, 40,0xFFE0); 952 | } 953 | else if(main.equals("Drizzle")) 954 | { 955 | col=0x07FF; 956 | tft.drawBitmap(8, 25, drizzle, 51, 40,0x07FF); 957 | } 958 | else if(main.equals("Snow")) 959 | { 960 | col=ST7735_WHITE; 961 | tft.drawBitmap(8, 25, snow, 51, 40,ST7735_WHITE); 962 | } 963 | else 964 | { 965 | col=0xD6D5; 966 | tft.drawBitmap(8, 25, mist, 51, 40,0xD6D5); 967 | } 968 | } 969 | --------------------------------------------------------------------------------