· 6 years ago · Nov 26, 2019, 05:36 PM
1#include <U8glib.h> //bitmap graphics library
2#include <ESP8266WiFi.h> //wifi library
3#include <Wire.h> //I2C library
4#include <Adafruit_SSD1306.h> //oled driver
5#include "ArduinoJson-v5.13.5.h" //json library
6
7
8/**
9 * Made with Marlin Bitmap Converter
10 * http://marlinfw.org/tools/u8glib/converter.html
11 *
12 * This bitmap from the file 'cloud-outline.png'
13 */
14
15#pragma once
16#define CLOUD_BMPWIDTH 64
17#define CLOUD_BMPHEIGHT 23
18const unsigned char bitmap_cloud[] PROGMEM = {
19 B00000000,B00000000,B00000000,B00000000,B11111111,B00000000,B00000000,B00000000,
20 B00000000,B00000000,B00000000,B00000001,B11111111,B10000000,B00000000,B00000000,
21 B00000000,B00000000,B00000000,B00011111,B11111111,B11110000,B00000000,B00000000,
22 B00000000,B00000000,B00000000,B11111111,B11111111,B11111110,B00000000,B00000000,
23 B00000000,B00000000,B00000001,B11111110,B00000000,B01111111,B10000000,B00000000,
24 B00000000,B00000000,B11111111,B11110000,B00000000,B00001111,B11100000,B00000000,
25 B00000000,B00000111,B11111111,B11000000,B00000000,B00000011,B11110000,B00000000,
26 B00000000,B00011111,B11111111,B00000000,B00000000,B00000001,B11111000,B00000000,
27 B00000000,B01111111,B00000000,B00000000,B00000000,B00000001,B11111000,B00000000,
28 B00000000,B11111110,B00000000,B00000000,B00000000,B00000001,B11111100,B00000000,
29 B00000011,B11111100,B00000000,B00000000,B00000000,B00000001,B11111111,B11100000,
30 B00011111,B11111100,B00000000,B00000000,B00000000,B00000001,B11111111,B11111000,
31 B01111111,B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,
32 B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
33 B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
34 B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
35 B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
36 B11111100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
37 B11111111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01111111,
38 B00111111,B11000000,B00000000,B00000000,B00000000,B00000000,B00000011,B11111110,
39 B00001111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11110000,
40 B00000001,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11000000,
41 B00000000,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B00000000
42};
43
44/**
45 * Made with Marlin Bitmap Converter
46 * http://marlinfw.org/tools/u8glib/converter.html
47 *
48 * This bitmap from the file 'clouds with sun.png'
49 */
50
51#pragma once
52#define CLOSUN_BMPWIDTH 64
53#define CLOSUN_BMPHEIGHT 23
54const unsigned char bitmap_clo_sun[] PROGMEM = {
55 B00000000,B00000000,B00000000,B00000000,B00000011,B10000000,B00000000,B00000000,
56 B00000000,B00000000,B00000000,B00000000,B00000011,B10000000,B00011000,B00000000,
57 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01110000,B00000000,
58 B00000000,B00000000,B00000000,B00111100,B00001111,B11111111,B00000000,B00000000,
59 B00000000,B00000000,B00000000,B00000110,B01111000,B00000011,B11100000,B00000000,
60 B00000000,B00000000,B00000000,B00000000,B11100000,B00000000,B01110000,B00000000,
61 B00000000,B00000000,B00000111,B11111111,B11000000,B00000000,B00111000,B11111000,
62 B00000000,B00000000,B00011110,B00000000,B11111000,B00000000,B00011000,B11100000,
63 B00000000,B00000000,B01110000,B00000000,B00001110,B00000000,B00011000,B00000000,
64 B00000000,B00000001,B11000000,B00000000,B00000111,B00000000,B00011000,B00000000,
65 B00000000,B00000011,B10000000,B00000000,B00000011,B10000000,B00110000,B00000000,
66 B00000000,B00000011,B10000000,B00000000,B00000001,B11111111,B11100000,B00000000,
67 B00000000,B00000011,B00000000,B00000000,B00000000,B00000000,B11100111,B10000000,
68 B00000000,B11111111,B00000000,B00000000,B00000000,B00000000,B01110001,B10000000,
69 B00000111,B10000000,B00000000,B00000000,B00000000,B00000000,B01110000,B00000000,
70 B00001110,B00000000,B00000000,B00000000,B00000000,B00000000,B01111111,B00000000,
71 B00001100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11000000,
72 B00011100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11100000,
73 B00001100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01100000,
74 B00001110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01100000,
75 B00000111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11000000,
76 B00000001,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B10000000,
77 B00000000,B00011111,B11111111,B11111111,B11111111,B11111111,B11111000,B00000000
78};
79
80/**
81 * Made with Marlin Bitmap Converter
82 * http://marlinfw.org/tools/u8glib/converter.html
83 *
84 * This bitmap from the file 'rain.png'
85 */
86
87#pragma once
88#define RAIN_BMPWIDTH 64
89#define RAIN_BMPHEIGHT 23
90const unsigned char bitmap_rain[] PROGMEM = {
91
92 B00000000,B00000000,B00000111,B11100000,B00000000,B00000000,B00000000,B00000000,
93 B00000000,B00000001,B11111111,B11111111,B10000000,B00000000,B00000000,B00000000,
94 B00000000,B00001111,B11110000,B00001111,B11110000,B00000000,B00000000,B00000000,
95 B00000000,B00111111,B00000000,B00000000,B11111100,B00000000,B00000000,B00000000,
96 B00000000,B01111000,B00000000,B00000000,B00111111,B11111110,B00000000,B00000000,
97 B00000001,B11110000,B00000000,B00000000,B00001111,B11111111,B11100000,B00000000,
98 B00000001,B11100000,B00000000,B00000000,B00000110,B00000001,B11111000,B00000000,
99 B00000011,B11000000,B00000000,B00000000,B00000000,B00000000,B00111110,B00000000,
100 B00000011,B11000000,B00000000,B00000000,B00000000,B00000000,B00011111,B10000000,
101 B00011111,B11000000,B00000000,B00000000,B00000000,B00000000,B00001111,B11111000,
102 B00111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01111100,
103 B01111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011110,
104 B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00001111,
105 B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00001111,
106 B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00001111,
107 B01111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011110,
108 B00111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01111100,
109 B00001111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11110000,
110 B00000001,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B10000000,
111 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
112 B00000000,B00000011,B11000000,B00000011,B11000000,B00000011,B11000000,B00000000,
113 B00000000,B00000011,B11000000,B00000011,B11000000,B00000011,B11000000,B00000000,
114 B00000000,B00000011,B11000011,B11000011,B11000011,B11000011,B11000000,B00000000,
115
116
117};
118
119/**
120 * Made with Marlin Bitmap Converter
121 * http://marlinfw.org/tools/u8glib/converter.html
122 *
123 * This bitmap from the file 'sun.jpg'
124 */
125
126#pragma once
127#define CLEAR_BMPWIDTH 40
128#define CLEAR_BMPHEIGHT 23
129const unsigned char bitmap_clear[] PROGMEM = {
130 B00000000,B00000000,B00011000,B00000000,B00000000,
131 B00000000,B00000000,B00011000,B00000000,B00000000,
132 B00000000,B00000000,B00011000,B00000000,B10000000,
133 B00000001,B11000000,B00000000,B00000011,B10000000,
134 B00000000,B11100000,B00000000,B00000111,B00000000,
135 B00000000,B00110000,B11111111,B10000100,B00000000,
136 B00000000,B00000111,B11111111,B11100000,B00000000,
137 B00000000,B00001111,B11111111,B11110000,B00000000,
138 B00000000,B00011111,B11111111,B11111000,B00000000,
139 B00000000,B00011111,B11111111,B11111000,B00000000,
140 B00000000,B00111111,B11111111,B11111100,B00000000,
141 B00011111,B00111111,B11111111,B11111100,B11111000,
142 B00001010,B00111111,B11111111,B11111100,B01010000,
143 B00000000,B00011111,B11111111,B11111100,B00000000,
144 B00000000,B00011111,B11111111,B11111000,B00000000,
145 B00000000,B00001111,B11111111,B11110000,B00000000,
146 B00000000,B00000111,B11111111,B11100000,B00000000,
147 B00000000,B00110011,B11111111,B11000000,B00000000,
148 B00000000,B01110000,B01111110,B00001110,B00000000,
149 B00000000,B11100000,B00000000,B00000111,B00000000,
150 B00000000,B00000000,B00000000,B00000001,B00000000,
151 B00000000,B00000000,B00011000,B00000000,B00000000,
152 B00000000,B00000000,B00011000,B00000000,B00000000
153};
154
155/**
156 * Made with Marlin Bitmap Converter
157 * http://marlinfw.org/tools/u8glib/converter.html
158 *
159 * This bitmap from the file '428-200.png'
160 */
161
162#pragma once
163#define THUND_BMPWIDTH 64
164#define THUND_BMPHEIGHT 23
165const unsigned char bitmap_thund[] PROGMEM = {
166 B00000000,B00000000,B00000111,B11111111,B11111000,B00000000,B00000000,B00000000,
167 B00000000,B00000000,B00011111,B11111111,B11111111,B00000000,B00000000,B00000000,
168 B00000000,B00000000,B01111111,B11000000,B01111111,B11000000,B00000000,B00000000,
169 B00000000,B00000001,B11111100,B00000000,B00001111,B11111111,B11111111,B10000000,
170 B00000000,B00000011,B11111000,B00000000,B00000011,B11111111,B11111111,B11100000,
171 B00000000,B00000011,B11110000,B00000000,B00000001,B11111111,B11111111,B11111000,
172 B00000000,B00001111,B11100000,B00000000,B00000001,B11110000,B00000000,B11111110,
173 B00000000,B11111111,B11100000,B00000000,B00000000,B11000000,B00000000,B01111111,
174 B00000011,B11111111,B11110000,B00000000,B00000000,B00000000,B00000000,B00111111,
175 B00001111,B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
176 B00111111,B11000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
177 B11111111,B11000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
178 B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111110,
179 B11111100,B00000000,B00000000,B00000000,B00000000,B00000000,B00001111,B11111100,
180 B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11110000,
181 B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B10000000,
182 B00000000,B00000000,B00000000,B11111111,B11100000,B00000000,B00000000,B00000000,
183 B00000000,B00000000,B00000001,B11111111,B11111100,B00000000,B00000000,B00000000,
184 B00000000,B00000000,B00000011,B11111111,B11111100,B00000000,B00000000,B00000000,
185 B00000000,B00000000,B00000000,B01111111,B11000000,B00000000,B00000000,B00000000,
186 B00000000,B00000000,B00000000,B11111110,B00000000,B00000000,B00000000,B00000000,
187 B00000000,B00000000,B00000011,B11110000,B00000000,B00000000,B00000000,B00000000,
188 B00000000,B00000000,B00000111,B10000000,B00000000,B00000000,B00000000,B00000000
189};
190
191/**
192 * Made with Marlin Bitmap Converter
193 * http://marlinfw.org/tools/u8glib/converter.html
194 *
195 * This bitmap from the file 'mist_729278.png'
196 */
197
198#pragma once
199#define MIST_BMPWIDTH 64
200#define MIST_BMPHEIGHT 19
201const unsigned char bitmap_mist[] PROGMEM = {
202 B00000000,B00000000,B01110000,B11111111,B11111111,B11110000,B01110000,B00000000,
203 B00000000,B00000000,B11110000,B11111111,B11111111,B11111000,B11110000,B00000000,
204 B00000000,B00000000,B01100000,B01111111,B11111111,B11100000,B01100000,B00000000,
205 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
206 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
207 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
208 B00000011,B11000001,B11111111,B11111111,B11000011,B11000001,B11111111,B11110000,
209 B00000011,B11000001,B11111111,B11111111,B11000011,B11000001,B11111111,B11110000,
210 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
211 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
212 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
213 B00000011,B11111111,B11110000,B11110000,B11111111,B11111111,B11110000,B11110000,
214 B00000011,B11111111,B11110000,B11110000,B11111111,B11111111,B11110000,B11110000,
215 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
216 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
217 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
218 B00000000,B00000000,B00100000,B00011111,B11111111,B11100000,B00100000,B00000000,
219 B00000000,B00000000,B11110000,B01111111,B11111111,B11111000,B11110000,B00000000,
220 B00000000,B00000000,B01110000,B01111111,B11111111,B11110000,B11110000,B00000000
221};
222/**
223 * Made with Marlin Bitmap Converter
224 * http://marlinfw.org/tools/u8glib/converter.html
225 *
226 * This bitmap from the file 'snowflake.png'
227 */
228
229#pragma once
230#define SNOW_BMPWIDTH 35
231#define SNOW_BMPHEIGHT 23
232const unsigned char bitmap_snow[] PROGMEM = {
233 B00000000,B00000000,B00000000,B00000000,
234 B00000000,B00000000,B01000000,B00000000,
235 B00000000,B00000110,B11101100,B00000000,
236 B00000000,B00000111,B11111100,B00000000,
237 B00000000,B00000000,B11110000,B00000000,
238 B00000001,B10000000,B11100000,B00110000,
239 B00001101,B10001110,B11101110,B00110110,
240 B00000111,B10001111,B11111110,B00111100,
241 B00000111,B11111100,B11100111,B11111100,
242 B00001100,B00111100,B11100111,B10000110,
243 B00000000,B00111111,B11111111,B11000000,
244 B00000001,B11100011,B11111000,B11110000,
245 B00000000,B01111111,B11111111,B11000000,
246 B00001100,B00111100,B11100111,B10000110,
247 B00000111,B11111100,B11100111,B11111100,
248 B00000111,B10001111,B11111110,B00111100,
249 B00001101,B10001110,B11101110,B00110110,
250 B00000001,B10000000,B11100000,B00110000,
251 B00000000,B00000000,B11100000,B00000000,
252 B00000000,B00000111,B11111100,B00000000,
253 B00000000,B00000110,B11101100,B00000000,
254 B00000000,B00000000,B01000000,B00000000,
255 B00000000,B00000000,B00000000,B00000000
256};
257
258
259
260Adafruit_SSD1306 display(LED_BUILTIN); //create instance of SSD1306 called display
261
262const char* ssid = "P10"; // SSID of local network
263const char* password = "5769124M"; // Password on network
264String APIKEY = "64d0f7abb745d7c879b5dcd3beea87fe"; //openweathermap.org api key
265String CityID = "2650752"; //my city id
266
267
268
269WiFiClient client; //start wifi client
270char servername[]="api.openweathermap.org"; //specify server name
271
272String result; //string var to hold result
273
274int counter = 60; //counter var
275
276String weatherMain ="";
277String weatherDescription =""; //empty string to hold descrip
278String weatherLocation = ""; //empty string to hold location
279String Country; //dl'd var for country
280float Temperature; //dl'd var for temp
281float Humidity; //dl'd var for humidity
282float Pressure; //dl'd var for pressure
283
284
285void setup() {
286
287 Serial.begin(38400); //start serial comms for debug
288
289 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //start the OLED @ Hex addy 0x3C
290 display.display(); //show the Adafruit Logo
291 delay(2); //for 2 milli seconds
292 display.clearDisplay(); //clear display @ beginning of each loop
293 display.setTextSize(1); //set smallest text size
294 display.setTextColor(WHITE); //set text color to WHITE
295 display.setCursor(0,0); //cursor to upper left
296 display.print("Connecting"); //setup info
297 Serial.println("Connecting"); //setup info
298 WiFi.begin(ssid, password);
299 while (WiFi.status() != WL_CONNECTED)
300 {
301 delay(500);
302 Serial.print("*");
303 }
304
305
306 display.display(); //show display
307 delay(1000); //wait
308 display.clearDisplay(); //clear display
309 display.print("Connected!"); //show info
310 Serial.println("Connected"); //show info
311 delay(1000); //wait
312 display.display(); //show display
313 delay(1000); //wait
314 display.clearDisplay(); //clear display
315
316}
317
318void loop() {
319
320 if(counter == 60) //Get new data every 10 minutes
321 {
322 counter = 0; //reset counter
323 displayGettingData(); //callfunction
324 delay(1000); //wait
325 getWeatherData(); //call function
326 }else //otherwise
327 {
328 counter++; //increment counter
329
330 if(weatherMain == "Clear"){
331 displayWeatherClear(Temperature, weatherDescription); //call function
332 }
333 else if (weatherDescription == "few clouds"){
334 displayWeatherCloSun(Temperature, weatherDescription);
335 }
336 else if (weatherMain == "Clouds"){
337 displayWeatherCloud(Temperature, weatherDescription); //call function
338 }
339 else if (weatherMain == "Rain" || weatherMain == "Drizzle"){
340 displayWeatherRain(Temperature, weatherDescription);
341 }
342 else if (weatherMain == "Thunder"){
343 displayWeatherThund(Temperature, weatherDescription);
344 }
345 else if (weatherMain == "Mist" || weatherMain == "Smoke" || weatherMain == "Haze" || weatherMain == "Dust" || weatherMain == "Fog" || weatherMain == "Squall"){
346 displayWeatherMist(Temperature, weatherDescription);
347 }
348 else if (weatherMain == "Snow"){
349 displayWeatherSnow(Temperature, weatherDescription);
350 };
351
352 delay(5000); //wait
353 displayConditions( weatherLocation, Humidity, Pressure); //callfunction
354 delay(5000); //wait
355 }
356}
357
358void getWeatherData() //client function to send/receive GET request data.
359{
360 if (client.connect(servername, 80)) { //starts client connection, checks for connection
361 client.println("GET /data/2.5/weather?id="+CityID+"&units=metric&APPID="+APIKEY);
362 client.println("Host: api.openweathermap.org");
363 client.println("User-Agent: ArduinoWiFi/1.1");
364 client.println("Connection: close");
365 client.println();
366 }
367 else {
368 Serial.println("connection failed"); //error message if no client connect
369 Serial.println();
370 }
371
372 while(client.connected() && !client.available()) delay(1); //waits for data
373 while (client.connected() || client.available()) { //connected or data available
374 char c = client.read(); //gets byte from ethernet buffer
375 result = result+c;
376 }
377
378 client.stop(); //stop client
379 result.replace('[', ' ');
380 result.replace(']', ' ');
381 Serial.println(result);
382
383Serial.println(result);
384StaticJsonBuffer<1024> json_buf;
385JsonObject &root = json_buf.parseObject(result.c_str());
386
387if (!root.success())
388{
389 Serial.println("parseObject() failed");
390}
391
392String location = root["name"];
393String country = root["sys"]["country"];
394float temperature = root["main"]["temp"];
395float humidity = root["main"]["humidity"];
396String weather = root["weather"]["main"];
397String description = root["weather"]["description"];
398float pressure = root["main"]["pressure"];
399
400weatherMain = weather;
401weatherDescription = description;
402weatherLocation = location;
403Country = country;
404Temperature = temperature;
405Humidity = humidity;
406Pressure = pressure;
407
408}
409
410void displayWeatherCloud(float Temperature, String description) //show location & weather function
411{
412 display.clearDisplay();
413 display.drawBitmap(0, 0, bitmap_cloud, 64, 23, WHITE);
414 display.display();
415 display.setCursor(70,0);
416 display.setTextSize(2);
417 display.print(Temperature,1);
418 //display.print((char)223);
419 display.println("C");
420 display.display();
421 display.setTextSize(0.5);
422 display.setCursor(0,25);
423 display.println(description);
424 display.display();
425 delay(2000);
426
427}
428
429 void displayWeatherCloSun(float Temperature, String description) //show location & weather function
430{
431 display.clearDisplay();
432 display.drawBitmap(0, 0, bitmap_clo_sun, 64, 23, WHITE);
433 display.display();
434 display.setCursor(70,0);
435 display.setTextSize(2);
436 display.print(Temperature,1);
437 //display.print((char)223);
438 display.println("C");
439 display.display();
440 display.setTextSize(0.5);
441 display.setCursor(0,25);
442 display.println(description);
443 display.display();
444 delay(2000);
445
446}
447
448void displayWeatherRain(float Temperature, String description) //show location & weather function
449{
450 display.clearDisplay();
451 display.drawBitmap(0, 0, bitmap_rain, 64, 23, WHITE);
452 display.display();
453 display.setCursor(70,0);
454 display.setTextSize(2);
455 display.print(Temperature,1);
456 //display.print((char)223);
457 display.println("C");
458 display.display();
459 display.setTextSize(0.5);
460 display.setCursor(0,25);
461 display.println(description);
462 display.display();
463 delay(2000);
464
465}
466
467void displayWeatherThund(float Temperature, String description) //show location & weather function
468{
469 display.clearDisplay();
470 display.drawBitmap(0, 0, bitmap_thund, 64, 23, WHITE);
471 display.display();
472 display.setCursor(70,0);
473 display.setTextSize(2);
474 display.print(Temperature,1);
475 //display.print((char)223);
476 display.println("C");
477 display.display();
478 display.setTextSize(0.5);
479 display.setCursor(0,25);
480 display.println(description);
481 display.display();
482 delay(2000);
483
484}
485void displayWeatherMist(float Temperature, String description) //show location & weather function
486{
487 display.clearDisplay();
488 display.drawBitmap(0, 0, bitmap_mist, 64, 19, WHITE);
489 display.display();
490 display.setCursor(70,0);
491 display.setTextSize(2);
492 display.print(Temperature,1);
493 //display.print((char)223);
494 display.println("C");
495 display.display();
496 display.setTextSize(0.5);
497 display.setCursor(0,25);
498 display.println(description);
499 display.display();
500 delay(2000);
501
502}
503
504void displayWeatherClear(float Temperature, String description) //show location & weather function
505{
506 display.clearDisplay();
507 display.drawBitmap(0, 0, bitmap_rain, 40, 23, WHITE);
508 display.display();
509 display.setCursor(70,0);
510 display.setTextSize(2);
511 display.print(Temperature,1);
512 //display.print((char)223);
513 display.println("C");
514 display.display();
515 display.setTextSize(0.5);
516 display.setCursor(0,25);
517 display.println(description);
518 display.display();
519 delay(2000);
520
521}
522
523void displayWeatherSnow(float Temperature, String description) //show location & weather function
524{
525 display.clearDisplay();
526 display.drawBitmap(0, 0, bitmap_snow, 35, 23, WHITE);
527 display.display();
528 display.setCursor(70,0);
529 display.setTextSize(2);
530 display.print(Temperature,1);
531 //display.print((char)223);
532 display.println("C");
533 display.display();
534 display.setTextSize(0.5);
535 display.setCursor(0,25);
536 display.println(description);
537 display.display();
538 delay(2000);
539
540}
541
542void displayConditions(String location, float Humidity, float Pressure) //show conditions function
543{
544 display.clearDisplay();
545 display.setCursor(35,0);
546 display.print(location);
547 display.print(", ");
548 display.println(Country);
549 display.setCursor(25,10);
550
551
552 //Printing Humidity
553 display.print("Humidity :");
554 display.print(Humidity,0);
555 display.println(" %");
556
557 //Printing Pressure
558 display.print("Pressure :");
559 display.print(Pressure,1);
560 display.println(" hPa");
561 delay(5000);
562 display.display();
563}
564
565void displayGettingData() //getting data display function
566{
567 display.clearDisplay();
568 display.setCursor(0,0);
569 display.print("Getting data");
570 display.display();
571 delay(1000);
572}