#include <NetworkClient.h>
#include <NetworkClientSecure.h>
#define TIMEOUT_READ_PAYLOAD 100
const char *json = R"====(
{
"eid": 704643328,
"timestamp": 1787310047,
"actEnergyDlvd": 10049605.907,
"actEnergyRcvd": 46781.086,
"apparentEnergy": 12936586.836,
"reactEnergyLagg": 3743089.616,
"reactEnergyLead": 1.122,
"instantaneousDemand": 2246.673,
"activePower": 2246.673,
"apparentPower": 2250.9,
"reactivePower": 111.447,
"pwrFactor": 1.0,
"voltage": 236.728,
"current": 9.51,
"freq": 50.0,
"channels": [
{
"eid": 1778385169,
"timestamp": 1787310047,
"actEnergyDlvd": 10049605.907,
"actEnergyRcvd": 46781.086,
"apparentEnergy": 12936586.836,
"reactEnergyLagg": 3743089.616,
"reactEnergyLead": 1.122,
"instantaneousDemand": 2246.673,
"activePower": 2246.673,
"apparentPower": 2250.9,
"reactivePower": 111.447,
"pwrFactor": 1.0,
"voltage": 236.728,
"current": 9.51,
"freq": 50.0
},
{
"eid": 1778385170,
"timestamp": 1787310047,
"actEnergyDlvd": 0.057,
"actEnergyRcvd": 96475.417,
"apparentEnergy": 28719.312,
"reactEnergyLagg": 2268.58,
"reactEnergyLead": 7.308,
"instantaneousDemand": -0.481,
"activePower": -0.481,
"apparentPower": 0.929,
"reactivePower": 0.086,
"pwrFactor": 0.0,
"voltage": 9.896,
"current": 0.094,
"freq": 50.0
},
{
"eid": 1778385171,
"timestamp": 1787310047,
"actEnergyDlvd": 0.0,
"actEnergyRcvd": 125358.361,
"apparentEnergy": 5557.902,
"reactEnergyLagg": 2258.595,
"reactEnergyLead": 1.418,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": -0.0,
"reactivePower": -0.0,
"pwrFactor": 0.0,
"voltage": 5.448,
"current": -0.0,
"freq": 50.0
}
]
},
{
"eid": 704643584,
"timestamp": 1787310047,
"actEnergyDlvd": 17736267.275,
"actEnergyRcvd": 0.0,
"apparentEnergy": 20515372.536,
"reactEnergyLagg": 976961.207,
"reactEnergyLead": 2989657.391,
"instantaneousDemand": 413.758,
"activePower": 413.758,
"apparentPower": 462.389,
"reactivePower": 7.984,
"pwrFactor": 0.892,
"voltage": 236.917,
"current": 1.958,
"freq": 50.0,
"channels": [
{
"eid": 1778385425,
"timestamp": 1787310047,
"actEnergyDlvd": 17736267.275,
"actEnergyRcvd": 0.0,
"apparentEnergy": 20515372.536,
"reactEnergyLagg": 976961.207,
"reactEnergyLead": 2989657.391,
"instantaneousDemand": 413.758,
"activePower": 413.758,
"apparentPower": 462.389,
"reactivePower": 7.984,
"pwrFactor": 0.892,
"voltage": 236.917,
"current": 1.958,
"freq": 50.0
},
{
"eid": 1778385426,
"timestamp": 1787310047,
"actEnergyDlvd": 70502.341,
"actEnergyRcvd": 0.0,
"apparentEnergy": 1759.489,
"reactEnergyLagg": 2086.514,
"reactEnergyLead": 0.0,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": 0.0,
"reactivePower": -0.0,
"pwrFactor": 0.0,
"voltage": 7.703,
"current": 0.0,
"freq": 50.0
},
{
"eid": 1778385427,
"timestamp": 1787310047,
"actEnergyDlvd": 41772.668,
"actEnergyRcvd": 0.0,
"apparentEnergy": 3428.094,
"reactEnergyLagg": 2079.859,
"reactEnergyLead": 6.287,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": -0.0,
"reactivePower": -0.0,
"pwrFactor": 0.0,
"voltage": 8.014,
"current": 0.0,
"freq": 50.0
}
]
},
{
"eid": 1023410688,
"timestamp": 1787310040,
"actEnergyDlvd": 0.0,
"actEnergyRcvd": 0.0,
"apparentEnergy": 0.0,
"reactEnergyLagg": 0.0,
"reactEnergyLead": 0.0,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": 0.0,
"reactivePower": 0.0,
"pwrFactor": 0.0,
"voltage": 0.0,
"current": 0.0,
"freq": 0.0,
"channels": [
{
"eid": 2097152513,
"timestamp": 1787310040,
"actEnergyDlvd": 0.0,
"actEnergyRcvd": 0.0,
"apparentEnergy": 0.0,
"reactEnergyLagg": 0.0,
"reactEnergyLead": 0.0,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": 0.0,
"reactivePower": 0.0,
"pwrFactor": 0.0,
"voltage": 0.0,
"current": 0.0,
"freq": 0.0
},
{
"eid": 2097152258,
"timestamp": 1787310040,
"actEnergyDlvd": 0.0,
"actEnergyRcvd": 0.0,
"apparentEnergy": 0.0,
"reactEnergyLagg": 0.0,
"reactEnergyLead": 0.0,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": 0.0,
"reactivePower": 0.0,
"pwrFactor": 0.0,
"voltage": 0.0,
"current": 0.0,
"freq": 0.0
},
{
"eid": 2097152515,
"timestamp": 1787310040,
"actEnergyDlvd": 0.0,
"actEnergyRcvd": 0.0,
"apparentEnergy": 0.0,
"reactEnergyLagg": 0.0,
"reactEnergyLead": 0.0,
"instantaneousDemand": 0.0,
"activePower": 0.0,
"apparentPower": 0.0,
"reactivePower": 0.0,
"pwrFactor": 0.0,
"voltage": 0.0,
"current": 0.0,
"freq": 0.0
}
]
}
])====";
NetworkClientSecure clientSecu;
const float PmaxReseau = 36000.0f;
float PfloatMax(float Pin) {
return constrain(Pin, float(-1.0F * PmaxReseau), float(PmaxReseau));
}
/* float ValJson(String nom, String Json) {
int p = Json.indexOf(nom + "\":");
if (p < 0) return 0; // MC002
Json = Json.substring(p);
p = Json.indexOf(":");
Json = Json.substring(p + 1);
int q = Json.indexOf(",");
p = Json.indexOf("}");
if (p > 0)
p = min(p, q);
else
p = q;
float val = 0;
if (p > 0) {
Json = Json.substring(0, p);
val = Json.toFloat();
}
return val;
}
*/
float ValJson(const String &nom, const String &Json) {
String lookup = "\"" + nom + "\""; // le nom encadré avant et après évite d'extraire une correspondance en fin de nom
int p = Json.indexOf(lookup);
if (p == -1) return 0.0f; // pas trouvé le nom encadré par double cote
p = Json.indexOf(':', p + lookup.length()); // Sauter le nom trouvé et chercher le ':' suivant
if (p == -1) return 0.0f; // pas trouvé le ':'
p++;
while (p < Json.length() && Json[p] <= ' ') p++; // On saute tous les caractères de contrôle (ASCII <= 32)
if (p < Json.length() && Json[p] == '\"') p++; // Si on tombe sur un guillemet ouvrant, on le saute (cas ou le nombre float serait entre "")
return Json.substring(p).toFloat(); // le fonction .toFloat accepte que la chaine commence par espace, tab, \r \n ...
}
long LongJson(String nom, String Json) { // Pour éviter des problèmes d'overflow
int p = Json.indexOf(nom + "\":");
if (p < 0) return 0; // MC002
Json = Json.substring(p);
p = Json.indexOf(":");
Json = Json.substring(p + 1);
int q = Json.indexOf(".");
p = Json.indexOf("}");
if (p > 0)
p = min(p, q);
else
p = q;
long val = 0;
if (p > 0) {
Json = Json.substring(0, p);
val = Json.toInt();
}
return val;
}
int status;
enum ReadStatus {
READ_OK,
READ_INVALID_ARGUMENT,
READ_TIMEOUT,
READ_DISCONNECTED,
READ_TOO_LONG
};
const char* ReadStatusToString(int status) {
switch (status) {
case READ_OK:
return "OK";
case READ_INVALID_ARGUMENT:
return "INVALID_ARGUMENT";
case READ_TIMEOUT:
return "TIMEOUT";
case READ_DISCONNECTED:
return "DISCONNECTED";
case READ_TOO_LONG:
return "TOO_LONG";
default:
return "UNKNOWN";
}
}
int lastPosScanjson = 0; // a remettre a zéro pour recommencer
int ReadBufferUntilChar(NetworkClient& stream, char* out, size_t maxSize, size_t& outLen, char untilChar, unsigned long timeoutMs) {
if (maxSize == 0) return READ_INVALID_ARGUMENT;
outLen = 0;
out[0] = '\0';
const size_t maxLen = maxSize - 1;
unsigned long lastActivity = millis();
String StrJson = String(json);
while (true) { // on quiterra avec un return
while (lastPosScanjson < StrJson.length()) { // le char a la position a scanner est avant la fin de la chaine ?
int c = StrJson.charAt(lastPosScanjson); // le caractere a la position a analyser
if (c <= 0) break;
if (c == 32) { // saute tous les espaces
lastPosScanjson++; // avant a la position suivante
continue; // retourne au while pour traiter le caractere suivant
}
// Serial.print(char(c));
lastActivity = millis();
if ((char)c == untilChar) { // on a trouvé le caractere recherché
out[outLen] = '\0'; // ferme le buffer
//Serial.println(out);
lastPosScanjson++; // avance a la position suivante si le prochain caractere a chercher est le même que l'actuel
// Serial.printf("****\n");
return READ_OK;
}
if (outLen >= maxLen) {
out[outLen] = '\0';
return READ_TOO_LONG;
}
out[outLen++] = (char)c;
lastPosScanjson++;
}
// if (!stream.connected() && stream.available() == 0) {
// out[outLen] = '\0';
// return READ_DISCONNECTED;
// }
if ((unsigned long)(millis() - lastActivity) >= timeoutMs) {
out[outLen] = '\0';
return READ_TIMEOUT;
}
yield();
}
// if (lastPosScanjson > strlen(json)) return "";
// int locateUntilChar = StrJson.indexOf(untilChar, lastPosScanjson);
// if (locateUntilChar < 0) return "";
// String result = StrJson.substring(lastPosScanjson, locateUntilChar);
// lastPosScanjson = locateUntilChar;
// return result;
}
float Tension_M, Tension_M1, Tension_M2, Tension_M3;
float Intensite_M, Intensite_M1, Intensite_M2, Intensite_M3;
float Frequence;
float PactConso_M, PactProd;
bool EnergieActiveValide, Pva_valide;
float PowerFactor_M;
int PVAS_M_inst = 0;
int PVAI_M_inst = 0;
int PuissanceS_M_inst = 0;
int PuissanceI_M_inst = 0;
int PVA_M_moy;
float Puissance_M_moy;
float LastwhDlvdCum = 0.0f;
float LastwhRcvdCum = 0.0f;
long Energie_M_Injectee, Energie_M_Soutiree;
bool PuissanceRecue;
uint32_t LectureEnphase() {
// init variable
static unsigned long g_nLastGoodReading = millis();
uint32_t nTickReadingStart = millis();
// //unsigned long nLastTick;
bool bJsonLoadingFinished = false;
bool bTimeout = false;
float PactReseau = 0.0f;
float PvaReseau = 0.0f;
float whDlvdCum = 0.0f;
float whRcvdCum = 0.0f;
// if (TokenEnphase.length() <= TOKEN_MIN_LENGTH) { // MC001 Controle longueur du Token
// StockMessage("Token Enphase absent");
// Setup_Enphase(true);
// if (TokenEnphase.length() <= TOKEN_MIN_LENGTH)
// return millis() - nTickReadingStart; //retry on next loop with a new connection
// }
// String host = IP2String(RMSextIP);
// String baseRequest;
// baseRequest = "/ivp/meters/readings HTTP/1.1\r\nHost: " + host + "\r\nAccept: application/json\r\nConnection: keep-alive\r\n";
float PowerFactor = 0.0f;
// if (TokenEnphase.length() > 50 && EnphaseUser != "") {
// //nLastTick = millis();
// if (!clientSecu.connected()) { // établi la connexion
// clientSecu.stop(); // MC002 toujours repartir proprement
// delay(5); // MC002 toujours repartir proprement
// clientSecu.setInsecure(); // skip verification
// clientSecu.setTimeout(TIMEOUT_CONNECT);
// if (!clientSecu.connect(host.c_str(), 443)) {
// //StockMessage("Connection failed to Envoy-S server! : https://" + String(host) + "timout=" + String(millis()-nLastTick));
// return millis() - nTickReadingStart; // on sort, pas de comm avec le server enphase
// }
// //StockMessage("Connected to Envoy-S server HTTPS!"+ String(host) + "timout=" + String(millis()-nLastTick));
// }
// clientSecu.println("GET " + baseRequest + "Authorization: Bearer " + TokenEnphase + "\r\n\r\n");
static char receivedDataBuf[1200]; // 'static' pour en faire une variable globale et eviter de saturer la pile
// size_t statusLineLen = 0;
// int result = 0;
// do {
// // on consomme le buffer jusqu'à la premiere ligne d'une nouvelle reponse HTTP (contenant HTTP/),
// // au cas où il restait du buffer non consommé de la precedente requete, recu entre-temps).
// result = ReadBufferUntilChar(clientSecu, receivedDataBuf, sizeof(receivedDataBuf), statusLineLen, '\n', TIMEOUT_WAITING_ANSWER);
// } while (!strstr(receivedDataBuf, "HTTP/") && result == READ_OK);
// // Cette ligne devrait alors contenir le HTTP response code (200, 401...)
// if (!strstr(receivedDataBuf, "HTTP/")) {
// if (result == READ_DISCONNECTED) {
// StockMessage("Envoy connection closed before sending any HTTP response. Retrying new connection...");
// }
// // else
// // {
// // StockMessage(String("Envoy error while reading HTTP response status, status= ") + ReadStatusToString(result) + ", partialLen=" + statusLineLen);
// // }
// clientSecu.stop();
// return millis() - nTickReadingStart; //retry on next loop with a new connection
// }
// if (!strstr(receivedDataBuf, "200")) {
// if (strstr(receivedDataBuf, "401")) { // MC001 pour gérer un nouveau Token si plus correct ou dépassé
// StockMessage("Bearer Token expired");
// clientSecu.stop();
// Setup_Enphase(true); // récupère un nouveau token
// return millis() - nTickReadingStart; //retry on next LectureEnphase() call;
// }
// // toute autre erreur n'est pas récupérable, on sort de la fonction
// StockMessage(String("Envoy refused request: receivedDataBuf=[") + receivedDataBuf + "]");
// clientSecu.stop();
// return millis() - nTickReadingStart; //retry on next LectureEnphase() call
// }
int nGlobalIndex = 0;
int nPhaseIndex = 0;
bool bMonoPhase = true;
size_t jsonPayloadLength = 0;
// int status;
// //TelnetPrintln("Waiting JSON data ...");
// // Saute L'entete d'ouverture de la trame JSON.
// status = ReadBufferUntilChar(clientSecu, receivedDataBuf, sizeof(receivedDataBuf), jsonPayloadLength, '[', TIMEOUT_READ_PAYLOAD);
// if (status != READ_OK) {
// //StockMessage(String("Envoy JSON Reading 1 failed, status= ") + ReadStatusToString(status) + ", partialLen=" + jsonPayloadLength);
// clientSecu.stop();
// return millis() - nTickReadingStart;
// }
for (nGlobalIndex = 0; (nGlobalIndex < 8) && !bJsonLoadingFinished && !bTimeout; nGlobalIndex++) {
// Read Global Topic
// avance jusqu'au prochain crochet ouvrant
status = ReadBufferUntilChar(clientSecu, receivedDataBuf, sizeof(receivedDataBuf), jsonPayloadLength, '[', TIMEOUT_READ_PAYLOAD);
if (status != READ_OK) {
Serial.println(String("Envoy JSON Reading 2 failed, status= ") + ReadStatusToString(status) + ", partialLen=" + jsonPayloadLength);
//clientSecu.stop();
bTimeout = true;
continue;
}
//delay(1);
//Serial.println(receivedDataBuf);
if (nGlobalIndex == 0) {
//StockMessage(receivedDataBuf);
float tension = ValJson("voltage", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "voltage,tension", tension);
long eid = LongJson("eid", receivedDataBuf);
Serial.printf("Memorise %s = %d\n", "eid,eid", eid);
//StockMessage("Tension Global0 ="+String(tension));
if (tension > 280.0f)
bMonoPhase = false;
Serial.printf("Memorise system Monophasé = %s\n", bMonoPhase ? "vrai" : "faux");
//StockMessage("bMonoPhase ="+String(bMonoPhase));
if (!bMonoPhase) {
PactProd = ValJson("activePower", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "activePower,PactProd bi/tri", PactProd);
Tension_M = ValJson("voltage", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "voltage,tension bi/tri", tension);
Intensite_M = ValJson("current", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "current,Intensite_M bi/tri", Intensite_M);
}
} else if (nGlobalIndex == 1) {
if (!bMonoPhase) {
PactReseau = ValJson("activePower", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "activePower,PactReseau bi/tri", PactReseau);
PactConso_M = PactReseau + PactProd; // dans l'hypothese qu'il n'y a pas de l'énergie fournit par une batterie !
PvaReseau = ValJson("apparentPower", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "apparentPower,PvaReseau bi/tri", PvaReseau);
whDlvdCum = ValJson("actEnergyDlvd", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "actEnergyDlvd,whDlvdCum bi/tri", whDlvdCum);
whRcvdCum = ValJson("actEnergyRcvd", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "actEnergyRcvd,whRcvdCum bi/tri", whRcvdCum);
Frequence = ValJson("freq", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "freq,Frequence bi/tri", Frequence);
}
}
for (nPhaseIndex = 0; (nPhaseIndex < 3) && !bJsonLoadingFinished && !bTimeout; nPhaseIndex++) {
// Read Phase
status = ReadBufferUntilChar(clientSecu, receivedDataBuf, sizeof(receivedDataBuf), jsonPayloadLength, '}', TIMEOUT_READ_PAYLOAD);
if (status != READ_OK) {
//if (nPhaseIndex == 2) // MC003
// Serial.printlnge(String("Envoy JSON Reading 3 failed, status= ") + ReadStatusToString(status) + ", partialLen=" + jsonPayloadLength);
//clientSecu.stop();
bTimeout = true;
continue;
}
receivedDataBuf[jsonPayloadLength - 1] = '}';
//delay(1);
if ((nGlobalIndex == 0) && (nPhaseIndex == 0)) {
if (bMonoPhase) {
PactProd = ValJson("activePower", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "activePower,PactProd mono", PactProd);
}
} else if ((nGlobalIndex == 1) && (nPhaseIndex == 0)) {
Tension_M1 = ValJson("voltage", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "voltage,Tension_M1", Tension_M1);
Intensite_M1 = ValJson("current", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "current,Intensite_M1", Intensite_M1);
if (bMonoPhase) {
//StockMessage(receivedDataBuf);
PactReseau = ValJson("activePower", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "activePower,PactReseau mono", PactReseau);
PactConso_M = PactReseau + PactProd; // dans l'hypothese qu'il n'y a pas de l'énergie fournit par une batterie !
PvaReseau = ValJson("apparentPower", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "apparentPower,PvaReseau mono", PvaReseau);
whDlvdCum = ValJson("actEnergyDlvd", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "actEnergyDlvd,whDlvdCum mono", whDlvdCum);
whRcvdCum = ValJson("actEnergyRcvd", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "actEnergyRcvd,whRcvdCum mono", whRcvdCum);
Frequence = ValJson("freq", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "freq,Frequence mono", Frequence); // bug ValJson si absence de virgule !!!
Tension_M = Tension_M1;
Intensite_M = Intensite_M1;
//StockMessage("activePower="+String(PactReseau));
}
} else if ((nGlobalIndex == 1) && (nPhaseIndex == 1)) {
Tension_M2 = ValJson("voltage", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "voltage,Tension_M2", Tension_M2);
Intensite_M2 = ValJson("current", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "current,Intensite_M2", Intensite_M2);
} else if ((nGlobalIndex == 1) && (nPhaseIndex == 2)) {
Tension_M3 = ValJson("voltage", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "voltage,Tension_M3", Tension_M3);
Intensite_M3 = ValJson("current", receivedDataBuf);
Serial.printf("Memorise %s = %f\n", "current,Intensite_M3", Intensite_M3);
bJsonLoadingFinished = true;
g_nLastGoodReading = millis();
}
}
}
//}
//clientSecu.stop();
if (!bJsonLoadingFinished) {
//Protection contre les mauvaises lectures qui perdureraient plus de 10s !!!
if ((millis() - g_nLastGoodReading) > 10000) {
PactProd = 0.0f;
PactConso_M = 0;
PactReseau = 0.0f;
PactConso_M = 0.0f;
Tension_M = 0.0f;
Intensite_M = 0.0f;
Frequence = 0.0f;
Tension_M1 = 0.0f;
Tension_M2 = 0.0f;
Tension_M3 = 0.0f;
Intensite_M1 = 0.0f;
Intensite_M2 = 0.0f;
Intensite_M3 = 0.0f;
}
//TelnetPrintln("JSON Loading failed");
//StockMessage("JSON Loading failed");
return millis() - nTickReadingStart;
}
PactReseau = PfloatMax(PactReseau);
if (PactReseau < 0) {
PuissanceS_M_inst = 0;
PuissanceI_M_inst = int(-PactReseau);
} else {
PuissanceI_M_inst = 0;
PuissanceS_M_inst = int(PactReseau);
}
PvaReseau = PfloatMax(PvaReseau);
if (PactReseau < 0) {
PVAS_M_inst = 0;
PVAI_M_inst = int(PvaReseau);
} else {
PVAI_M_inst = 0;
PVAS_M_inst = int(PvaReseau);
}
Pva_valide = true;
//filtre_puissance();
if ((PVA_M_moy) != 0) {
PowerFactor = floor(100.0f * fabsf(Puissance_M_moy) / PVA_M_moy) / 100.0f;
PowerFactor = min(PowerFactor, 1.0f);
}
PowerFactor_M = PowerFactor;
if (whDlvdCum != 0) {
if (LastwhDlvdCum == 0) LastwhDlvdCum = whDlvdCum;
long DeltaWhSoutire = whDlvdCum - LastwhDlvdCum;
LastwhDlvdCum = whDlvdCum;
if (DeltaWhSoutire > 0) Energie_M_Soutiree += DeltaWhSoutire;
}
if (whRcvdCum != 0) {
if (LastwhRcvdCum == 0) LastwhRcvdCum = whRcvdCum;
long DeltaWhInjecte = whRcvdCum - LastwhRcvdCum;
LastwhRcvdCum = whRcvdCum;
if (DeltaWhInjecte > 0) Energie_M_Injectee += DeltaWhInjecte;
}
EnergieActiveValide = true;
if (PactReseau != 0 || PvaReseau != 0) PuissanceRecue = true; // Reset du Watchdog à chaque trame reçue de la passerelle Envoy-S metered
//if (cptLEDyellow > 30) cptLEDyellow = 4;
return millis() - nTickReadingStart;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
Serial.println();
Serial.println();
LectureEnphase();
Serial.println("\nFin");
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}