Interrogation du json enphase

Bonjour je suis confronté a un problème concernant l interrogation d un json en local , je vous joint mon code ainsi qu'une capture d écran

void enphasedata(){
  HTTPClient http;  //Declare an object of class HTTPClient
  int httpCode = 0;
  String payload1;  //Get the request response payload



  http.begin("http://envoy/production.json");
  httpCode = http.GET();  //Send the request

  if (httpCode > 0) {  //Check the returning code

    payload1 = http.getString();  //Get the request response payload
    Serial.print("voici le payload =");
    Serial.println(payload1);
    //create a json buffer where to store the json data
    StaticJsonDocument<5000> jsonBuffer;

    auto error = deserializeJson(jsonBuffer, payload1);
    if (error) {
      Serial.println("parseObject() failed");
      return;
    }


    //get the data from the json tree
    String wNow = jsonBuffer["wNow"];
    Serial.print("wNow =");
    Serial.println(wNow);
    }
    else
    {
      Serial.println("http get failed");
      Serial.print("code erreur http =");
      Serial.println(httpCode);
    }

}

voici également le retour du json

{"production":[{"type":"inverters","activeCount":8,"readingTime":1688204942,"wNow":772,"whLifetime":4580084},{"type":"eim","activeCount":1,"measurementType":"production","readingTime":1688205055,"wNow":460.319,"whLifetime":4570205.482,"varhLeadLifetime":1.267,"varhLagLifetime":1419328.88,"vahLifetime":5604404.333,"rmsCurrent":2.233,"rmsVoltage":232.965,"reactPwr":135.672,"apprntPwr":519.702,"pwrFactor":0.87,"whToday":1467.482,"whLastSevenDays":111398.482,"vahToday":2926.333,"varhLeadToday":0.267,"varhLagToday":1624.88}],"consumption":[{"type":"eim","activeCount":1,"measurementType":"total-consumption","readingTime":1688205055,"wNow":475.854,"whLifetime":8432819.699,"varhLeadLifetime":3975683.408,"varhLagLifetime":1470210.81,"vahLifetime":9040003.829,"rmsCurrent":4.437,"rmsVoltage":233.062,"reactPwr":-473.314,"apprntPwr":1034.082,"pwrFactor":0.46,"whToday":6025.699,"whLastSevenDays":135786.699,"vahToday":7781.829,"varhLeadToday":4397.408,"varhLagToday":1657.81},{"type":"eim","activeCount":1,"measurementType":"net-consumption","readingTime":1688205055,"wNow":15.535,"whLifetime":5147796.691,"varhLeadLifetime":3975682.14,"varhLagLifetime":50881.929,"vahLifetime":9040003.829,"rmsCurrent":2.203,"rmsVoltage":233.159,"reactPwr":-337.642,"apprntPwr":514.195,"pwrFactor":0.03,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}

Retour serial

test enphase http get failed
code erreur http =-1

Merci pour votre expertise

Edit cela semble venir de l enpahse si j interroge un autre json cela fonctionne =s

Je ne sais pas ce que tu entends par 'en phase' mais je pense que le problème ici est que tu ne reçois rien par le GET

Sans doute un onduleur

En effet, j'ai trouvé ça

Passerelle de communication Enphase Envoy-S offrant une mesure intégrée de la production photovoltaïque et de la consommation d’énergie

Nombre de périphériques détectés Jusqu’à 600 micro-onduleurs

Bonjour
C est bien la gatway enphase qui me fourni le json , que je ne parvient pas a parse :s

pour vous la gatway ne me répond pas ?
Pourquoi répond t elle parfaitement sur un navigateur ?

C'est ce que j'imagine à la lecture de ce message.
Pourquoi, je ne saurais dire, il faudrait voir le code entier, ou les messages qu'il envoie sur la console.

as tu une idée a me soumettre pour faire ce test ? Merci

Tu peux tester les exemples des bibliothèques, par exemple :

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.