Webhook ... Read all the documentation but still having issues

@PeteKnight I can only find out this OpenWeatherMap API instead of OpenWeather. Can show me the OpenWeather API app icon?

In that case you need to make the API call from your sketch, using @Blynk_Coeur’s example, rather than using the the Webhook widget.

Pete.

1 Like

@PeteKnight I am using Cytron esp8266 wifi shield, the coding might be different?

If its an ESP8266 then I think the ESP8266HTTPClient.h library should work fine with that sketch.

Pete.

1 Like

@Blynk_Coeur Any idea? Isit the same and can help figure out what is the issue ? My serial monitor print until wifi is connected and ready (24ms) then the openweather data doesnt appear

I’d suggest that you post your entire sketch.

Pete.

I need to see your entire code

@PeteKnight @Blynk_Coeur Hi, the one that i share is my entire code. I just want to get the data from open weather map API.

That code won’t work, because the data returned is too big to be handled by the Webhook widget,
You need to put the API call into your sketch instead of using the Webhook widget. @Blynk_Coeur has provided some partial code in post #16 and you need to incorporate this into your code, along with the necessary libraries.

Pete.

1 Like

I was asking you to provide code with API call , not webhook widget :stuck_out_tongue_winking_eye:

@Blynk_Coeur @PeteKnight I will try later and feedback to u all asap. The Json library can used in cytron ESP8266 wifi shield?

1 Like

If it’s an ESP8266 and you’re programming it in C++ then yes.

Pete.

1 Like

@PeteKnight @Blynk_Coeur Ok sure, later will feeback to both of you asap.

1 Like

image

I am using Arduino Uno stack with Cytron ESP8266 Wifi Shield. For previous case i just need to select the arduino uno board…but now i have no idea how to write my coding

Post the code that produced this error!

Pete.

#define BLYNK_PRINT Serial

#include <Arduino_JSON.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <ESP8266WiFi.h>

char auth[] = "xxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxx";
char pass[] = "xxx";

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop() 
{
  // put your main code here, to run repeatedly:
}

void forecast(){
    HTTPClient http;  //Declare an object of class HTTPClient
    http.begin("https://api.openweathermap.org/data/2.5/weather?id=xxx&appid=xxx");  //Specify request destination
    int httpCode = http.GET();     //Send the request
    if (httpCode > 0) { //Check the returning code
      payload = http.getString();   //Get the request response payload
        }
    http.end();   //Close connection
      JsonRequest();//call Json to decript weather
} 


void JsonRequest() {

  DynamicJsonDocument doc(976);
  deserializeJson(doc, payload);

  float coord_lon = doc["coord"]["lon"]; 
  float coord_lat = doc["coord"]["lat"];

  JsonObject weather_0 = doc["weather"][0];
  int weather_0_id = weather_0["id"]; 
  const char* weather_0_main = weather_0["main"];
  const char* weather_0_description = weather_0["description"]; 
  const char* weather_0_icon = weather_0["icon"]; 
  const char* base = doc["base"]; // "stations"


  JsonObject weather_1 = doc["weather"][1];
  int weather_1_id = weather_1["id"]; 
  const char* weather_1_description = weather_1["description"];

  JsonObject main = doc["main"];
  float main_temp = main["temp"]; 
  float main_feels_like = main["feels_like"];
  float main_temp_min = main["temp_min"]; 
  int main_temp_max = main["temp_max"]; 
  int main_pressure = main["pressure"];
  int main_humidity = main["humidity"]; 
  int visibility = doc["visibility"];
  float wind_speed = doc["wind"]["speed"];
  int wind_deg = doc["wind"]["deg"]; 
  int clouds_all = doc["clouds"]["all"]; 
  long dt = doc["dt"]; // 1587889504

  JsonObject sys = doc["sys"];
  int sys_type = sys["type"]; 
  int sys_id = sys["id"]; 
  const char* sys_country = sys["country"]; 

  char buff[32];

  long sys_sunrise = sys["sunrise"]; // 1587875670
  String Sunrise = String(hour(sys_sunrise))+ ":" +String(MyPrintDigits(minute(sys_sunrise)));
  sendToNextion(1, "home.Sunrise", Sunrise);

  long sys_sunset = sys["sunset"]; // 1587926436
  String Sunset = String(hour(sys_sunset))+ ":" + String(MyPrintDigits(minute(sys_sunset)));
  sendToNextion(1, "home.Sunset", Sunset);

  int timezone = doc["timezone"];
  long id = doc["id"]; 
  const char* name = doc["name"]; 
  int cod = doc["cod"];

  // temp Ext
  String T_Ext = String(main_temp);
  T_Ext = T_Ext.substring(0, 2);
  sendToNextion(1, "home.T_Ext", T_Ext);

  String D_Ext = String(main_temp);
  D_Ext = D_Ext.substring(2, 4);
  sendToNextion(1, "home.D_Ext", D_Ext);

  //Hum ext
  String H_Ext = String(main_humidity);
  sendToNextion(1, "home.H_Ext", H_Ext);
 
  String description = weather_0_description;
  sendToNextion(1, "home.weather_desc", description);
  setWeatherPicture(weather_0_id);
}

I think if I need to include esp8266 board? But I don’t think I need, previously I just select Arduino Uno as the board then it runs well. Is there any way other than Json library?

I not familiar with nodemcu, i need help on code this cytron esp8266 WIFI SHEILD

okay, I see, you’re not actually running the sketch on your ESP8266, you’re using it as an AT modem for your UNO.
In that case, I don’t think there is a way to make this work.

Pete.

1 Like

@Blynk_Coeur @PeteKnight So any other way if i used this cytron esp8266 wifi shield to get open weather map data? Or any API suggested that the webhook widget can support?

cytron esp8266 needs
CytronWiFiShield.h and CytronWiFiClient.h
Don’t know how it works, why do you prefer this unknown MCU ?
Better use ESP32 or ESP8266

@Blynk_Coeur It is much more simple compare to using nodemcu. Can u help me to figure out the coding for openweathermap API with blynk.