Browse Source

Using IS units for energy

fastled
Xose Pérez 7 years ago
parent
commit
8c2d912545
7 changed files with 3554 additions and 3550 deletions
  1. +1
    -3
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +6
    -2
      code/espurna/power.ino
  4. +3543
    -3542
      code/espurna/static/index.html.gz.h
  5. +1
    -0
      code/espurna/web.ino
  6. +2
    -2
      code/html/index.html
  7. +1
    -1
      code/platformio.ini

+ 1
- 3
code/espurna/config/general.h View File

@ -538,9 +538,7 @@ PROGMEM const char* const custom_reset_string[] = {
#define POWER_VOLTAGE_DECIMALS 0 // Decimals for voltage values
#define POWER_POWER_DECIMALS 0 // Decimals for power values
#define POWER_ENERGY_DECIMALS 3 // Decimals for energy values
#define POWER_ENERGY_DECIMALS_WEB 5 // Decimals for energy values
#define POWER_ENERGY_FACTOR 1 // Watt seconds / Joule
#define POWER_ENERGY_FACTOR_WEB (1. / 3600. / 1000.) // kWh
#define POWER_ENERGY_FACTOR 1 // Watt * seconds == Joule (Ws == J)
#if POWER_PROVIDER == POWER_PROVIDER_EMON_ANALOG
#define EMON_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)


BIN
code/espurna/data/index.html.gz View File


+ 6
- 2
code/espurna/power.ino View File

@ -107,7 +107,7 @@ void _powerRead() {
if (factor > 1) factor = 1;
#endif
#if POWER_HAS_ENERGY
_power_energy = _powerEnergy(); //Due to its nature this value doesn't have to be filtered
_power_energy = _powerEnergy(); // Due to its nature this value doesn't have to be filtered
#endif
// Filters
@ -140,7 +140,7 @@ void _powerRead() {
root["pwrCurrent"] = roundTo(current, POWER_CURRENT_DECIMALS);
root["pwrVoltage"] = roundTo(voltage, POWER_VOLTAGE_DECIMALS);
root["pwrApparent"] = roundTo(apparent, POWER_POWER_DECIMALS);
root["pwrEnergy"] = roundTo(_power_energy * POWER_ENERGY_FACTOR_WEB, POWER_ENERGY_DECIMALS_WEB);
root["pwrEnergy"] = roundTo(_power_energy, POWER_ENERGY_DECIMALS);
#if POWER_HAS_ACTIVE
root["pwrActive"] = roundTo(active, POWER_POWER_DECIMALS);
root["pwrReactive"] = roundTo(reactive, POWER_POWER_DECIMALS);
@ -275,6 +275,10 @@ double getReactivePower() {
double getPowerFactor() {
return roundTo(_power_factor, 2);
}
double getPowerEnergy() {
roundTo(_power_energy, POWER_ENERGY_DECIMALS);
}
#endif
// -----------------------------------------------------------------------------


+ 3543
- 3542
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 1
- 0
code/espurna/web.ino View File

@ -611,6 +611,7 @@ void _wsStart(uint32_t client_id) {
root["pwrCurrent"] = getCurrent();
root["pwrVoltage"] = getVoltage();
root["pwrApparent"] = getApparentPower();
root["pwrEnergy"] = getPowerEnergy();
#if POWER_HAS_ACTIVE
root["pwrActive"] = getActivePower();
root["pwrReactive"] = getReactivePower();


+ 2
- 2
code/html/index.html View File

@ -221,8 +221,8 @@
</div>
<div class="pure-g module module-emon module-hlw module-v9261f module-ech1560">
<label class="pure-u-1 pure-u-sm-1-4" for="pwrEnergy">Energy</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="pwrEnergy" post=" kWh" readonly />
<label class="pure-u-1 pure-u-sm-1-4" for="pwrEnergy">Energy (Agg)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="pwrEnergy" post=" J" readonly />
</div>
<div class="pure-u-1 state">


+ 1
- 1
code/platformio.ini View File

@ -24,7 +24,7 @@ lib_deps =
Brzo I2C
EspSoftwareSerial
https://bitbucket.org/xoseperez/justwifi.git#1.1.4
https://bitbucket.org/xoseperez/hlw8012.git#1.0.1
https://bitbucket.org/xoseperez/hlw8012.git#1.1.0
https://bitbucket.org/xoseperez/fauxmoesp.git#2.2.0
https://bitbucket.org/xoseperez/nofuss.git#0.2.5
https://bitbucket.org/xoseperez/emonliteesp.git#0.2.0


Loading…
Cancel
Save