ive ben trying to do a little project to show time and weather on an oled screen, i copied the code but keep getting a upgrade to json 7 error on upload … ive tried upgrading to no avail - i also tried down grading but no luck the code is:
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Test OLED 128x64
/**************************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x32 pixel display using I2C to communicate
3 pins are required to interface (two I2C and one reset).
Adafruit invests time and resources providing this open
source code, please support Adafruit and open-source
hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries,
with contributions from the open source community.
BSD license, check license.txt for more information
All text above, and the splash screen below must be
included in any redistribution.
**************************************************************************/
// To install Boards and Libraries from NodeMCU ESP8266 on Arduino IDE see this video : https://www.youtube.com/watch?v=8jMr94B8iN0
//----------------------------------------Include Library
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//----------------------------------------
//----------------------------------------
#define SCREEN_WIDTH 128 //--> OLED display width, in pixels
#define SCREEN_HEIGHT 64 //--> OLED display height, in pixels
//----------------------------------------
//----------------------------------------Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//----------------------------------------
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//----------------------------------------SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
// Address 0x3C for 128x32 and Address 0x3D for 128x64.
// But on my 128x64 module the 0x3D address doesn't work. What works is the 0x3C address.
// So please try which address works on your module.
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); //--> Don't proceed, loop forever
}
//----------------------------------------
//----------------------------------------Show initial display buffer contents on the screen
// the library initializes this with an Adafruit splash screen.
// Show the display buffer on the screen(Update screen). You MUST call display() after
// drawing commands to make them visible on screen!
display.display();
delay(1000);
//----------------------------------------
//____________________________________________________________________________________Display text & numbers
display.clearDisplay(); //--> for Clearing the display
//----------------------------------------Display text with text size 1
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(10, 0); //--> (x position, y position)
display.println("Uteh Str");
display.display();
delay(2000);
//----------------------------------------
//----------------------------------------Display text with text size 2
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(10, 14); //--> (x position, y position)
display.println("Uteh Str");
display.display();
delay(2000);
//----------------------------------------
//----------------------------------------Displaying Inverted Text
display.setTextSize(1);
display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setCursor(10,35); //--> (x position, y position)
display.println("Uteh Str");
display.display();
delay(2000);
//----------------------------------------
//----------------------------------------Displaying Numbers
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(10,50); //--> (x position, y position)
display.println(1234567890);
display.display();
delay(2000);
//----------------------------------------
//____________________________________________________________________________________
}
void loop() {
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Test Get Weather Data and TimeDate
// To install Boards and Libraries from NodeMCU ESP8266 on Arduino IDE see this video : https://www.youtube.com/watch?v=8jMr94B8iN0
//----------------------------------------Include Library
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include "TimeLib.h"
#include <ArduinoJson.h>
//----------------------------------------
#define ON_Board_LED 2 //--> Defining an On Board LED (GPIO2 = D4), used for indicators when the process of connecting to a wifi router and when there is a client request.
//----------------------------------------Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
//----------------------------------------
//----------------------------------------SSID and Password of your WiFi router
const char* ssid = "your_wifi_name"; //--> Your wifi name
const char* password = "your_wifi_password"; //--> Your wifi password
//----------------------------------------
//----------------------------------------TimeLib configuration
struct timelib_tm tinfo; //--> Structure that holds human readable time information;
timelib_t now, initialt;
unsigned long previousMillisGetTimeDate = 0; //--> will store last time was updated
const long intervalGetTimeDate = 1000; //--> The interval for updating the time and date
//----------------------------------------
//----------------------------------------Declaration of time and date variables
//Week Days
String weekDays[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
//Month names
String months[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
unsigned long epochTime;
int currentHour,currentMinute,currentSecond;
String weekDay;
int monthDay,currentMonth;
String currentMonthName;
int currentYear,currentYearforSet;
String _DateTime;
//----------------------------------------
//----------------------------------------Variable declarations to hold weather data
String current_weather_Description;
String current_weather;
int current_temperature, current_pressure, current_humidity, current_wind_deg, current_visibility;
float current_wind_speed, current_feels_like, current_uv, current_dew_point;
String current_weather_sym;
String forecast_weather[4];
String forecast_weather_sym[4];
float forecast_temp_min[4];
float forecast_temp_max[4];
//----------------------------------------
//----------------------------------------openweathermap API configuration
String openWeatherMapApiKey = "";
// Check subroutine "void Get_Weather_Data ()"
// If using a city name : String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "," + countryCode + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
// If using a city ID : String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?id=" + city + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
// Please choose one.
String city = "city_name";
String countryCode = "country_ID";
String units = "metric";
//----------------------------------------
//----------------------------------------Variable declaration for the json data and defining the ArduinoJson(DynamicJsonBuffer)
String strjsonBuffer;
String strjsonBufferCF;
DynamicJsonBuffer jsonBuffer;
//----------------------------------------
int timezone_offset;
//=====================================================================================Subroutines for the connection process
void Connect() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); //--> Connect to your WiFi router
Serial.println("");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
digitalWrite(ON_Board_LED, LOW); //--> Make the On Board Flashing LED on the process of connecting to the wifi router.
delay(250);
digitalWrite(ON_Board_LED, HIGH); //--> Make the Off Board Flashing LED on the process of connecting to the wifi router.
delay(250);
}
//----------------------------------------
digitalWrite(ON_Board_LED, HIGH); //--> Turn off the On Board LED when it is connected to the wifi router.
//----------------------------------------If successfully connected to the wifi router, the IP Address that will be visited is displayed in the serial monitor
Serial.println("");
Serial.print("Successfully connected to : ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println();
//----------------------------------------
}
//=====================================================================================
//=====================================================================================setup()
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(500);
pinMode(ON_Board_LED,OUTPUT); //--> On Board LED port Direction output
digitalWrite(ON_Board_LED, HIGH); //--> Turn off Led On Board
Connect();
timeClient.begin(); //--> Initialize a NTPClient to get time
Get_Weather_Data();
}
//=====================================================================================
//=====================================================================================loop()
void loop() {
//__________________________________________________________________________________________________Millis to display time & date
unsigned long currentMillisGetTimeDate = millis();
if (currentMillisGetTimeDate - previousMillisGetTimeDate >= intervalGetTimeDate) {
previousMillisGetTimeDate = currentMillisGetTimeDate;
now = timelib_get(); //--> Get the timestamp from the library
timelib_break(now, &tinfo); //--> Convert to human readable format
//----------------------------------------Processing time and date data
char timeProcess[8];
sprintf(timeProcess, "%02u:%02u:%02u", tinfo.tm_hour, tinfo.tm_min, tinfo.tm_sec);
char _time[8];
strcpy(_time,timeProcess);
char dateDayProcess[2];
sprintf(dateDayProcess, "%02u", tinfo.tm_mday);
char _dateDay[2];
strcpy(_dateDay,dateDayProcess);
_DateTime = _dateDay;
_DateTime += "-" + currentMonthName + "-" + String(currentYear) + " " + _time;
Serial.print("Date & Time : ");
Serial.println(_DateTime);
//----------------------------------------
}
}
//=====================================================================================
//=====================================================================================Subroutines for getting weather data from openweathermap
void Get_Weather_Data() {
if(WiFi.status()== WL_CONNECTED){
//__________________________________________________________________________________________________Get longitude, latitude and timezone offset
//----------------------------------------If using a city name
String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "," + countryCode + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
//----------------------------------------
//----------------------------------------If using a city ID
//String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?id=" + city + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
//----------------------------------------
Serial.println("--------------------");
Serial.println("Get longitude, latitude & timezone offset from openweathermap...");
Serial.println();
strjsonBuffer = httpGETRequest(current_serverPath.c_str());
//Serial.println(strjsonBuffer);
JsonObject& root = jsonBuffer.parseObject(strjsonBuffer);
// Test if parsing succeeds.
if (!root.success()) {
Serial.println("parseObject() failed");
delay(500);
return;
}
String lon = root["coord"]["lon"];
String lat = root["coord"]["lat"];
timezone_offset = root["timezone"];
Serial.println();
Serial.print("Lon : ");
Serial.println(lon);
Serial.print("Lat : ");
Serial.println(lat);
Serial.print("Timezone offset : ");
Serial.println(timezone_offset);
Serial.println();
jsonBuffer.clear();
Serial.println("Set the Date and Time from the Internet...");
Set_Time_and_Date();
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________Get current weather data and weather forecast data for the following days
//----------------------------------------Get current weather data
String current_forecast_serverPath = "http://api.openweathermap.org/data/2.5/onecall?lat=" + lat + "&lon=" + lon + "&units=" + units + "&exclude=hourly&APPID=" + openWeatherMapApiKey;
Serial.println("Get weather data from openweathermap...");
strjsonBufferCF = httpGETRequest(current_forecast_serverPath.c_str());
//Serial.println(strjsonBuffer);
JsonObject& rootCF = jsonBuffer.parseObject(strjsonBufferCF);
// Test if parsing succeeds.
if (!rootCF.success()) {
Serial.println("parseObject() failed");
delay(500);
return;
}
String str_current_weather = rootCF["current"]["weather"][0]["main"];
current_weather = str_current_weather;
String str_current_weather_Description = rootCF["current"]["weather"][0]["description"];
current_weather_Description = str_current_weather_Description;
String str_current_weather_sym = rootCF["current"]["weather"][0]["icon"];
current_weather_sym = str_current_weather_sym;
current_temperature = rootCF["current"]["temp"];
current_feels_like = rootCF["current"]["feels_like"];
current_uv = rootCF["current"]["uvi"];
current_dew_point = rootCF["current"]["dew_point"];
current_pressure = rootCF["current"]["pressure"];
current_humidity = rootCF["current"]["humidity"];
current_visibility = rootCF["current"]["visibility"];
current_wind_speed = rootCF["current"]["wind_speed"];
current_wind_deg = rootCF["current"]["wind_deg"];
//----------------------------------------
//----------------------------------------Get weather forecast data for the following days
String str_forecast_weather1 = rootCF["daily"][0]["weather"][0]["main"];
forecast_weather[0] = str_forecast_weather1;
String str_forecast_weather_sym1 = rootCF["daily"][0]["weather"][0]["icon"];
forecast_weather_sym[0] = str_forecast_weather_sym1;
forecast_temp_max[0] = rootCF["daily"][0]["temp"]["max"];
forecast_temp_min[0] = rootCF["daily"][0]["temp"]["min"];
String str_forecast_weather2 = rootCF["daily"][1]["weather"][0]["main"];
forecast_weather[1] = str_forecast_weather2;
String str_forecast_weather_sym2 = rootCF["daily"][1]["weather"][0]["icon"];
forecast_weather_sym[1] = str_forecast_weather_sym2;
forecast_temp_max[1] = rootCF["daily"][1]["temp"]["max"];
forecast_temp_min[1] = rootCF["daily"][1]["temp"]["min"];
String str_forecast_weather3 = rootCF["daily"][2]["weather"][0]["main"];
forecast_weather[2] = str_forecast_weather3;
String str_forecast_weather_sym3 = rootCF["daily"][2]["weather"][0]["icon"];
forecast_weather_sym[2] = str_forecast_weather_sym3;
forecast_temp_max[2] = rootCF["daily"][2]["temp"]["max"];
forecast_temp_min[2] = rootCF["daily"][2]["temp"]["min"];
String str_forecast_weather4 = rootCF["daily"][3]["weather"][0]["main"];
forecast_weather[3] = str_forecast_weather4;
String str_forecast_weather_sym4 = rootCF["daily"][3]["weather"][0]["icon"];
forecast_weather_sym[3] = str_forecast_weather_sym4;
forecast_temp_max[3] = rootCF["daily"][3]["temp"]["max"];
forecast_temp_min[3] = rootCF["daily"][3]["temp"]["min"];
//----------------------------------------
//----------------------------------------
Serial.println();
Serial.println("Current weather data");
Serial.print("weather : ");
Serial.println(current_weather);
Serial.print("weather description : ");
Serial.println(current_weather_Description);
Serial.print("weather symbol : ");
Serial.println(current_weather_sym);
Serial.print("temperature : ");
Serial.print(current_temperature);
Serial.println(" °C");
Serial.print("feels_like : ");
Serial.print(current_feels_like);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(current_feels_like));
Serial.print(" °C");
Serial.println(")");
Serial.print("UV : ");
Serial.print(current_uv);
Serial.print(" (");
Serial.print(round(current_uv));
Serial.println(")");
Serial.print("Dew point : ");
Serial.print(current_dew_point);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(current_dew_point));
Serial.print(" °C");
Serial.println(")");
Serial.print("pressure : ");
Serial.print(current_pressure);
Serial.println(" hPa");
Serial.print("humidity : ");
Serial.print(current_humidity);
Serial.println(" %");
Serial.print("visibility : ");
Serial.print(current_visibility);
Serial.print(" m");
Serial.print(" (");
float current_visibility_to_km = current_visibility / 1000;
Serial.print(current_visibility_to_km);
Serial.print(" km");
Serial.println(")");
Serial.print("wind_speed : ");
Serial.print(current_wind_speed);
Serial.println(" m/s");
Serial.print("wind_deg : ");
Serial.print(current_wind_deg);
Serial.println("°");
//----------------------------------------
//----------------------------------------
int wds[4] = {timeClient.getDay(),timeClient.getDay()+1,timeClient.getDay()+2,timeClient.getDay()+3};
for(int i = 0; i < 4; i++) {
if(wds[i] == 7) {
wds[i] = 0;
}
if(wds[i] == 8) {
wds[i] = 1;
}
if(wds[i] == 9) {
wds[i] = 2;
}
}
String wd;
//----------------------------------------
//----------------------------------------
wd = weekDays[wds[0]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[0]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[0]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[0]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[0]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[0]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[0]));
Serial.print(" °C");
Serial.println(")");
Serial.println();
wd = weekDays[wds[1]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[1]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[1]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[1]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[1]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[1]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[1]));
Serial.print(" °C");
Serial.println(")");
Serial.println();
wd = weekDays[wds[2]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[2]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[2]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[2]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[2]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[2]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[2]));
Serial.print(" °C");
Serial.println(")");
wd = weekDays[wds[3]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[3]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[3]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[3]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[3]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[3]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[3]));
Serial.print(" °C");
Serial.println(")");
Serial.println("--------------------");
Serial.println();
//----------------------------------------
jsonBuffer.clear();
Serial.println("Set the Date and Time again from the Internet...");
Set_Time_and_Date();
//__________________________________________________________________________________________________
}
else {
Serial.println("WiFi Disconnected");
}
}
//=====================================================================================
//=====================================================================================httpGETRequest
String httpGETRequest(const char* serverName) {
HTTPClient http;
// Your IP address with path or Domain name with URL path
http.begin(serverName);
// Send HTTP POST request
int httpResponseCode = http.GET();
String payload = "{}";
if (httpResponseCode == 200) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
payload = http.getString();
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
delay(500);
}
// Free resources
http.end();
return payload;
}
//=====================================================================================
//=====================================================================================Subroutines for setting the time and date from the internet
void Set_Time_and_Date() {
timeClient.setTimeOffset(timezone_offset);
// Send an HTTP GET request
timeClient.update();
epochTime = timeClient.getEpochTime();
currentHour = timeClient.getHours();
currentMinute = timeClient.getMinutes();
currentSecond = timeClient.getSeconds();
weekDay = weekDays[timeClient.getDay()];
//Get a time structure
struct tm *ptm = gmtime ((time_t *)&epochTime);
monthDay = ptm->tm_mday;
currentMonth = ptm->tm_mon+1;
currentMonthName = months[currentMonth-1];
currentYear = ptm->tm_year+1900;
currentYearforSet = currentYear - 2000;
// Set time manually to 13:55:30 Jan 1st 2014
// YOU CAN SET THE TIME FOR THIS EXAMPLE HERE
tinfo.tm_year = currentYearforSet;
tinfo.tm_mon = currentMonth;
tinfo.tm_mday = monthDay;
tinfo.tm_hour = currentHour;
tinfo.tm_min = currentMinute;
tinfo.tm_sec = currentSecond;
// Convert time structure to timestamp
initialt = timelib_make(&tinfo);
// Set system time counter
timelib_set(initialt);
// Configure the library to update / sync every day (for hardware RTC)
//timelib_set_provider(time_provider, TIMELIB_SECS_PER_DAY);
Serial.println("Setting Date and Time from Internet is successful.");
}
//=====================================================================================
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> NodeMCU OLED 128x64 Weather Station
// To install Boards and Libraries from NodeMCU ESP8266 on Arduino IDE see this video : https://www.youtube.com/watch?v=8jMr94B8iN0
//----------------------------------------Include Library
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include "TimeLib.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <ArduinoJson.h>
//----------------------------------------
#define ON_Board_LED 2 //--> Defining an On Board LED (GPIO2 = D4), used for indicators when the process of connecting to a wifi router and when there is a client request.
//----------------------------------------OLED screen size configuration
#define SCREEN_WIDTH 128 //--> OLED display width, in pixels
#define SCREEN_HEIGHT 64 //--> OLED display height, in pixels
//----------------------------------------
//----------------------------------------Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//----------------------------------------
//----------------------------------------Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
//----------------------------------------
//----------------------------------------SSID and Password of your WiFi router
const char* ssid = "your_wifi_name"; //--> Your wifi name
const char* password = "your_wifi_password"; //--> Your wifi password
//----------------------------------------
//----------------------------------------TimeLib configuration
struct timelib_tm tinfo; //--> Structure that holds human readable time information;
timelib_t now, initialt;
unsigned long previousMillisGetTimeDate = 0; //--> will store last time was updated
const long intervalGetTimeDate = 1000; //--> The interval for updating the time and date
//----------------------------------------
//----------------------------------------Declaration of time and date variables
//Week Days
String weekDays[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
String weekDays3Dgt[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
//Month names
String months[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
unsigned long epochTime;
int currentHour,currentMinute,currentSecond;
String weekDay;
int monthDay,currentMonth;
String currentMonthName;
int currentYear,currentYearforSet;
String _DateTime;
//----------------------------------------
//----------------------------------------Variable declarations to hold weather data
String current_weather_Description;
String current_weather;
int current_temperature, current_pressure, current_humidity, current_wind_deg, current_visibility;
float current_wind_speed, current_feels_like, current_uv, current_dew_point;
String current_weather_sym;
String forecast_weather[4];
String forecast_weather_sym[4];
float forecast_temp_min[4];
float forecast_temp_max[4];
//----------------------------------------
//----------------------------------------openweathermap API configuration
String openWeatherMapApiKey = "";
// Check subroutine "void Get_Weather_Data ()"
// If using a city name : String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "," + countryCode + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
// If using a city ID : String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?id=" + city + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
// Please choose one.
String city = "city_name";
String countryCode = "country_ID";
String units = "metric";
//----------------------------------------
//----------------------------------------Variable declaration for the json data and defining the ArduinoJson(DynamicJsonBuffer)
String strjsonBuffer;
String strjsonBufferCF;
DynamicJsonBuffer jsonBuffer;
//----------------------------------------
//----------------------------------------Variable declaration for the weather data update indicator
int Upadate_Trig = 1;
//----------------------------------------
//----------------------------------------Variable declarations for weather and loading symbols / icons
// 'Process1_Sym', 8x8px
const unsigned char Process1_Sym [] PROGMEM = {
0x00, 0x18, 0x00, 0x01, 0x99, 0x80, 0x01, 0x81, 0x80, 0x08, 0x00, 0x10, 0x18, 0x00, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06,
0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x08, 0x00, 0x10, 0x01,
0x81, 0x80, 0x01, 0x99, 0x80, 0x00, 0x18, 0x00
};
// 'Process2_Sym', 8x8px
const unsigned char Process2_Sym [] PROGMEM = {
0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x06, 0x00, 0x60, 0x06, 0x00, 0x60, 0x00, 0x00, 0x00, 0x30,
0x00, 0x0c, 0x30, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x00, 0x0c, 0x30, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x06,
0x00, 0x60, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00
};
// 'Clear_Daylight_Sym', 24x24px
const unsigned char Clear_Daylight_Sym [] PROGMEM = {
0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x10, 0x18, 0x08, 0x38, 0x00, 0x1c, 0x1c, 0x3c, 0x38, 0x08,
0xff, 0x10, 0x01, 0xc1, 0x80, 0x03, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x06, 0x00, 0x60, 0x0c, 0x00,
0x30, 0xec, 0x00, 0x37, 0xec, 0x00, 0x37, 0x0c, 0x00, 0x30, 0x06, 0x00, 0x60, 0x06, 0x00, 0x60,
0x03, 0x00, 0xc0, 0x01, 0xc3, 0x80, 0x08, 0xff, 0x10, 0x1c, 0x3c, 0x38, 0x38, 0x00, 0x1c, 0x10,
0x18, 0x08, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00
};
// 'Clear_Night_Sym', 24x24px
const unsigned char Clear_Night_Sym [] PROGMEM = {
0x08, 0x08, 0x80, 0x08, 0x1c, 0xc0, 0x1c, 0x08, 0xe0, 0x3e, 0x00, 0xf0, 0xff, 0x80, 0xd8, 0x3e,
0x00, 0xcc, 0x1c, 0x00, 0xc6, 0x08, 0x01, 0x86, 0x08, 0x01, 0x83, 0x00, 0x03, 0x03, 0x00, 0x03,
0x03, 0x40, 0x06, 0x03, 0xe0, 0x06, 0x03, 0x40, 0x1c, 0x03, 0x00, 0x78, 0x03, 0x01, 0xe0, 0x03,
0xff, 0x80, 0x06, 0x7e, 0x00, 0x06, 0x30, 0x00, 0x0c, 0x18, 0x00, 0x18, 0x0c, 0x00, 0x30, 0x07,
0x00, 0xe0, 0x03, 0xff, 0xc0, 0x00, 0xff, 0x00
};
// 'Thunderstorm', 24x24px
const unsigned char Thunderstorm_Sym [] PROGMEM = {
0x01, 0xf0, 0x00, 0x03, 0xf8, 0x70, 0x06, 0x0c, 0xf8, 0x1c, 0x07, 0x8c, 0x38, 0x03, 0x06, 0x60,
0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xe0, 0x00, 0x07, 0x7f, 0xff,
0xfe, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x10, 0x1e, 0x02, 0x20, 0x24, 0x04, 0x40, 0x48, 0x08,
0xf8, 0x9f, 0x9f, 0x11, 0x00, 0x82, 0x21, 0xfd, 0x04, 0x40, 0x0a, 0x08, 0x80, 0x14, 0x10, 0x00,
0x28, 0x00, 0x00, 0x50, 0x00, 0x00, 0x60, 0x00
};
// 'Drizzle', 24x24px
const unsigned char Drizzle_Sym [] PROGMEM = {
0x01, 0xf0, 0x00, 0x03, 0x18, 0x70, 0x06, 0x0c, 0xf8, 0x1c, 0x07, 0x8c, 0x38, 0x03, 0x06, 0x60,
0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xe0, 0x00, 0x07, 0x7f, 0xff,
0xfe, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc3, 0x0c, 0x30, 0xc3, 0x0c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x18, 0x61, 0x86, 0x18, 0x61, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0xc3, 0x0c, 0x30, 0xc3, 0x0c
};
// 'Rain', 24x24px
const unsigned char Rain_Sym [] PROGMEM = {
0x01, 0xf0, 0x00, 0x03, 0xf8, 0x70, 0x06, 0x0c, 0xf8, 0x1c, 0x07, 0x8c, 0x38, 0x03, 0x06, 0x60,
0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xe0, 0x00, 0x07, 0x7f, 0xff,
0xfe, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x84, 0x21, 0x21, 0x08, 0x42,
0x42, 0x10, 0x84, 0x84, 0x21, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x84, 0x21, 0x21,
0x08, 0x42, 0x42, 0x10, 0x84, 0x84, 0x21, 0x08
};
// 'Snow', 24x24px
const unsigned char Snow_Sym [] PROGMEM = {
0x01, 0xf0, 0x00, 0x03, 0x18, 0x70, 0x06, 0x0c, 0xf8, 0x1c, 0x07, 0x8c, 0x38, 0x03, 0x06, 0x60,
0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xe0, 0x00, 0x07, 0x7f, 0xff,
0xfe, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xa0, 0x50, 0x20, 0x40, 0x20, 0xa8, 0xa0, 0x50, 0x70,
0x00, 0x01, 0xfc, 0x04, 0x00, 0x70, 0x15, 0x00, 0xa8, 0x0e, 0x00, 0x20, 0x3f, 0x80, 0x00, 0x0e,
0x0a, 0x05, 0x15, 0x04, 0x02, 0x04, 0x0a, 0x05
};
// 'Mist', 24x24px
const unsigned char Mist_Sym [] PROGMEM = {
0x01, 0xf0, 0x00, 0x03, 0x18, 0x70, 0x06, 0x0c, 0xf8, 0x1c, 0x07, 0x8c, 0x38, 0x03, 0x06, 0x60,
0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xe0, 0x00, 0x07, 0x7f, 0xff,
0xfe, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc3, 0x0c, 0x79, 0xe7, 0x9e,
0xcf, 0x3c, 0xf3, 0x86, 0x18, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc3, 0x0c, 0x79,
0xe7, 0x9e, 0xcf, 0x3c, 0xf3, 0x86, 0x18, 0x61
};
// 'Clouds_Daylight', 24x24px
const unsigned char Clouds_Daylight_Sym [] PROGMEM = {
0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x10, 0x18, 0x08, 0x38, 0x00, 0x1c, 0x1c, 0x3c, 0x38, 0x08,
0xff, 0x10, 0x01, 0xc3, 0x80, 0x03, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x06, 0x00, 0x60, 0x0c, 0x00,
0x30, 0xec, 0x00, 0x37, 0xed, 0xf0, 0x37, 0x0f, 0xf8, 0x70, 0x06, 0x0c, 0xf8, 0x1c, 0x07, 0x8c,
0x38, 0x03, 0x06, 0x60, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xe0,
0x00, 0x07, 0x7f, 0xff, 0xfe, 0x3f, 0xff, 0xfc
};
// 'Clouds_Night_Sym', 24x24px
const unsigned char Clouds_Night_Sym [] PROGMEM = {
0x00, 0x00, 0x02, 0x00, 0x01, 0x07, 0x04, 0x01, 0xc2, 0x04, 0x01, 0xe0, 0x0e, 0x01, 0xb0, 0x3f,
0x81, 0x98, 0x0e, 0x01, 0x8c, 0x04, 0x03, 0x0c, 0x04, 0x03, 0x06, 0x00, 0x03, 0x06, 0x00, 0x06,
0x03, 0x00, 0x06, 0x03, 0x00, 0x0c, 0x03, 0x00, 0x38, 0x03, 0x01, 0xf0, 0x06, 0x7f, 0xc0, 0x06,
0x3e, 0x00, 0x0c, 0x30, 0x00, 0x0c, 0x18, 0x00, 0x18, 0x0c, 0x00, 0x30, 0x07, 0x00, 0xe0, 0x43,
0xc3, 0xc2, 0xe0, 0xff, 0x07, 0x40, 0x3c, 0x02
};
// 'Cloudy_Sym', 24x24px
const unsigned char Cloudy_Sym [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x01, 0xf0, 0xe0, 0x03, 0x19, 0xf0, 0x0e,
0x0f, 0x1c, 0x1c, 0x06, 0x0e, 0x30, 0x00, 0x03, 0x60, 0x00, 0x03, 0x61, 0xc0, 0x03, 0x63, 0xe1,
0xc3, 0x36, 0x33, 0xe6, 0x3c, 0x1e, 0x3c, 0x78, 0x0c, 0x1c, 0xe0, 0x00, 0x06, 0xc0, 0x00, 0x06,
0xc0, 0x00, 0x06, 0xc0, 0x00, 0x06, 0xe0, 0x00, 0x0c, 0x7f, 0xff, 0xf8, 0x3f, 0xff, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
char *mist[] = {"Mist", "Smoke", "Haze","Dust", "Fog", "Sand","Dust","Ash","Squall","Tornado"};
//----------------------------------------
//----------------------------------------Variable declaration for calculating the connection time
int cnt_con = 0;
//----------------------------------------
int timezone_offset;
//=====================================================================================Subroutines for the connection process
void Connect() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); //--> Connect to your WiFi router
Serial.println("");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
//----------------------------------------Displays the text and icon of the connection process on OLED
digitalWrite(ON_Board_LED, LOW); //--> Make the On Board Flashing LED on the process of connecting to the wifi router.
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(20, 15);
display.println("Connect to WiFi");
display.drawBitmap(52, 25, Process1_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(250);
digitalWrite(ON_Board_LED, HIGH); //--> Make the Off Board Flashing LED on the process of connecting to the wifi router.
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(20, 15);
display.println("Connect to WiFi");
display.drawBitmap(52, 25, Process2_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(250);
cnt_con++;
if(cnt_con > 59) {
cnt_con = 0;
Serial.println("Failed to connect !");
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 28);
display.println(" Failed to connect !");
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(5000);
Waiting_to_be_connected_again();
}
//----------------------------------------
}
//----------------------------------------
digitalWrite(ON_Board_LED, HIGH); //--> Turn off the On Board LED when it is connected to the wifi router.
//----------------------------------------If successfully connected to the wifi router, the IP Address that will be visited is displayed in the serial monitor
Serial.println("");
Serial.print("Successfully connected to : ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println();
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 24);
display.println(" Connection");
display.setCursor(0, 33);
display.println(" Successful");
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(2000);
//----------------------------------------
}
//=====================================================================================
//=====================================================================================Subroutine if connection is lost
void Connection_lost() {
Serial.println("WiFi Disconnected");
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 28);
display.println(" Connection lost !");
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(5000);
Connect();
}
//=====================================================================================
//=====================================================================================Subroutines waiting to be reconnected
void Waiting_to_be_connected_again() {
for(int i = 30; i > -1; i--) {
Serial.print("Will be connected again:");
Serial.println(i);
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 24);
display.println(" Will be");
display.setCursor(0, 33);
display.print(" connected again:");
display.println(i);
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(1000);
}
Connect();
}
//=====================================================================================
//=====================================================================================setup()
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(500);
//----------------------------------------SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
// Address 0x3C for 128x32 and Address 0x3D for 128x64.
// But on my 128x64 module the 0x3D address doesn't work. What works is the 0x3C address.
// So please try which address works on your module.
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); //--> Don't proceed, loop forever
}
//----------------------------------------
//----------------------------------------Show initial display buffer contents on the screen
// the library initializes this with an Adafruit splash screen.
// Show the display buffer on the screen(Update screen). You MUST call display() after
// drawing commands to make them visible on screen!
display.display();
delay(2000);
//----------------------------------------
pinMode(ON_Board_LED,OUTPUT); //--> On Board LED port Direction output
digitalWrite(ON_Board_LED, HIGH); //--> Turn off Led On Board
Connect();
timeClient.begin(); //--> Initialize a NTPClient to get time
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(3, 19);
display.println(" Get weather data");
display.setCursor(3, 28);
display.println(" from");
display.setCursor(3, 37);
display.println(" openweathermap");
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(1000);
Get_Weather_Data();
Serial.println("Data will be updated every 15 minute.");
}
//=====================================================================================
//=====================================================================================loop()
void loop() {
if(WiFi.status()== WL_CONNECTED){
//__________________________________________________________________________________________________Millis to display time, date and weather data
unsigned long currentMillisGetTimeDate = millis();
if (currentMillisGetTimeDate - previousMillisGetTimeDate >= intervalGetTimeDate) {
previousMillisGetTimeDate = currentMillisGetTimeDate;
now = timelib_get(); //--> Get the timestamp from the library
timelib_break(now, &tinfo); //--> Convert to human readable format
//----------------------------------------Processing time and date data
char timeProcess[8];
sprintf(timeProcess, "%02u:%02u:%02u", tinfo.tm_hour, tinfo.tm_min, tinfo.tm_sec);
char _time[8];
strcpy(_time,timeProcess);
char dateDayProcess[2];
sprintf(dateDayProcess, "%02u", tinfo.tm_mday);
char _dateDay[2];
strcpy(_dateDay,dateDayProcess);
_DateTime = _dateDay;
_DateTime += "-" + currentMonthName + "-" + String(currentYear) + " " + _time;
//----------------------------------------
//----------------------------------------Conditions for updating weather data, time and date.
if(Upadate_Trig == 1 && tinfo.tm_min % 15 == 0) {
display.clearDisplay(); //--> for Clearing the display
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
Display_current_weather_data();
display.drawRect(0, 0, 128, 64, WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(4, 52); //--> (x position, y position)
display.println(" Updating Data...");
display.drawLine(0, 47, 127, 47, WHITE);
display.display();
Get_Weather_Data();
Serial.println("Set the Date and Time from the Internet...");
Set_Time_and_Date();
Upadate_Trig = 0;
}
if(tinfo.tm_min % 15 != 0) {
Upadate_Trig = 1;
}
//----------------------------------------
//----------------------------------------Conditions for displaying more detailed weather data
if(tinfo.tm_sec > 20 && tinfo.tm_sec < 26) {
Display_weather_description();
} else if(tinfo.tm_sec > 25 && tinfo.tm_sec < 36) {
Display_other_information_1();
} else if(tinfo.tm_sec > 35 && tinfo.tm_sec < 46) {
Display_other_information_2();
} else if(tinfo.tm_sec > 45 && tinfo.tm_sec < 56) {
Display_weather_forecast_data();
} else {
display.clearDisplay(); //--> for Clearing the display
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
Display_current_weather_data();
Display_current_DateTime();
display.drawLine(0, 47, 127, 47, WHITE);
display.display();
}
//----------------------------------------
}
//__________________________________________________________________________________________________
} else {
Connection_lost();
}
}
//=====================================================================================
//=====================================================================================Subroutines for getting weather data from openweathermap
void Get_Weather_Data() {
if(WiFi.status()== WL_CONNECTED){
//__________________________________________________________________________________________________Get longitude, latitude and timezone offset
//----------------------------------------If using a city name
String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "," + countryCode + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
//----------------------------------------
//----------------------------------------If using a city ID
//String current_serverPath = "http://api.openweathermap.org/data/2.5/weather?id=" + city + "&units=" + units + "&APPID=" + openWeatherMapApiKey;
//----------------------------------------
Serial.println("--------------------");
Serial.println("Get weather data from openweathermap...");
Serial.println();
strjsonBuffer = httpGETRequest(current_serverPath.c_str());
//Serial.println(strjsonBuffer);
JsonObject& root = jsonBuffer.parseObject(strjsonBuffer);
// Test if parsing succeeds.
if (!root.success()) {
Serial.println("parseObject() failed");
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 19);
display.println(" Failed to get");
display.setCursor(0, 28);
display.println(" weather data !");
display.setCursor(4, 37);
display.println("parseObject() failed");
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(5000);
return;
}
String lon = root["coord"]["lon"];
String lat = root["coord"]["lat"];
timezone_offset = root["timezone"];
Serial.println();
Serial.print("Lon : ");
Serial.println(lon);
Serial.print("Lat : ");
Serial.println(lat);
Serial.print("Timezone offset : ");
Serial.println(timezone_offset);
Serial.println();
jsonBuffer.clear();
Serial.println("Set the Date and Time from the Internet...");
Set_Time_and_Date();
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________Get current weather data and weather forecast data for the following days
//----------------------------------------Get current weather data
String current_forecast_serverPath = "http://api.openweathermap.org/data/2.5/onecall?lat=" + lat + "&lon=" + lon + "&units=" + units + "&exclude=hourly&APPID=" + openWeatherMapApiKey;
strjsonBufferCF = httpGETRequest(current_forecast_serverPath.c_str());
//Serial.println(strjsonBuffer);
JsonObject& rootCF = jsonBuffer.parseObject(strjsonBufferCF);
// Test if parsing succeeds.
if (!rootCF.success()) {
Serial.println("parseObject() failed");
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 19);
display.println(" Failed to get");
display.setCursor(0, 28);
display.println(" weather data !");
display.setCursor(4, 37);
display.println("parseObject() failed");
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(5000);
return;
}
String str_current_weather = rootCF["current"]["weather"][0]["main"];
current_weather = str_current_weather;
String str_current_weather_Description = rootCF["current"]["weather"][0]["description"];
current_weather_Description = str_current_weather_Description;
String str_current_weather_sym = rootCF["current"]["weather"][0]["icon"];
current_weather_sym = str_current_weather_sym;
current_temperature = rootCF["current"]["temp"];
current_feels_like = rootCF["current"]["feels_like"];
current_uv = rootCF["current"]["uvi"];
current_dew_point = rootCF["current"]["dew_point"];
current_pressure = rootCF["current"]["pressure"];
current_humidity = rootCF["current"]["humidity"];
current_visibility = rootCF["current"]["visibility"];
current_wind_speed = rootCF["current"]["wind_speed"];
current_wind_deg = rootCF["current"]["wind_deg"];
//----------------------------------------
//----------------------------------------Get weather forecast data for the following days
String str_forecast_weather1 = rootCF["daily"][0]["weather"][0]["main"];
forecast_weather[0] = str_forecast_weather1;
String str_forecast_weather_sym1 = rootCF["daily"][0]["weather"][0]["icon"];
forecast_weather_sym[0] = str_forecast_weather_sym1;
forecast_temp_max[0] = rootCF["daily"][0]["temp"]["max"];
forecast_temp_min[0] = rootCF["daily"][0]["temp"]["min"];
String str_forecast_weather2 = rootCF["daily"][1]["weather"][0]["main"];
forecast_weather[1] = str_forecast_weather2;
String str_forecast_weather_sym2 = rootCF["daily"][1]["weather"][0]["icon"];
forecast_weather_sym[1] = str_forecast_weather_sym2;
forecast_temp_max[1] = rootCF["daily"][1]["temp"]["max"];
forecast_temp_min[1] = rootCF["daily"][1]["temp"]["min"];
String str_forecast_weather3 = rootCF["daily"][2]["weather"][0]["main"];
forecast_weather[2] = str_forecast_weather3;
String str_forecast_weather_sym3 = rootCF["daily"][2]["weather"][0]["icon"];
forecast_weather_sym[2] = str_forecast_weather_sym3;
forecast_temp_max[2] = rootCF["daily"][2]["temp"]["max"];
forecast_temp_min[2] = rootCF["daily"][2]["temp"]["min"];
String str_forecast_weather4 = rootCF["daily"][3]["weather"][0]["main"];
forecast_weather[3] = str_forecast_weather4;
String str_forecast_weather_sym4 = rootCF["daily"][3]["weather"][0]["icon"];
forecast_weather_sym[3] = str_forecast_weather_sym4;
forecast_temp_max[3] = rootCF["daily"][3]["temp"]["max"];
forecast_temp_min[3] = rootCF["daily"][3]["temp"]["min"];
//----------------------------------------
//----------------------------------------
Serial.println();
Serial.println("Current weather data");
Serial.print("weather : ");
Serial.println(current_weather);
Serial.print("weather description : ");
Serial.println(current_weather_Description);
Serial.print("weather symbol : ");
Serial.println(current_weather_sym);
Serial.print("temperature : ");
Serial.print(current_temperature);
Serial.println(" °C");
Serial.print("feels_like : ");
Serial.print(current_feels_like);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(current_feels_like));
Serial.print(" °C");
Serial.println(")");
Serial.print("UV : ");
Serial.print(current_uv);
Serial.print(" (");
Serial.print(round(current_uv));
Serial.println(")");
Serial.print("Dew point : ");
Serial.print(current_dew_point);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(current_dew_point));
Serial.print(" °C");
Serial.println(")");
Serial.print("pressure : ");
Serial.print(current_pressure);
Serial.println(" hPa");
Serial.print("humidity : ");
Serial.print(current_humidity);
Serial.println(" %");
Serial.print("visibility : ");
Serial.print(current_visibility);
Serial.print(" m");
Serial.print(" (");
float current_visibility_to_km = current_visibility / 1000;
Serial.print(current_visibility_to_km);
Serial.print(" km");
Serial.println(")");
Serial.print("wind_speed : ");
Serial.print(current_wind_speed);
Serial.println(" m/s");
Serial.print("wind_deg : ");
Serial.print(current_wind_deg);
Serial.println("°");
//----------------------------------------
//----------------------------------------
int wds[4] = {timeClient.getDay(),timeClient.getDay()+1,timeClient.getDay()+2,timeClient.getDay()+3};
for(int i = 0; i < 4; i++) {
if(wds[i] == 7) {
wds[i] = 0;
}
if(wds[i] == 8) {
wds[i] = 1;
}
if(wds[i] == 9) {
wds[i] = 2;
}
}
String wd;
//----------------------------------------
//----------------------------------------
wd = weekDays[wds[0]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[0]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[0]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[0]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[0]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[0]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[0]));
Serial.print(" °C");
Serial.println(")");
Serial.println();
wd = weekDays[wds[1]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[1]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[1]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[1]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[1]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[1]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[1]));
Serial.print(" °C");
Serial.println(")");
Serial.println();
wd = weekDays[wds[2]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[2]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[2]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[2]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[2]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[2]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[2]));
Serial.print(" °C");
Serial.println(")");
wd = weekDays[wds[3]];
Serial.println();
Serial.print("Weather forecast data : ");
Serial.println(wd);
Serial.print("weather : ");
Serial.println(forecast_weather[3]);
Serial.print("weather_sym : ");
Serial.println(forecast_weather_sym[3]);
Serial.print("temp_max : ");
Serial.print(forecast_temp_max[3]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_max[3]));
Serial.print(" °C");
Serial.println(")");
Serial.print("temp_min : ");
Serial.print(forecast_temp_min[3]);
Serial.print(" °C");
Serial.print(" (");
Serial.print(round(forecast_temp_min[3]));
Serial.print(" °C");
Serial.println(")");
Serial.println("--------------------");
Serial.println();
//----------------------------------------
jsonBuffer.clear();
Serial.println("Set the Date and Time again from the Internet...");
Set_Time_and_Date();
//__________________________________________________________________________________________________
}
else {
Serial.println("WiFi Disconnected");
}
}
//=====================================================================================
//=====================================================================================httpGETRequest
String httpGETRequest(const char* serverName) {
HTTPClient http;
// Your IP address with path or Domain name with URL path
http.begin(serverName);
// Send HTTP POST request
int httpResponseCode = http.GET();
String payload = "{}";
if (httpResponseCode == 200) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
payload = http.getString();
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
display.clearDisplay(); //--> for Clearing the display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 19);
display.println(" Failed to get");
display.setCursor(0, 28);
display.println(" weather data !");
display.setCursor(0, 37);
display.print(" HTTP Response: ");
display.println(httpResponseCode);
display.drawRect(0, 0, 128, 64, WHITE); //--> Display frame
display.display();
delay(5000);
}
// Free resources
http.end();
return payload;
}
//=====================================================================================
//=====================================================================================Subroutines for setting the time and date from the internet
void Set_Time_and_Date() {
timeClient.setTimeOffset(timezone_offset);
// Send an HTTP GET request
timeClient.update();
epochTime = timeClient.getEpochTime();
currentHour = timeClient.getHours();
currentMinute = timeClient.getMinutes();
currentSecond = timeClient.getSeconds();
weekDay = weekDays[timeClient.getDay()];
//Get a time structure
struct tm *ptm = gmtime ((time_t *)&epochTime);
monthDay = ptm->tm_mday;
currentMonth = ptm->tm_mon+1;
currentMonthName = months[currentMonth-1];
currentYear = ptm->tm_year+1900;
currentYearforSet = currentYear - 2000;
// Set time manually to 13:55:30 Jan 1st 2014
// YOU CAN SET THE TIME FOR THIS EXAMPLE HERE
tinfo.tm_year = currentYearforSet;
tinfo.tm_mon = currentMonth;
tinfo.tm_mday = monthDay;
tinfo.tm_hour = currentHour;
tinfo.tm_min = currentMinute;
tinfo.tm_sec = currentSecond;
// Convert time structure to timestamp
initialt = timelib_make(&tinfo);
// Set system time counter
timelib_set(initialt);
// Configure the library to update / sync every day (for hardware RTC)
//timelib_set_provider(time_provider, TIMELIB_SECS_PER_DAY);
Serial.println("Setting Date and Time from Internet is successful.");
}
//=====================================================================================
//=====================================================================================Subroutines to display time and date
void Display_current_DateTime() {
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(4, 52); //--> (x position, y position)
display.println(_DateTime);
}
//=====================================================================================
//=====================================================================================Subroutines for displaying weather data
void Display_current_weather_data() {
//----------------------------------------Weather icon selection conditions
if (current_weather == "Thunderstorm") {
display.drawBitmap(10, 5, Thunderstorm_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (current_weather == "Drizzle") {
display.drawBitmap(10, 5, Drizzle_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (current_weather == "Rain") {
display.drawBitmap(10, 5, Rain_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (current_weather == "Snow") {
display.drawBitmap(10, 5, Snow_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (current_weather == "Clear") {
if (current_weather_sym == "01d") {
display.drawBitmap(10, 5, Clear_Daylight_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
} else if (current_weather_sym == "01n") {
display.drawBitmap(10, 5, Clear_Night_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
}
else if (current_weather == "Clouds") {
if (current_weather_sym == "02d") {
display.drawBitmap(10, 5, Clouds_Daylight_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
} else if (current_weather_sym == "02d") {
display.drawBitmap(10, 5, Clouds_Night_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
} else {
display.drawBitmap(10, 5, Cloudy_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
}
for (int i = 0; i < 10; i++) {
if (current_weather == mist[i]) {
display.drawBitmap(10, 5, Mist_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
}
//----------------------------------------
//----------------------------------------Displays weather data, temperature, humidity and wind speed
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(50, 5); //--> (x position, y position)
display.println(current_weather);
display.setCursor(50, 15); //--> (x position, y position)
String Hum = "H:" + String(current_humidity) + "%";
display.println(Hum);
display.setCursor(50, 25); //--> (x position, y position)
String WS = "WS:" + String(current_wind_speed) + "m/s";
display.println(WS);
display.setCursor(50, 35); //--> (x position, y position)
display.println(weekDay);
display.setCursor(4, 35); //--> (x position, y position)
display.print("T:");
display.print(current_temperature);
display.print((char)247); //--> ASCII degree symbol
display.print("C");
//----------------------------------------
}
//=====================================================================================
//=====================================================================================Subroutines to display data for the next few days
void Display_weather_forecast_data() {
int forecast_X1[] = {20,90};
int forecast_X2[] = {17,87};
int forecast_X3[] = {8,79};
int wds[4] = {timeClient.getDay(),timeClient.getDay()+1,timeClient.getDay()+2,timeClient.getDay()+3};
int round_forecast_temp_max[2];
int round_forecast_temp_min[2];
for(int i = 0; i < 4; i++) {
if(wds[i] == 7) {
wds[i] = 0;
}
if(wds[i] == 8) {
wds[i] = 1;
}
if(wds[i] == 9) {
wds[i] = 2;
}
}
String forecast_weather_Prcs[2];
String forecast_weather_sym_Prcs[2];
int wds_Prcs[2];
if(tinfo.tm_sec > 45 && tinfo.tm_sec < 51) {
forecast_weather_Prcs[0] = forecast_weather[0];
forecast_weather_Prcs[1] = forecast_weather[1];
forecast_weather_sym_Prcs[0] = forecast_weather_sym[0];
forecast_weather_sym_Prcs[1] = forecast_weather_sym[1];
wds_Prcs[0] = wds[0];
wds_Prcs[1] = wds[1];
round_forecast_temp_max[0] = round(forecast_temp_max[0]);
round_forecast_temp_min[0] = round(forecast_temp_min[0]);
round_forecast_temp_max[1] = round(forecast_temp_max[1]);
round_forecast_temp_min[1] = round(forecast_temp_min[1]);
} else {
forecast_weather_Prcs[0] = forecast_weather[2];
forecast_weather_Prcs[1] = forecast_weather[3];
forecast_weather_sym_Prcs[0] = forecast_weather_sym[2];
forecast_weather_sym_Prcs[1] = forecast_weather_sym[3];
wds_Prcs[0] = wds[2];
wds_Prcs[1] = wds[3];
round_forecast_temp_max[0] = round(forecast_temp_max[2]);
round_forecast_temp_min[0] = round(forecast_temp_min[2]);
round_forecast_temp_max[1] = round(forecast_temp_max[3]);
round_forecast_temp_min[1] = round(forecast_temp_min[3]);
}
String wd;
String WF, WSF;
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
//----------------------------------------Process data for display
for(int i = 0; i < 2; i++) {
wd = weekDays3Dgt[wds_Prcs[i]];
display.setCursor(forecast_X1[i], 0);
display.print(wd);
WF = forecast_weather_Prcs[i];
WSF = forecast_weather_sym_Prcs[i];
if (WF == "Thunderstorm") {
display.drawBitmap(forecast_X2[i], 9, Thunderstorm_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (WF == "Drizzle") {
display.drawBitmap(forecast_X2[i], 9, Drizzle_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (WF == "Rain") {
display.drawBitmap(forecast_X2[i], 9, Rain_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (WF == "Snow") {
display.drawBitmap(forecast_X2[i], 9, Snow_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
else if (WF == "Clear") {
if (WSF == "01d") {
display.drawBitmap(forecast_X2[i], 9, Clear_Daylight_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
} else if (WSF == "01n") {
display.drawBitmap(forecast_X2[i], 9, Clear_Night_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
}
else if (WF == "Clouds") {
if (WSF == "02d") {
display.drawBitmap(forecast_X2[i], 9, Clouds_Daylight_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
} else if (WSF == "02d") {
display.drawBitmap(forecast_X2[i], 9, Clouds_Night_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
} else {
display.drawBitmap(forecast_X2[i], 9, Cloudy_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
}
for (int i = 0; i < 10; i++) {
if (WF == mist[i]) {
display.drawBitmap(forecast_X2[i], 9, Mist_Sym, 24, 24, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color);
}
}
String forecast_temp_max_min = String(round_forecast_temp_max[i]) + "/" + round_forecast_temp_min[i];
if(forecast_temp_max_min.length() == 6) {
forecast_X3[i] += 3;
} else if(forecast_temp_max_min.length() == 5) {
forecast_X3[i] += 6;
} else if(forecast_temp_max_min.length() == 4) {
forecast_X3[i] += 9;
} else if(forecast_temp_max_min.length() == 3) {
forecast_X3[i] += 12;
}
display.setCursor(forecast_X3[i], 36);
display.print(forecast_temp_max_min);
}
//----------------------------------------
display.drawRect(0, 47, 128, 17, WHITE); //--> Display frame
Display_current_DateTime();
display.display();
}
//=====================================================================================
//=====================================================================================Show_weather_description()
void Display_weather_description() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0); //--> (x position, y position)
display.println("Weather description :");
display.setCursor(0, 10); //--> (x position, y position)
display.println(current_weather_Description);
display.drawRect(0, 47, 128, 17, WHITE); //--> Display frame
Display_current_DateTime();
display.display();
}
//=====================================================================================
//=====================================================================================Displays_other_information_1()
void Display_other_information_1() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
int round_current_feels_like = round(current_feels_like);
String Show_current_feels_like = "Feels Like :" + String(round_current_feels_like);
display.setCursor(0, 0); //--> (x position, y position)
display.print(Show_current_feels_like);
display.print((char)247); //--> ASCII degree symbol
display.print("C");
int round_current_uv = round(current_uv);
String Show_current_uv = "UV :" + String(round_current_uv);
display.setCursor(0, 10); //--> (x position, y position)
display.println(Show_current_uv);
int round_current_dew_point = round(current_dew_point);
String Show_current_dew_point = "Dew Point :" + String(round_current_dew_point);
display.setCursor(0, 20); //--> (x position, y position)
display.print(Show_current_dew_point);
display.print((char)247); //--> ASCII degree symbol
display.print("C");
display.drawRect(0, 47, 128, 17, WHITE); //--> Display frame
Display_current_DateTime();
display.display();
}
//=====================================================================================
//=====================================================================================Displays_other_information_2()
void Display_other_information_2() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
String Show_current_pressure = "Pressure :" + String(current_pressure) + "hPa";
display.setCursor(0, 0); //--> (x position, y position)
display.println(Show_current_pressure);
float current_visibility_to_km = current_visibility/1000;
String Show_current_visibility = "visibility :" + String(current_visibility_to_km) + "km";
display.setCursor(0, 10); //--> (x position, y position)
display.println(Show_current_visibility);
String Cardinal_Direction;
if(current_wind_deg > 347 || current_wind_deg < 12) {
Cardinal_Direction = "N";
} else if(current_wind_deg > 11 && current_wind_deg < 34) {
Cardinal_Direction = "NNE";
} else if(current_wind_deg > 33 && current_wind_deg < 57) {
Cardinal_Direction = "NE";
} else if(current_wind_deg > 56 && current_wind_deg < 79) {
Cardinal_Direction = "ENE";
} else if(current_wind_deg > 78 && current_wind_deg < 102) {
Cardinal_Direction = "E";
} else if(current_wind_deg > 101 && current_wind_deg < 124) {
Cardinal_Direction = "ESE";
} else if(current_wind_deg > 123 && current_wind_deg < 147) {
Cardinal_Direction = "SE";
} else if(current_wind_deg > 146 && current_wind_deg < 169) {
Cardinal_Direction = "SSE";
} else if(current_wind_deg > 168 && current_wind_deg < 192) {
Cardinal_Direction = "S";
} else if(current_wind_deg > 191 && current_wind_deg < 214) {
Cardinal_Direction = "SSW";
} else if(current_wind_deg > 213 && current_wind_deg < 237) {
Cardinal_Direction = "SW";
} else if(current_wind_deg > 236 && current_wind_deg < 259) {
Cardinal_Direction = "WSW";
} else if(current_wind_deg > 258 && current_wind_deg < 282) {
Cardinal_Direction = "W";
} else if(current_wind_deg > 281 && current_wind_deg < 304) {
Cardinal_Direction = "WNW";
} else if(current_wind_deg > 303 && current_wind_deg < 327) {
Cardinal_Direction = "NW";
} else if(current_wind_deg > 326 && current_wind_deg < 347) {
Cardinal_Direction = "NNW";
}
display.setCursor(0, 20); //--> (x position, y position)
display.print("Wind Degree :");
display.print(current_wind_deg);
display.print((char)247); //--> ASCII degree symbol
display.println(Cardinal_Direction);
display.drawRect(0, 47, 128, 17, WHITE); //--> Display frame
Display_current_DateTime();
display.display();
}
//=====================================================================================
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
it keeps pointing at line 188 which says: DynamicJsonBuffer jsonBuffer;
how can i fix this please?
