![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
hg
Dependencies: LoRaTransmitter mbed BME280 SX1272Lib
Diff: main.cpp
- Revision:
- 2:2bcb1840d680
- Parent:
- 1:30ce00fbab55
--- a/main.cpp Fri May 13 15:45:57 2022 +0000 +++ b/main.cpp Mon Jun 06 10:43:47 2022 +0000 @@ -110,6 +110,7 @@ volatile float Vsum = 0,Vmax =0, Vmean = 0, Imax =0, Isum = 0, Imean = 0, Ud = 0, Id = 0, cosi = 0; volatile double P = 0, P2 = 0, S2 = 0, P1=0, S1=0; + uint16_t strSize = 0; char str[BUFFER_SIZE]; char monitor[16]="0", monitor1[16]="0"; @@ -120,6 +121,7 @@ { j++; + voltage_sinus = voltage*2200; current_sinus = current*5; Vsum+=voltage_sinus; @@ -135,7 +137,6 @@ S2=S2+((voltage_sinus-Vmean)*(current_sinus-Imean)); - if (j>=300) { j = 0; @@ -144,7 +145,7 @@ P1=P2/300; S1=S2/300; Ud=(Vmax-Vmean)/1.41; Id=(Imax-Imean)/1.41; - Vmax = 0; Imax = 0; + Vmax = 0; Imax = 0; Vsum=0; Isum =0; cosi = P2/S2; P2=0; S2=0; @@ -153,7 +154,7 @@ void transmit (void) { - strSize = sprintf ( str, "W=%10.4fkWh, cos fi=%5.4f, P1=%5.4f, S1=%5.4f", P, cosi, P2, S2); + strSize = sprintf ( str, "W=%10.4fkWh, cos fi=%5.4f, P1=%5.4f, S1=%5.4f", P, cosi, P1*1.41, S1*1.41); State = TX; }