Odczyt danych z falownika Fronius
Aktualna to: fro32071.upd, niestety nie wiem jaka była poprzednia wersja.
To:
Kod: Zaznacz cały
{ "Body" : { "Data" : {} }, "Head" : { "RequestArguments" : { "DataCollection" : "CommonInverterData", "DeviceClass" : "Inverter", "Scope" : "Device" }, "Status" : { "Code" : 6, "Reason" : "CGI-Args: Invalid parameter '' for attribute 'DeviceId' (must be numeric)", "UserMessage" : "" }, "Timestamp" : "2021-08-11T16:53:40+02:00" } }
Kod: Zaznacz cały
{ "Body" : { "Data" : { "DAY_ENERGY" : { "Unit" : "Wh", "Value" : 16296 }, "DeviceStatus" : { "ErrorCode" : 0, "LEDColor" : 2, "LEDState" : 0, "MgmtTimerRemainingTime" : -1, "StateToReset" : false, "StatusCode" : 7 }, "FAC" : { "Unit" : "Hz", "Value" : 50.020000000000003 }, "IAC" : { "Unit" : "A", "Value" : 1.96 }, "IDC" : { "Unit" : "A", "Value" : 1.47 }, "PAC" : { "Unit" : "W", "Value" : 468 }, "TOTAL_ENERGY" : { "Unit" : "Wh", "Value" : 12152650 }, "UAC" : { "Unit" : "V", "Value" : 237.40000000000001 }, "UDC" : { "Unit" : "V", "Value" : 350.30000000000001 }, "YEAR_ENERGY" : { "Unit" : "Wh", "Value" : 2246651.75 } } }, "Head" : { "RequestArguments" : { "DataCollection" : "CommonInverterData", "DeviceClass" : "Inverter", "DeviceId" : "1", "Scope" : "Device" }, "Status" : { "Code" : 0, "Reason" : "", "UserMessage" : "" }, "Timestamp" : "2021-08-11T17:02:59+02:00" } }
Na podstawie w/w fragmentu kodu wygenerowałem sobie plik json w Arduino który dostępny jest na ESP1 symulujący inwerter Froniusa. Na ESP2 mam wgrany oficjalny plik dostępny na https://github.com/SUPLA/supla-arduino do obsługi Froniusa.
ESP1 generuję takie dane:
Dzięki temu w przeglądarce na PC uzyskuje piękny plik JSON z ESP1:
W trakcie prób z firmware do odczytu Froniusa widzę jak ESP2 łączy się z ESP1, widzę że pobiera dane JSON, ale nie konwertuje ich za chiny ludowe.
W kodzie na ESP2:
Tutaj widać że ESP2 odbiera dane prawidłowo:
Jednak nie przechodzi za wiersz:
i tym samym w apce nie mam żadnych danych.
Już mi ręce opadają.
ESP1 generuję takie dane:
Kod: Zaznacz cały
httpServer.on("/solar_api/v1/GetInverterRealtimeData.cgi", []() {
text = "{ \"Body\" : { \"Data\" : { \"DAY_ENERGY\" : { \"Unit\" : \"Wh\", \"Value\" : 16296 }, \"DeviceStatus\" : { \"ErrorCode\" : 0, \"LEDColor\" : 2, \"LEDState\" : 0, \"MgmtTimerRemainingTime\" : -1, \"StateToReset\" : false, \"StatusCode\" : 7 }, \"FAC\" : { \"Unit\" : \"Hz\", \"Value\" : 50.020000000000003 }, \"IAC\" : { \"Unit\" : \"A\", \"Value\" : 1.96 }, \"IDC\" : { \"Unit\" : \"A\", \"Value\" : 1.47 }, \"PAC\" : { \"Unit\" : \"W\", \"Value\" : 468 }, \"TOTAL_ENERGY\" : { \"Unit\" : \"Wh\", \"Value\" : 12152650 }, \"UAC\" : { \"Unit\" : \"V\", \"Value\" : 237.40000000000001 }, \"UDC\" : { \"Unit\" : \"V\", \"Value\" : 350.30000000000001 }, \"YEAR_ENERGY\" : { \"Unit\" : \"Wh\", \"Value\" : 2246651.75 } } }, \"Head\" : { \"RequestArguments\" : { \"DataCollection\" : \"CommonInverterData\", \"DeviceClass\" : \"Inverter\", \"DeviceId\" : \"1\", \"Scope\" : \"Device\" }, \"Status\" : { \"Code\" : 0, \"Reason\" : \"\", \"UserMessage\" : \"\" }, \"Timestamp\" : \"2021-08-11T17:02:59+02:00\" } }";
text += "\n";
httpServer.send(200, "application/json", text );
});
W trakcie prób z firmware do odczytu Froniusa widzę jak ESP2 łączy się z ESP1, widzę że pobiera dane JSON, ale nie konwertuje ich za chiny ludowe.
W kodzie na ESP2:
Kod: Zaznacz cały
while (pvClient.available()) {
char c;
c = pvClient.read();
Serial.print(c); // To dodałem do kodu by widziec czy odbiera dane
if (c == '\n') {
if (startCharFound) {
if (bytesCounter > 79) bytesCounter = 79;
buf[bytesCounter] = '\0';
char varName[80];
char varValue[80];
sscanf(buf, " %s : %s", varName, varValue);
if (valueToFetch != NONE && strncmp(varName, "Value", strlen("Value")) == 0) { //Za ten wiersz już nie przechodzi.
Jednak nie przechodzi za wiersz:
Kod: Zaznacz cały
if (valueToFetch != NONE && strncmp(varName, "Value", strlen("Value")) == 0) { //Za ten wiersz już nie przechodzi.
Już mi ręce opadają.
Fronius wysyłał każdą daną w osobnej lini tekstu. Kod do parsowania odpowiedzi potrafi przetworzyć linię o maksymalnej długości 80 bajtów.Duch__ pisze: ↑śr sie 18, 2021 8:03 am Na podstawie w/w fragmentu kodu wygenerowałem sobie plik json w Arduino który dostępny jest na ESP1 symulujący inwerter Froniusa. Na ESP2 mam wgrany oficjalny plik dostępny na https://github.com/SUPLA/supla-arduino do obsługi Froniusa.
....
W trakcie prób z firmware do odczytu Froniusa widzę jak ESP2 łączy się z ESP1, widzę że pobiera dane JSON, ale nie konwertuje ich za chiny ludowe.
Ten kod nie potrafi parsować jsona, tylko wyłuskiwał istotne dane z tekstu, który przychodził.
Widzimy się na Supla Offline Party vol. 2
Jakby któryś z kolegów chciał zasymulować sobie Inwerter Froniusa i przesyłać swoje liczby to poniżej wrzucam przykładowy kod generujący odpowiedni plik JSON.
Kod: Zaznacz cały
httpServer.on("/solar_api/v1/GetInverterRealtimeData.cgi", []() {
text = "{\n";
text += "\"Body\" : {\n";
text += "\"Data\" : {\n";
text += "\"DAY_ENERGY\" : {\n";
text += "\"Unit\" : \"Wh\",\n";
text += "\"Value\" : 16390\n";
text += "},\n";
text += "\n\n";
text += "\"DeviceStatus\" : {\n";
text += "\"ErrorCode\" : 0,\n";
text += "\"LEDColor\" : 2,\n";
text += "\"LEDState\" : 0,\n";
text += "\"MgmtTimerRemainingTime\" : -1,\n";
text += "\"StateToReset\" : false,\n";
text += "\"StatusCode\" : 7\n";
text += "},\n";
text += "\"FAC\" : {\n";
text += "\"Unit\" : \"Hz\",\n";
text += "\"Value\" : " + String(Wartosc 1) + "\n";
text += "\"IAC\" : {\n";
text += "\"Unit\" : \"A\",\n";
text += "\"Value\" : "+String(Wartosc 2)+"\n";
text += "\"IDC\" : {\n";
text += "\"Unit\" : \"A\",\n";
text += "\"Value\" : 6.7400000000000002\n";
text += "},\n";
text += "\"PAC\" : {\n";
text += "\"Unit\" : \"W\",\n";
text += "\"Value\" : "+String(Batt_P)+"\n";
text += "},\n";
text += "\"TOTAL_ENERGY\" : {\n";
text += "\"Unit\" : \"Wh\",\n";
text += "\"Value\" : "+String(Wartosc 3 * 1000)+"\n";
text += "},\n";
text += "\"UAC\" : {\n";
text += "\"Unit\" : \"V\",\n";
text += "\"Value\" : "+String(Wartosc 4)+"\n";
text += "},\n";
text += "\"UDC\" : {\n";
text += "\"Unit\" : \"V\",\n";
text += "\"Value\" : 674\n";
text += "},\n";
text += "\"YEAR_ENERGY\" : {\n";
text += "\"Unit\" : \"Wh\",\n";
text += "\"Value\" : 775271\n";
text += "}\n";
text += "}\n";
text += "},\n";
text += "\"Head\" : {\n";
text += "\"RequestArguments\" : {\n";
text += "\"DataCollection\" : \"CommonInverterData\",\n";
text += "\"DeviceClass\" : \"Inverter\",\n";
text += "\"DeviceId\" : \"1\",\n";
text += "\"Scope\" : \"Device\"\n";
text += "},\n";
text += "\"Status\" : {\n";
text += "\"Code\" : 0,\n";
text += "\"Reason\" : \"\",\n";
text += "\"UserMessage\" : \"\"\n";
text += "},\n";
text += "\"Timestamp\" : \"2018-03-01T12:49:42+01:00\"\n";
text += "}\n";
text += "}\n";
text += "\n";
httpServer.send(200, "application/json", text );
});
-
- Posty: 53
- Rejestracja: czw lut 28, 2019 8:22 pm
Witam,
Pomoże ktoś? Podczas kompilacji wyskakują mi takie błędy
Pomoże ktoś? Podczas kompilacji wyskakują mi takie błędy
Kod: Zaznacz cały
Arduino:1.8.15 (Windows Store 1.8.49.0) (Windows 10), Płytka:"Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 8MB (FS:6MB OTA:~1019KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Fronius:452:75: error: extended character ↵ is not valid in an identifier
452 | <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:457:56: error: extended character ↵ is not valid in an identifier
457 | <span class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:493:75: error: extended character ↵ is not valid in an identifier
493 | <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:498:56: error: extended character ↵ is not valid in an identifier
498 | <span class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:525:75: error: extended character ↵ is not valid in an identifier
525 | <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:530:56: error: extended character ↵ is not valid in an identifier
530 | <span class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:557:75: error: extended character ↵ is not valid in an identifier
557 | <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:562:56: error: extended character ↵ is not valid in an identifier
562 | <span class="d-inline-block ml-1 v-align-middle">↵</span>
| ^
Fronius:1610:9: error: extended character ’ is not valid in an identifier
1610 | You can’t perform that action at this time.
| ^
Znaleziono wiele bibliotek w "SuplaDevice.h"
Wykorzystane: D:\Moje dokumenty\Arduino\libraries\supla-arduino-master
Niewykorzystane: D:\Moje dokumenty\Arduino\libraries\SuplaDevice
Znaleziono wiele bibliotek w "WiFiClient.h"
Wykorzystane: D:\Moje dokumenty\ArduinoData\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi
Niewykorzystane: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
extended character ↵ is not valid in an identifier
Ten raport powinien zawierać więcej informacji jeśli w
File -> Preferencje zostanie włączona opcja "Pokaż
szczegółowe informacje podczas kompilacji"