What can i do now?


#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <ESP8266HTTPClient.h>

#include <ArduinoJson.h>


#include <SerialESP8266wifi.h>

#include <Arduino_JSON.h>
#include <JSON.h>
#include <JSONVar.h>

#include <ArduinoJson.h>


#include <Wire.h>

#include <SerialESP8266wifi.h>


#include <Adafruit_SSD1306.h>
#include <splash.h>

#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h> // http web access library
#include <ArduinoJson.h> // JSON decoding library
// Libraries for SSD1306 OLED display
#include <Wire.h> // include wire library (for I2C devices such as the SSD1306 display)
#include <Adafruit_GFX.h> // include Adafruit graphics library
#include <Adafruit_SSD1306.h> // include Adafruit SSD1306 OLED display driver
 
#define OLED_RESET 5 // define SSD1306 OLED reset at ESP8266 GPIO5 (NodeMCU D1)
Adafruit_SSD1306 display(OLED_RESET);
 
// set Wi-Fi SSID and password
const char *ssid = "TP-Link_6742";
const char *password = "26051973";
 
// set location and API key
String Location = "Amravati, IN";
String API_Key = "eb9274010b722f75502bbf8fa15f4872";
 
void setup()
{
Serial.begin(9600);
delay(1000);
 
Wire.begin(4, 0); // set I2C pins [SDA = GPIO4 (D2), SCL = GPIO0 (D3)], default clock is 100kHz
 
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
 
Wire.setClock(400000L); // set I2C clock to 400kHz
 
display.clearDisplay(); // clear the display buffer
display.setTextColor(WHITE, BLACK);
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Weather News By Anupam");
display.print(" Station - Amravati");
display.display();
 
WiFi.begin ("ssid, password");

Serial.print("Connecting.");
display.setCursor(0, 24);
display.println("Connecting...");


display.println("Made By Anupam");
display.display();
while ( WiFi.status() != WL_CONNECTED )

{
delay(500);
Serial.print(".");
}
Serial.println("connected");
display.print("connected");
display.display();
delay(1000);
 
}
 
void loop()
{
if (WiFi.status() == WL_CONNECTED) //Check WiFi connection status
{
HTTPClient http; //Declare an object of class HTTPClient
 
// specify request destination
http.begin("http://api.openweathermap.org/data/2.5/weather?q=" + Location + "&APPID=" + API_Key); // !!
 
int httpCode = http.GET(); // send the request
 
if (httpCode > 0) // check the returning code
{
String payload = http.getString(); //Get the request response payload
 
 DynamicJsonBuffer jsonBuffer(512);
// Parse JSON object
JsonObject& root = jsonBuffer.parseObject(payload);
if (!root.success()) {
Serial.println(F("Parsing failed!"));
return;
}
 
float temp = (float)(root["main"]["temp"]) - 273.15; // get temperature in °C
int humidity = root["main"]["humidity"]; // get humidity in %
float pressure = (float)(root["main"]["pressure"]) / 1000; // get pressure in bar
float wind_speed = root["wind"]["speed"]; // get wind speed in m/s
int wind_degree = root["wind"]["deg"]; // get wind degree in °
 
// print data
Serial.printf("Temperature = %.2f°C\r\n", temp);
Serial.printf("Humidity = %d %%\r\n", humidity);
Serial.printf("Pressure = %.3f bar\r\n", pressure);
Serial.printf("Wind speed = %.1f m/s\r\n", wind_speed);
Serial.printf("Wind degree = %d°\r\n\r\n", wind_degree);
 
display.setCursor(0, 24);
display.printf("Temperature: %5.2f C\r\n", temp);
display.printf("Humidity : %d %%\r\n", humidity);
display.printf("Pressure : %.3fbar\r\n", pressure);
display.printf("Wind speed : %.1f m/s\r\n", wind_speed);
display.printf("Wind degree: %d", wind_degree);
display.drawRect(109, 24, 3, 3, WHITE); // put degree symbol ( ° )
display.drawRect(97, 56, 3, 3, WHITE);
display.display();
 
}
 
http.end(); //Close connection
 
}
 
delay(60000); // wait 1 minute
 
}
// End of code.

In file included from C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecure.h:41:0,

             from C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiServerSecure.h:20,

             from C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/ESP8266WiFi.h:41,

             from C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp:29:

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:38:5: error: 'BearSSL::WiFiClientSecure::~WiFiClientSecure()' marked override, but does not override

 ~WiFiClientSecure() override;

 ^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:43:9: error: 'int BearSSL::WiFiClientSecure::connect(const String&, uint16_t)' marked override, but does not override

 int connect(const String& host, uint16_t port) override;

     ^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:48:12: error: 'size_t BearSSL::WiFiClientSecure::write_P(const char*, size_t)' marked override, but does not override

 size_t write_P(PGM_P buf, size_t size) override;

        ^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:60:12: error: 'size_t BearSSL::WiFiClientSecure::peekBytes(uint8_t*, size_t)' marked override, but does not override

 size_t peekBytes(uint8_t *buffer, size_t length) override;

        ^

In file included from C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp:30:0:

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureAxTLS.h:36:3: error: 'axTLS::WiFiClientSecure::~WiFiClientSecure()' marked override, but does not override

~WiFiClientSecure() override;

^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureAxTLS.h:39:7: error: 'int axTLS::WiFiClientSecure::connect(const String&, uint16_t)' marked override, but does not override

int connect(const String& host, uint16_t port) override;

   ^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureAxTLS.h:47:10: error: 'size_t axTLS::WiFiClientSecure::write_P(const char*, size_t)' marked override, but does not override

size_t write_P(PGM_P buf, size_t size) override;

      ^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src/WiFiClientSecureAxTLS.h:53:10: error: 'size_t axTLS::WiFiClientSecure::peekBytes(uint8_t*, size_t)' marked override, but does not override

size_t peekBytes(uint8_t *buffer, size_t length) override;

      ^

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp: In member function 'bool HTTPClient::connect()':

C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp:1248:14: error: 'class WiFiClient' has no member named 'setNoDelay'

 _client->setNoDelay(true);

          ^

exit status 1
Error compiling for board Generic ESP8266 Module.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

This Is The Error

You can re-write the sketch using the current libraries. Here I have done it for you. It compiles for an ESP8266 but I don't have one to test on so I can't be sure it works. Give it a try.

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

ESP8266WiFiMulti WiFiMulti;

#include <ArduinoJson.h>

#include <Adafruit_SSD1306.h>

#define OLED_RESET 5 // define SSD1306 OLED reset at ESP8266 GPIO5 (NodeMCU D1)
Adafruit_SSD1306 display(OLED_RESET);

// set Wi-Fi SSID and password
const char *ssid = "TP-Link_6742";
const char *password = "26051973";

// set location and API key
String Location = "Amravati, IN";
String API_Key = "eb9274010b722f75502bbf8fa15f4872";

void setup()
{
  Serial.begin(9600);
  delay(1000);

  Wire.begin(4, 0); // set I2C pins [SDA = GPIO4 (D2), SCL = GPIO0 (D3)], default clock is 100kHz

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
  // init done

  Wire.setClock(400000L); // set I2C clock to 400kHz

  display.clearDisplay(); // clear the display buffer
  display.setTextColor(WHITE, BLACK);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Weather News By Anupam");
  display.print(" Station - Amravati");
  display.display();

  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP(ssid, password);

  Serial.print("Connecting.");
  display.setCursor(0, 24);
  display.println("Connecting...");


  display.println("Made By Anupam");
  display.display();
  while ( WiFi.status() != WL_CONNECTED )

  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("connected");
  display.print("connected");
  display.display();
  delay(1000);

}

void loop()
{
  // wait for WiFi connection
  if ((WiFiMulti.run() == WL_CONNECTED))
  {
    WiFiClient client;
    HTTPClient http;
    String payload;


    // specify request destination
    Serial.print("[HTTP] begin...\n");
    if (http.begin(client, "http://api.openweathermap.org/data/2.5/weather?q=" + Location + "&APPID=" + API_Key))    // HTTP
    {

      Serial.print("[HTTP] GET...\n");
      // start connection and send HTTP header
      int httpCode = http.GET();

      // httpCode will be negative on error
      if (httpCode > 0) // check the returning code
      {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);

        // file found at server
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
        {
          payload = http.getString();
          // Serial.println(payload);
        }
      }
      else
      {
        Serial.printf("[HTTP] GET... failed, error: %s\n",
                      http.errorToString(httpCode).c_str());
        return;
      }

      /*
         {"coord":{"lon":77.75,"lat":20.9333},
         "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],
         "base":"stations","main":{"temp":301.45,"feels_like":303.3,"temp_min":301.45,
         "temp_max":301.45,"pressure":1004,"humidity":62,"sea_level":1004,"grnd_level":966},
         "visibility":10000,"wind":{"speed":3.14,"deg":293,"gust":7.39},"clouds":{"all":94},
         "dt":1628958953,"sys":{"country":"IN","sunrise":1628900858,"sunset":1628947200},
         "timezone":19800,"id":1278718,"name":"Amrāvati","cod":200}
      */

      StaticJsonDocument<1024> doc;

      DeserializationError error = deserializeJson(doc, payload);

      if (error)
      {
        Serial.print(F("deserializeJson() failed: "));
        Serial.println(error.f_str());
        return;
      }

      //      float coord_lon = doc["coord"]["lon"]; // 77.75
      //      float coord_lat = doc["coord"]["lat"]; // 20.9333
      //
      //      JsonObject weather_0 = doc["weather"][0];
      //      int weather_0_id = weather_0["id"]; // 804
      //      const char* weather_0_main = weather_0["main"]; // "Clouds"
      //      const char* weather_0_description = weather_0["description"]; // "overcast clouds"
      //      const char* weather_0_icon = weather_0["icon"]; // "04n"
      //
      //      const char* base = doc["base"]; // "stations"
      //
      JsonObject main = doc["main"];
      float main_temp = main["temp"]; // 301.45
      //      float main_feels_like = main["feels_like"]; // 303.3
      //      float main_temp_min = main["temp_min"]; // 301.45
      //      float main_temp_max = main["temp_max"]; // 301.45
      float main_pressure = main["pressure"]; // 1004
      int main_humidity = main["humidity"]; // 62
      //      int main_sea_level = main["sea_level"]; // 1004
      //      int main_grnd_level = main["grnd_level"]; // 966
      //
      //      int visibility = doc["visibility"]; // 10000
      //
      JsonObject wind = doc["wind"];
      float wind_speed = wind["speed"]; // 3.14
      int wind_deg = wind["deg"]; // 293
      //      float wind_gust = wind["gust"]; // 7.39
      //
      //      int clouds_all = doc["clouds"]["all"]; // 94
      //
      //      long dt = doc["dt"]; // 1628958953
      //
      //      JsonObject sys = doc["sys"];
      //      const char* sys_country = sys["country"]; // "IN"
      //      long sys_sunrise = sys["sunrise"]; // 1628900858
      //      long sys_sunset = sys["sunset"]; // 1628947200
      //
      //      int timezone = doc["timezone"]; // 19800
      //      long id = doc["id"]; // 1278718
      //      const char* name = doc["name"]; // "Amrāvati"
      //      int cod = doc["cod"]; // 200


      // print data
      Serial.printf("Temperature = %.2f°C\r\n", main_temp);
      Serial.printf("Humidity = %d %%\r\n", main_humidity);
      Serial.printf("Pressure = %.3f bar\r\n", main_pressure);
      Serial.printf("Wind speed = %.1f m/s\r\n", wind_speed);
      Serial.printf("Wind degree = %d°\r\n\r\n", wind_deg);

      display.setCursor(0, 24);
      display.printf("Temperature: %5.2f C\r\n", main_temp);
      display.printf("Humidity : %d %%\r\n", main_humidity);
      display.printf("Pressure : %.3fbar\r\n", main_pressure);
      display.printf("Wind speed : %.1f m/s\r\n", wind_speed);
      display.printf("Wind degree: %d", wind_deg);
      display.drawRect(109, 24, 3, 3, WHITE); // put degree symbol ( ° )
      display.drawRect(97, 56, 3, 3, WHITE);
      display.display();
    }

    http.end(); //Close connection

  }

  delay(60000); // wait 1 minute

}
// End of code.
1 Like