-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSource_MQTT.ino
More file actions
54 lines (50 loc) · 1.45 KB
/
Copy pathSource_MQTT.ino
File metadata and controls
54 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ******************************************************
// * Informations de puissance reçue via un Broker MQTT *
// ******************************************************
void UpdatePmqtt() {
float Pw = PfloatMax(PwMQTT);
float Pf = 1;
if (P_MQTT_Brute.indexOf("Pf") > 0) {
Pf = abs(PfMQTT);
}
if (P_MQTT_Brute.indexOf("Pva") > 0) {
if (PvaMQTT != 0) {
Pf = abs(Pw / PfloatMax(PvaMQTT));
}
}
if (P_MQTT_Brute.indexOf("Pva") > 0 || P_MQTT_Brute.indexOf("Pf") > 0) {
Pva_valide = true;
} else {
Pva_valide = false;
}
if (Pf > 1) Pf = 1;
if (Pw >= 0) {
PuissanceS_M_inst = Pw;
PuissanceI_M_inst = 0;
if (Pf > 0.01) {
PVAS_M_inst = PfloatMax(Pw / Pf);
} else {
PVAS_M_inst = 0;
}
PVAI_M_inst = 0;
EASfloat += Pw / 6000.0; // Watt Hour,Every 600ms. Soutirée
Energie_M_Soutiree = int(EASfloat); // Watt Hour,Every 40ms. Soutirée
} else {
PuissanceS_M_inst = 0;
PuissanceI_M_inst = -Pw;
if (Pf > 0.01) {
PVAI_M_inst = PfloatMax(-Pw / Pf);
} else {
PVAI_M_inst = 0;
}
PVAS_M_inst = 0;
EAIfloat += -Pw / 6000.0;
Energie_M_Injectee = long(EAIfloat);
}
filtre_puissance();
if (P_MQTT_Brute.indexOf("Pw") > 0) EnergieActiveValide = true;
if (millis() - LastPwMQTTMillis < 30000) PuissanceRecue = true; //Reset du Watchdog si trame MQTT reçue avec au minimum Pw récente
if (cptLEDyellow > 30) {
cptLEDyellow = 4;
}
}