Kolega shimano73 próbuje uskutecznić linki bezpośrednie a kolega SOYER próbuje go przekonać do zrobienia tego samego ale po mqtt. Trochę się nie spotkaliście w tym samym miejscu. Po wklejeniu linka w przeglądarkę można podejrzeć każdą zmienną którą on udostępnia.
Poniżej kawałek kodu który powinien coś rozjaśnić, kod testowy i z tego co pamiętam to działał ale bez gwarancji
Code: Select all
#include <Arduino.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
const char* ssid = "wifissid";
const char* password = "wifipass";
WiFiClientSecure client;
String serverName = "https://svrxx.supla.org/direct/xxxxxxxxxxx/read?format=json"; //Direct Link mew-01
unsigned long lastTime = 0;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
client.setInsecure();
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");
}
void loop() {
//Send an HTTP POST request every 10 minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
String serverPath = serverName;
// Your Domain name with URL path or IP address with path
http.begin(client, serverPath.c_str());
// Send HTTP GET request
int httpResponseCode = http.GET();
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String json = http.getString();
StaticJsonDocument<600> filter;
filter["phases"][0]["totalForwardActiveEnergy"] = true;
StaticJsonDocument<600> doc;
deserializeJson(doc, json, DeserializationOption::Filter(filter));
double val15 = doc["phases"][0]["totalForwardActiveEnergy"];
double val16 = doc["phases"][1]["totalForwardActiveEnergy"];
double val17 = doc["phases"][2]["totalForwardActiveEnergy"];
Serial.println("Energia Czynna Pobrana:");
Serial.println(val15);
Serial.println(val16);
Serial.println(val17);
Serial.print("Razem:");
Serial.print(val15 + val16 + val17);
Serial.println(" kWh");
Serial.println(" ");
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}
Linki są trochę ospałe, po MQTT odświeżanie wartości jest porównywalne do tej w apce Supli.
You do not have the required permissions to view the files attached to this post.