Webhook from browser does not work (though I can control the pin from Blynk app)

Dear forum

I want to set a pin (LED) from a web browser but I just cannot get this webhook to work, though the setup is ultra simple and I can control the LED from within the Blynk app using a simple button.

  • NodeMCU ESP 8266
  • Arduino 1.8.8
  • Control LED on pin D1 (GPIO5)

I searched a lot and tried many URLs in the browser (the IP I got from a Ping request):
http://139.59.206.133/7170b21b16514b22a9d9241733d51f2f/pin/D1?value=1
http://139.59.206.133/7170b21b16514b22a9d9241733d51f2f/update/D1?value=1

Not working…

Plain and simple code:

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "7170b21b16514b22a9d9241733d51f2f";

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

int  outputPin = 5; // Pin D1

void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(outputPin, OUTPUT);
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

Is there anybody that can help me? What am I missing?

Thanks and best regards

  • MakerAndy

P.S. Do I need to configure the WebHook widget in the Blynk app? I don’t think so, this seems to be for outgoing webhooks to a 3rd party.

A few observations…

Issue 1

You’re using a NodeMCU or Wemos D1 Mini, which has labels screen printed on it that say things like D1, D2 etc.
It seems that you want to control the pin that’s labelled D1, which in the code you correctly identify as GPIO5.

In the Blynk app, you’ve probably seen digital pins labelled as D1, D2 etc, and thought that these correlate to the labels screen prinnted on your NodeMCU board. They don’t!
The D numbers in the app relate to the GPIO numbers of the pins, not the numbers printed on the board.

When you’re using the API, you also use GPIO numbers, so if you’re trying to control the pin that has D1 printed next to it, you need to use D5 in your API url.

Issue 2
You’ve probably read that if you’re using a service like IFTTT then rather than using the url of blynk-cloud.com you should use use the IP address that you get when you ping blynk-cloud.com from your PC.
This is because the IFTTT server that you’re using could be anywhere in the world and blynk-cloud.com may take it to the wrong Blynk server, in which case it won’t find your project, and give an ‘invalid Auth code’ message.
If you’re doing this from the browser on your PC them blynk-cloud.com will work fine.
If you are using the IP address in your API call then you probably need to append the port onto the end, so 139:59:206:133:8080 is probably what you need.

Have you tried using the API reference console to build your API string:

https://blynkapi.docs.apiary.io/#reference/0/write-pin-value-via-get/set-widget-property-via-get?console=1

Pete.

1 Like

Hi Pete

Thank you VERY much, that solved it, I just needed to write D5 instead of D1 in the webhook and that solved it! Of the 2 statements I mentioned only …/update/… worked, not …/pin/…, but at least I got a working solution.

And yes, I tried the API reference console before, it’s not working there, but probably due to the fact that I cannot set the IP address as the hostname blynk-cloud.com is fix (and probably points to another server than mine).

Thanks again for your quick feedback :slight_smile:
-MakerAndy

1 Like

I’m not sure where the /pin/ syntax came from, but I’d expect to have to replace “pin” with “D5” anyway.
And to answer an earlier question, you don’t need the webhook widget in your app for this to work (although I see that you do have one there at the moment).

Glad its working, I’ll mark the topic as solved.

BTW - don’t forget to change your Auth code, otherwise anybody who reads this forum can activate whatever is attached to pin GPIO5.

Pete.

yes, solved. It’s only a temp test setup with a LED, but I changed the Auth code, thanks again!

1 Like