Ich bräuchte mal wieder die geballte Hilfe des Forums.
Kann mir jemand helfen die Werte der jsn im ESP nutzbar zu machen?
Aller 10 Sekunden sollen diese neu abgefragt werden.
Derzeit gibt es dafür nur ein Beispiel für den ESP8266 was auf dem ESP32 andauernd Crasht.
Die data.jsn sieht so aus:
{
"device":"AC ELWA-E",
"power_system":null,
"status":3,
"power":0,
"boostpower":0,
"temp1":427,
"ww1target":850,
"boostactive":0,
"legboostnext":"null",
"date":"29.05.24",
"loctime":"13:55:18",
"unixtime":1716990918,
"uptime":9,
"ctrlstate":"Modbus Read received",
"blockactive":0,
"meter1_id":null,
"meter1_ip":"null",
"meter2_id":null,
"meter2_ip":"null",
"meter3_id":null,
"meter3_ip":"null",
"meter4_id":null,
"meter4_ip":"null",
"meter5_id":null,
"meter5_ip":"null",
"meter6_id":null,
"meter6_ip":"null",
"meter_ss":null,
"meter_ssid":"null",
"surplus":null,
"m0sum":null,
"m0l1":null,
"m0l2":null,
"m0l3":null,
"m0bat":null,
"m1sum":null,
"m1l1":null,
"m1l2":null,
"m1l3":null,
"m1devstate":null,
"m2sum":null,
"m2l1":null,
"m2l2":null,
"m2l3":null,
"m2soc":null,
"m2state":null,
"m2devstate":null,
"m3sum":null,
"m3l1":null,
"m3l2":null,
"m3l3":null,
"m3soc":null,
"m3devstate":null,
"m4sum":null,
"m4l1":null,
"m4l2":null,
"m4l3":null,
"m4devstate":null,
"ecarstate":"null",
"ecarboostctr":null,
"mss2":"null",
"mss3":"null",
"mss4":"null",
"mss5":"null",
"mss6":"null",
"mss7":"null",
"mss8":"null",
"mss9":"null",
"mss10":"null",
"mss11":"null",
"volt_mains":234,
"volt_aux":4,
"freq":49998,
"tempchip":327,
"fan_speed":0,
"ps_state":0,
"ctrl_errors":0,
"warnings":0,
"fwversionlatest":"null",
"coversionlatest":"null",
"psversionlatest":"null",
"upd_state":0,
"ps_upd_state":0,
"co_upd_state":0,
"cur_eth_mode":0,
"wifi_signal":0,
"wifi_list":[{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0},{"ssid":"","signal":0}],
"cur_ip":"192.168.0.102",
"cur_sn":"255.255.255.0",
"cur_gw":"192.168.0.1",
"cur_dns":"192.168.0.1",
"cloudstate":0,
"debug_ip":"0.0.0.0"
}
Und hier das Beispiel für den ESP8266 aber wie Beschrieben nicht lauffähig und Fragt die Schnittstelle viel zu oft ab.
/*
Rui Santos
Complete project details at Complete project details at https://RandomNerdTutorials.com/esp32-http-get-post-arduino/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
#include <WiFi.h>
#include <HTTPClient.h>
#include <Arduino_JSON.h>
const char* ssid = "";
const char* password = "";
//Your Domain name with URL path or IP address with path
const char* serverName = "http://192.168.0.102/data.jsn";
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 10000;
String sensorReadings;
float sensorReadingsArr[80];
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
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.");
delay(2000);
}
void loop() {
//Send an HTTP POST request every 10 minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}
String httpGETRequest(const char* serverName) {
WiFiClient client;
HTTPClient http;
// Your Domain name with URL path or IP address with path
http.begin(client, serverName);
// Send HTTP POST request
int httpResponseCode = http.GET();
String payload = "{}";
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
payload = http.getString();
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();
return payload;
}
Ich hoffe sehr das Jemand die JSON auswerten kann.
Danke Gruß Robert