mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-05 17:07:42 +00:00
6.4.1.7 Fix regression energy sensors
6.4.1.7 20190106 * Fix HLW8012, HJL01 and BL0937 based energy sensors low Power (below 10W) measurement regression from 6.4.1.6
This commit is contained in:
parent
de996cb281
commit
cb8963a7bf
@ -1,4 +1,7 @@
|
|||||||
/* 6.4.1.6 20190105
|
/* 6.4.1.7 20190106
|
||||||
|
* Fix HLW8012, HJL01 and BL0937 based energy sensors low Power (below 10W) measurement regression from 6.4.1.6
|
||||||
|
*
|
||||||
|
* 6.4.1.6 20190105
|
||||||
* Add commands PowerCal, VoltageCal and CurrentCal for HLW8012, HJL01 and BL0937 based energy sensors
|
* Add commands PowerCal, VoltageCal and CurrentCal for HLW8012, HJL01 and BL0937 based energy sensors
|
||||||
*
|
*
|
||||||
* 6.4.1.5 20190103
|
* 6.4.1.5 20190103
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef _SONOFF_VERSION_H_
|
#ifndef _SONOFF_VERSION_H_
|
||||||
#define _SONOFF_VERSION_H_
|
#define _SONOFF_VERSION_H_
|
||||||
|
|
||||||
#define VERSION 0x06040106
|
#define VERSION 0x06040107
|
||||||
|
|
||||||
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
||||||
#define D_AUTHOR "Theo Arends"
|
#define D_AUTHOR "Theo Arends"
|
||||||
|
@ -47,8 +47,6 @@ byte hlw_load_off;
|
|||||||
byte hlw_cf1_timer;
|
byte hlw_cf1_timer;
|
||||||
unsigned long hlw_cf_pulse_length;
|
unsigned long hlw_cf_pulse_length;
|
||||||
unsigned long hlw_cf_pulse_last_time;
|
unsigned long hlw_cf_pulse_last_time;
|
||||||
unsigned long hlw_cf_summed_pulse_length;
|
|
||||||
unsigned long hlw_cf_pulse_counter;
|
|
||||||
unsigned long hlw_cf_power_pulse_length;
|
unsigned long hlw_cf_power_pulse_length;
|
||||||
|
|
||||||
unsigned long hlw_cf1_pulse_length;
|
unsigned long hlw_cf1_pulse_length;
|
||||||
@ -84,10 +82,6 @@ void HlwCfInterrupt(void) // Service Power
|
|||||||
} else {
|
} else {
|
||||||
hlw_cf_pulse_length = us - hlw_cf_pulse_last_time;
|
hlw_cf_pulse_length = us - hlw_cf_pulse_last_time;
|
||||||
hlw_cf_pulse_last_time = us;
|
hlw_cf_pulse_last_time = us;
|
||||||
|
|
||||||
hlw_cf_summed_pulse_length += hlw_cf_pulse_length;
|
|
||||||
hlw_cf_pulse_counter++;
|
|
||||||
|
|
||||||
hlw_energy_period_counter++;
|
hlw_energy_period_counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,20 +113,19 @@ void HlwEvery200ms(void)
|
|||||||
unsigned long hlw_u = 0;
|
unsigned long hlw_u = 0;
|
||||||
unsigned long hlw_i = 0;
|
unsigned long hlw_i = 0;
|
||||||
|
|
||||||
|
|
||||||
if (micros() - hlw_cf_pulse_last_time > (HLW_POWER_PROBE_TIME * 1000000)) {
|
if (micros() - hlw_cf_pulse_last_time > (HLW_POWER_PROBE_TIME * 1000000)) {
|
||||||
hlw_cf_pulse_counter = 0; // No load for some time
|
hlw_cf_pulse_length = 0; // No load for some time
|
||||||
hlw_load_off = 1;
|
hlw_load_off = 1;
|
||||||
}
|
}
|
||||||
|
hlw_cf_power_pulse_length = hlw_cf_pulse_length;
|
||||||
|
|
||||||
if (hlw_cf_pulse_counter && energy_power_on && !hlw_load_off) {
|
if (hlw_cf_power_pulse_length && energy_power_on && !hlw_load_off) {
|
||||||
hlw_cf_power_pulse_length = hlw_cf_summed_pulse_length / hlw_cf_pulse_counter;
|
|
||||||
hlw_w = (hlw_power_ratio * Settings.energy_power_calibration) / hlw_cf_power_pulse_length;
|
hlw_w = (hlw_power_ratio * Settings.energy_power_calibration) / hlw_cf_power_pulse_length;
|
||||||
energy_active_power = (float)hlw_w / 10;
|
energy_active_power = (float)hlw_w / 10;
|
||||||
} else {
|
} else {
|
||||||
energy_active_power = 0;
|
energy_active_power = 0;
|
||||||
}
|
}
|
||||||
hlw_cf_summed_pulse_length = 0;
|
|
||||||
hlw_cf_pulse_counter = 0;
|
|
||||||
|
|
||||||
hlw_cf1_timer++;
|
hlw_cf1_timer++;
|
||||||
if (hlw_cf1_timer >= 8) {
|
if (hlw_cf1_timer >= 8) {
|
||||||
@ -224,6 +217,7 @@ void HlwSnsInit(void)
|
|||||||
hlw_current_ratio = HLW_IREF;
|
hlw_current_ratio = HLW_IREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hlw_cf_pulse_length = 0;
|
||||||
hlw_cf_pulse_last_time = 0;
|
hlw_cf_pulse_last_time = 0;
|
||||||
hlw_cf_power_pulse_length = 0;
|
hlw_cf_power_pulse_length = 0;
|
||||||
hlw_cf1_pulse_length = 0;
|
hlw_cf1_pulse_length = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user