Hi friends. is it possible to remove [" β] symbol from webhook get ? I just need the pin value in webhook get without [β "].
here is my sketch:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "GEraVZrPqUS3wMJnPJGuSUdCEAuVhtLP";
char ssid[] = "MikroTik Tesla";
char pass[] = "12345678";
char server[] = "10.5.51.5";
BLYNK_WRITE(V0)
{
String dat = param.asStr();
Serial.println("WebHook data:");
Serial.println(param.asStr());
Blynk.virtualWrite(V1, dat);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, server, 8080);
// 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();
Blynk.virtualWrite(V0, "10.5.51.5:8080/1ba32e9c834340ed83a795c083c03c4a/get/V28");
}
the serial output:
WebHook data:
["56.4"]
WebHook data:
["56.9"]
WebHook data:
["56.9"]
maybe you can try myString.toFloat()
1 Like
Blynk_Coeur:
myString.toFloat()
thanks for reply. now showing 0.00 at serial output
BLYNK_WRITE(V0)
{
String dat = param.asStr();
float myFloat = dat.toFloat();
Serial.println("WebHook data:");
Serial.println(myFloat);
Blynk.virtualWrite(V1, myFloat);
}
WebHook data:
0.00
You have to extract string 56.9 with substring function before converting
1 Like
ErfanDL:
dat.toFloat();
like this? String dat = dat.toFloat();
This will not compiled!
error: conversion from 'float' to non-scalar type 'String' requested
I suggest you to cancel [" and β] before convertion
may be using dat.replace(β[", ββ) and dat.replace("]", ββ) ?
1 Like
But I donβt understand why you get [β56.9β]
I tried https://fra1.blynk.cloud/external/api/get?token=XXXXXXXXXXXXXX&v3
and obtain the temperature without any bracket
what if you change datastream V1 to Double ?
1 Like
Maybe this problem has been fixed in Blynk 2.0 ?
Double also displays the value 0.00
I am using Blynk 2.0
but why your V1 result is a string ?
1 Like
Itβs legacy local server.
At least the Blynk.virtualWrite in the void loop is only flooding @ErfanDL βs local server
Not exactly sure why an API call is being used to get a Blynk virtual pin value from within a Blynk sketch though!
Pete.
2 Likes
Iβm just testing something with my local server. I need to get the data of a Blynk server from Webhook on multiple nodemcus.
Thanks, my problem was solved with your suggestion.
BLYNK_WRITE(V0)
{
String dat = param.asStr();
dat.replace("[", "");
dat.replace("]", "");
dat.replace("\"", "");
float myfl = dat.toFloat();
Serial.println("WebHook data:");
Serial.println(myfl);
Blynk.virtualWrite(V1, myfl);
}
WebHook data:
58.00
WebHook data:
56.90
1 Like
It would be far more efficient to use Bridge, or a BLYNK_WRITE(Vpin) to do API calls that write the data values to virtual pins relating to the Auth tokens of the various NodeMCUs, rather than have each NodeMCU polling the Blynk server via an API call.
Pete.
1 Like