Thank you for your prompt response.
I used your code above for Edgent, and changed the token and url.
However the response i get is still -5.
Sending 11.80 to pin V2
Error code: -5 <-----------------------------------Response time = 98 milliseconds
Sending 12.10 to pin V2
Error code: -5 <-----------------------------------Response time = 97 milliseconds
Sending 12.40 to pin V2
Error code: -5 <-----------------------------------Response time = 99 milliseconds
Here is the code
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "MYID"
#define BLYNK_DEVICE_NAME "RELAY"
#define APP_DEBUG
#define BLYNK_WIFI_SSID "mywifi"
#define BLYNK_WIFI_PASS "mypass"
#define BLYNK_PRINT Serial
//#define BLYNK_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 = "https://blr1.blynk.cloud/external/api/"; // <<< SEE COMMENTS
String bridge_token_1 = "mytoken"; // 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(115200);
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,2,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();
}