openenergymonitor / EmonTxV3CM

EmonTxV3 Continuous Monitoring Firmware (Default shipped EmonTxV3 firmware)
13 stars 13 forks source link

AC input assumed. If not used, power collapses to zero. #21

Open SlyRemarks opened 4 years ago

SlyRemarks commented 4 years ago

Reported by Robert Wall.

His proposed solution:

Make use of the call EmonLibCM_acPresent( ), add a variable assumedVrms with a value of 240.0 (settable via the configuration options) and do as is done for the emonPiCM:

    if (EmonLibCM_acPresent())
    {
      emonPi.power1 = EmonLibCM_getRealPower(0);   // Copy the desired variables ready for transmission 
      emonPi.power2 = EmonLibCM_getRealPower(1); 
      emonPi.power1_plus_2 = emonPi.power1 + emonPi.power2;
      emonPi.E1     = EmonLibCM_getWattHour(0);
      emonPi.E2     = EmonLibCM_getWattHour(1);
    }
    else
    {
      emonPi.power1 = assumedVrms * EmonLibCM_getIrms(0);   // Copy the desired variables ready for transmission 
      emonPi.power2 = assumedVrms * EmonLibCM_getIrms(1); 
      emonPi.power1_plus_2 = emonPi.power1 + emonPi.power2;
      emonPi.E1    += assumedVrms * EmonLibCM_getIrms(0) * EmonLibCM_getDatalog_period()/3600.0;
      emonPi.E2    += assumedVrms * EmonLibCM_getIrms(1) * EmonLibCM_getDatalog_period()/3600.0;
    }

    emonPi.Vrms     = EmonLibCM_getVrms() * 100;

A Vrms value of zero will indicate to the user that apparent power is being reported.