hi,
I am using the blynk example here, but instead of the actual GET data going into V0 I am getting the literal URL https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt as the value of V0… and not the logo itself… any idea why?
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
WARNING!
It's very tricky to get it working. Please read this article:
http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
This example shows how to fetch data using WebHook GET method
App project setup:
WebHook widget on V0, method: GET, url: /pin/
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
// Allow for receiving messages up to 512 bytes long
//#define BLYNK_MAX_READBYTES 512
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "myauth";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "myssid";
char pass[] = "mypass";
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
BLYNK_WRITE(V0)
{
Serial.println("WebHook data:");
Serial.println(param.asStr());
}
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.com", 8442);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);
Blynk.virtualWrite(V0, "https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");
// You can perform HTTPS requests even if your hardware alone can't handle SSL
// Blynk can also fetch much bigger messages,
// if hardware has enough RAM (set BLYNK_MAX_READBYTES to 4096)
//Blynk.virtualWrite(V0, "https://api.sunrise-sunset.org/json?lat=50.4495484&lng=30.5253873&date=2016-10-01");
}
void loop()
{
Blynk.run();
}
This error is just a reminder of possible error case, I guess we’ll change its color for that case. That “/pin/” would be saved in the WebHook and it will use it, about how it works (or not)) maybe @Dmitriy could respond.
but if I also add in a Terminal Widget, on same V0, it will show this… (only after the 2nd button press, then it catches up and repeats the URL each press)…
So, I agree, it is using the /pin/ but not really the way it should (as indicated in the example).
Yay!!! my first real use of Webhooks… but just not seeing the glamor
@nirkon as the library is at the moment the following sketch will work for ESP standalone. As per the comments use https:///pin/ (3 forward slashes after https:) in the Webhook widget.
/*************************************************************
Webhook_GETrev1.ino for https://community.blynk.cc/t/blynk-webhook-get-request-example-not-working/21754
This example shows how to fetch data using WebHook GET method
App project setup:
WebHook widget on V0, method: GET, url: https:///pin/ (3 forward slashes after https:)
Button in PUSH mode on V1 - push button to display Blynk logo in Serial Monitor
*************************************************************/
#define BLYNK_PRINT Serial
// Allow for receiving messages up to 512 bytes long
//#define BLYNK_MAX_READBYTES 512
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxx";
BLYNK_WRITE(V0)
{
Serial.println("WebHook data:");
Serial.println(param.asStr());
}
BLYNK_WRITE(V1)
{
if(param.asInt()){
//Blynk.virtualWrite(V0, 1);
Blynk.virtualWrite(V0, "raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
Blynk.virtualWrite(V0, "raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");
// You can perform HTTPS requests even if your hardware alone can't handle SSL
// Blynk can also fetch much bigger messages,
// if hardware has enough RAM (set BLYNK_MAX_READBYTES to 4096)
//Blynk.virtualWrite(V0, "api.sunrise-sunset.org/json?lat=50.4495484&lng=30.5253873&date=2016-10-01");
}
void loop()
{
Blynk.run();
}