Webhook widget

The error is:
“Error compiling for board NodeMCU 1.0 (ESP-12E Module)”.

Tested to Wemos D1 mini - same error for that board.

It is not something in my code. After migration all is running perfect.
Only bridge does not.
Seems there is some conflict between BlynkSimpleEsp8266 and BlynkEdgent…

I think that if you check then there will be more to the message than that, especially if verbose compiler messages are enabled.

Pete.

I use static provisioning and Arduino.OTA.
It’s easier than Blynk edgent
I think blynk edgent is a good choice if you use blynk for business only but it makes no sense to use at home.

1 Like

Yes, that is the way the project runnung in legacy - WIFI manager and Arduino OTA.
Unfortunately loaction is not at home, but at the vila. I am sure it will run in 2.0 with static too, but it is almost the same - to do changes/updates only at the local wifi network.

Blynkedgent is great option and there should be a way to have bridge working with it,

[EDIT 14th January 2022]
Version 3.0.0 of the ESP8266 Core now requires that the http.begin command now includes the WiFi Client name as well as the server path.
In the original sketch the start of the api_bridge function looked like this…

void api_bridge(String token, int virtual_pin, float value_to_send)
{
  HTTPClient http;

  String server_path = server_name + "update?token=" + token + "&pin=v" + String(virtual_pin) + "&value=" +  float(value_to_send);

  // Your Domain name with URL path or IP address with path
  http.begin(server_path.c_str());

The edited version below now looks like this:

void api_bridge(String token, int virtual_pin, float value_to_send)
{
  WiFiClient my_wifi_client;
  HTTPClient http;

  String server_path = server_name + "update?token=" + token + "&pin=v" + String(virtual_pin) + "&value=" +  float(value_to_send);

  // Your Domain name with URL path or IP address with path
  http.begin(my_wifi_client, server_path.c_str());

The updated version of the code below works with the latest ESP8266 core (v3.0.2) and also works with earlier versions (tested with 2.5.0).

[END OF 14th January 2022 EDIT]

I just tested the code using Edgent on a NodeMCU and it works perfectly…


// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "REDACTED"
#define BLYNK_DEVICE_NAME "REDACTED"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI

#include "BlynkEdgent.h"
#include <ESP8266HTTPClient.h>

String server_name = "http://lon1.blynk.cloud/external/api/"; // <<< SEE COMMENTS

String bridge_token_1 = "REDACTED"; // token for the receiving device

float temperature = 10.0; // Used for testing, will be incremented in the "push_some_data" function

BlynkTimer timer;


void setup()
{
  Serial.begin(74880);
  delay(100);

  BlynkEdgent.begin();
  timer.setInterval(10000L, push_some_data);  
}

void loop()
{
  BlynkEdgent.run();
  timer.run();
}

void push_some_data()
{
  api_bridge(bridge_token_1,0,temperature); // Token for receiving device, virtual pin number, value to send

  // Increment the temperature value to simulate changing data...  
  temperature = temperature + 0.3;
  if (temperature >= 50)
  {
    temperature = 10.0;
  }
}


void api_bridge(String token, int virtual_pin, float value_to_send)
{
  WiFiClient my_wifi_client;
  HTTPClient http;

  String server_path = server_name + "update?token=" + token + "&pin=v" + String(virtual_pin) + "&value=" +  float(value_to_send);

  // Your Domain name with URL path or IP address with path
  http.begin(my_wifi_client, server_path.c_str());
  
  // Send HTTP GET request
  Serial.print("Sending ");
  Serial.print(value_to_send);
  Serial.print(" to pin V");
  Serial.println(virtual_pin); 
  
  long request_time = millis();
  int httpResponseCode = http.GET();
  
  if (httpResponseCode>0)
  {
    Serial.print("HTTP Response code: ");
    Serial.println(httpResponseCode);
    String payload = http.getString();
  }
  else
  {
    Serial.print("Error code: ");
    Serial.print(httpResponseCode);
    Serial.print(" <-----------------------------------");    
  }
 
  Serial.print("Response time = ");
  Serial.print(millis() - request_time);
  Serial.println(" milliseconds");
  Serial.println(); 
  
  // Free resources
  http.end();
}

Serial monitor…

[2109] Hold the button for 10 seconds to reset configuration...
[4718] Using Dynamic IP: REDACTED
[4718] CONNECTING_NET => CONNECTING_CLOUD
[4830] Current time: Sat Jul 17 12:51:47 2021
[4830] Connecting to blynk.cloud:443
[5686] Ready (ping: 11ms).
[5769] CONNECTING_CLOUD => RUNNING

Sending 10.00 to pin V0
HTTP Response code: 200
Response time = 73 milliseconds

Sending 10.30 to pin V0
HTTP Response code: 200
Response time = 29 milliseconds

Sending 10.60 to pin V0
HTTP Response code: 200
Response time = 35 milliseconds

Pete.

2 Likes

Tanks a lot Pete.
I was almost given up…
First tested directly your code and it didn’t work, so I decided there could be something wrong with my Arduino IDE. And really my Blynk library was not updated.
Once updated all is OK now.

Sorry I lost your time for such a stupid thing.

Hi I’ve been trying to overcome the blynk 2.0 webhook feature. Basically I want to collect data from an https GET request and then send that data to a Virtual pin.

This was working fine in Blynk 1.0 using webhook widget however i’m not having success with Blynk 2.0.

This code works and serial prints the payload data without Blynk added code but as soon as I add the Blynk code it dooesn’t return any payload and the ESP8266 reboots.

Has anyone got any ideas?

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "Energy Monitor"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI

#include "BlynkEdgent.h"

#include <ESP8266HTTPClient.h>
//#include <SimpleTimer.h>


const char* host = "https://www.solaxcloud.com:**The rest of the URL with held**";

BlynkTimer timer1;

void RepeatTask(){
  Serial.print("connecting to ");
  Serial.println(host);


WiFiClientSecure client1;
client1.setInsecure(); //the magic line, use with caution
//client.connect(host, httpsPort);

HTTPClient httpTest;
  
httpTest.begin(client1, host);


if (httpTest.GET() == HTTP_CODE_OK){
    String payload;  
    payload = httpTest.getString(); 
    Serial.println(payload);
    Serial.println();
}
httpTest.end();

}

void setup()
{
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();

  timer1.setInterval(20000, RepeatTask);
}

void loop() {
  BlynkEdgent.run();
  timer1.run();
}

What your serial monitor shows?
Which Blynk library do you use?

Hey @Blynk_Coeur, My serial monitor shows the following…what do you think? I’m currently using Blynk 2.0 library 1.0.1.

[9040] Using Dynamic IP: 192.168.0.188
[9040] CONNECTING_NET => CONNECTING_CLOUD
[10053] Current time: Wed Aug 18 08:29:27 2021
[10053] Connecting to blynk.cloud:443
[11753] Redirecting to ny3.blynk.cloud:443
[11765] Current time: Wed Aug 18 08:29:28 2021
[11766] Connecting to ny3.blynk.cloud:443
[14427] Ready (ping: 12ms).
[14725] CONNECTING_CLOUD => RUNNING
connecting to https://www.solaxcloud.com:9443/****private URL****
connecting to https://www.solaxcloud.com:9443/****private URL****

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

>>>stack>>>

ctx: cont
sp: 3ffffcd0 end: 3fffffc0 offset: 0000
3ffffcd0:  402625fa 3fff1478 00000000 00000000  
3ffffce0:  000000fe 00000000 00000000 00000000  
3ffffcf0:  00000000 00000000 00000000 00000001  
3ffffd00:  00007fff 00000000 c030c02c 00000000  
3ffffd10:  00000000 4020c06b 000005d8 40212ec6  
3ffffd20:  00000000 4020c06b 00000020 40212ee5  
3ffffd30:  c02ac026 c00ec004 000005d8 40212620  
3ffffd40:  c09dc09c 00000001 3fff69b4 4020c06b  
3ffffd50:  00000000 c00dc003 3fff000a 4020bcd8  
3ffffd60:  00000000 00000000 3ffffd90 3fff502c  
3ffffd70:  00000000 3ffea262 3fff69b4 4020c4cd  
3ffffd80:  00000117 3fff0ca0 00000001 402128ec  
3ffffd90:  00000000 00000000 000024e3 40212fde  
3ffffda0:  00000000 3fff4efc 3fff69b4 4020b11a  
3ffffdb0:  3fff6a8c 00000ac2 3ffe8688 3ffe9fb3  
3ffffdc0:  000024e3 3fff502c 3fff69b4 3ffe9fb3  
3ffffdd0:  000024e3 3fff502c 3fff69b4 4020c659  
3ffffde0:  402162f8 1898fe2f 402162f8 1898fe2f  
3ffffdf0:  3fff69b4 00000000 3ffffe90 40215002  
3ffffe00:  00000000 0012001f 00000000 4020dc21  
3ffffe10:  0000003a 00000000 3ffffe90 4020e656  
3ffffe20:  00000000 00000000 004c006f 00000000  
3ffffe30:  3ffffe94 00000011 3fff6a91 4021220d  
3ffffe40:  00000ab3 00000ab3 3ffe8688 40100a5b  
3ffffe50:  00000000 3ffffe90 00000001 3fff00e8  
3ffffe60:  3fff69b4 00000020 3fff6a8c 3fff00e8  
3ffffe70:  3fff69b4 3ffe862c 3fff0ab0 4020e78e  
3ffffe80:  3fff69b4 3ffe862c 3fff0ab0 40202880  
3ffffe90:  3fffff14 3fff502c 0012001f 80000000  
3ffffea0:  000124e3 00001388 3fff6b7c 004c004f  
3ffffeb0:  80000000 70747468 00000073 05000000  
3ffffec0:  00000000 00000001 00000000 3fff4e14  
3ffffed0:  0011001f 80000000 00000000 4022e8c2  
3ffffee0:  00000000 00000000 00000000 00000000  
3ffffef0:  ffffffff 4bc6a700 00000000 00b7000a  
3fffff00:  00000000 00000000 00000000 00000000  
3fffff10:  00000000 40215e94 00000000 00001388  
3fffff20:  00009eb1 00000000 3fff0804 00000000  
3fffff30:  3fff69b4 3fff69b4 3fff4dfc 00000000  
3fffff40:  006b006f 00000000 3fff0c24 402089d4  
3fffff50:  3ffefea8 00000000 3ffefeac 40208be0  
3fffff60:  00005091 00009eb1 00000000 00000001  
3fffff70:  00000002 3fff08e1 00000001 3fff0c38  
3fffff80:  3fffdad0 00000000 3fff09b8 3fff0c38  
3fffff90:  3fffdad0 00000000 3fff0c24 402089ae  
3fffffa0:  3fffdad0 00000000 3fff0c24 40212a0c  
3fffffb0:  feefeffe feefeffe 3ffe8684 40100ef5  
<<<stack<<<

last failed alloc call: 4020C06B(1496)

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

last failed alloc caller: 0x4020c06b

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v00073670
~ld

>[384]

That’s an Out Of Memory message.

Pete.

Oh ok thanks Pete…Should I move to an ESP32 than?

I don’t know.
Does the exception decoder give any clues about what is causing it?

Pete.

I think the problem is here
Your MCU run into panic because of the watchdog

they say :

https://www.solaxcloud.com:4443/proxy/api/getRealtimeInfo.do?tokenId=2020
0722185111234567890&sn=ABCDEFGHIJ

you wrote 9443 instead of 4443 :thinking:

Ok Thankyou @Blynk_Coeur. I will try port 4443 it works in a Web browser which is surprising. I will code it and test it in the next few days and report back.:crossed_fingers:

1 Like

I’ve been working in the blynk.console to try and find where the webhook feature is even located but I haven’t been successful. the webhook [documentation] (Webhooks - Blynk Documentation) states,“If you don’t see this section, this means you don’t have permissions to access the webhooks. Please contact your administrator for the access rights.”
However, when I go to the permissions tab the webhook enable button is disabled and I cant re-enable it without getting an error. Currently I am in developer mode.
Has anyone else experienced this issue?

Are you using Blynk 2.0 ?

Yes Blynk 2.0. What is strange about this that the staff and user roles have sliders that I can change state. BUT after accepting the changes and saving it pops up with an error
“You can’t set higher permissions than your current role”

The functionality in the documentation is for Organisations, and can only be accessed if Blynk give you access to it. I think it’s currently disabled because it’s not ready yet.
There is currently no built-in webhook like there is in the Legacy Webkook Widget. Read this post and the ones immediately after it, earlier in this topic…

If you want to make a web API call then simply do it from your sketch rather than from the widget.

Pete.

2 Likes

Correct. Webhooks are no not enabled as functionality is limited, so we’ll enable it when we finish all features we want.

1 Like

Hey @Blynk_Coeur, I still get the same result. Port 4443 works and returns the values as expected outside of Blynk but when i try and serial print the values with the Blynk.Edgent code the MCU crashes as @PeteKnight mentioned it’s an Out of memory error.