mirror of https://github.com/arendst/Tasmota.git
Revert HLW power changes
5.6.1f * Fix JSON error (#786) * Revert changes from 5.6.1e but extent HLW power timer to 10 seconds (#796)
This commit is contained in:
parent
65681a7054
commit
9c3b1852b1
|
@ -1,7 +1,7 @@
|
|||
## Sonoff-Tasmota
|
||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||
|
||||
Current version is **5.6.1e** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **5.6.1f** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||
|
||||
### ATTENTION All versions
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
/* 5.6.1e
|
||||
/* 5.6.1f
|
||||
* Fix JSON error (#786)
|
||||
* Revert changes from 5.6.1e but extent HLW power timer to 10 seconds (#796)
|
||||
*
|
||||
* 5.6.1e
|
||||
* Remove Sonoff Pow HLW power timer to enable low power readings. Unstable below 3W due to used hardware. (#759)
|
||||
*
|
||||
* 5.6.1d
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||
====================================================*/
|
||||
|
||||
#define VERSION 0x05060105 // 5.6.1e
|
||||
#define VERSION 0x05060106 // 5.6.1f
|
||||
|
||||
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
||||
enum week_t {Last, First, Second, Third, Fourth};
|
||||
|
@ -730,7 +730,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
strlcpy(sysCfg.mqtt_user, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? MQTT_USER : dataBuf, sizeof(sysCfg.mqtt_user));
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("[\"MqttUser\":\"%s\"}"), sysCfg.mqtt_user);
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttUser\":\"%s\"}"), sysCfg.mqtt_user);
|
||||
}
|
||||
else if (!strcmp_P(type,PSTR("MQTTPASSWORD"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_pwd))) {
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#define HLW_UREF 2200 // 220.0V
|
||||
#define HLW_IREF 4545 // 4.545A
|
||||
|
||||
#define HLW_POWER_PROBE_TIME 10 // Number of seconds to probe for power before deciding none used
|
||||
|
||||
byte hlw_pminflg = 0;
|
||||
byte hlw_pmaxflg = 0;
|
||||
byte hlw_uminflg = 0;
|
||||
|
@ -48,6 +50,7 @@ byte hlw_mkwh_state = 0;
|
|||
#endif // FEATURE_POWER_LIMIT
|
||||
|
||||
byte hlw_SELflag;
|
||||
byte hlw_load_off;
|
||||
byte hlw_cf1_timer;
|
||||
byte hlw_fifth_second;
|
||||
byte hlw_startup;
|
||||
|
@ -76,16 +79,25 @@ void hlw_cf1_interrupt() ICACHE_RAM_ATTR;
|
|||
|
||||
void hlw_cf_interrupt() // Service Power
|
||||
{
|
||||
hlw_cf_plen = micros() - hlw_cf_last;
|
||||
hlw_cf_last = micros();
|
||||
hlw_EDcntr++;
|
||||
hlw_Ecntr++;
|
||||
unsigned long us = micros();
|
||||
|
||||
if (hlw_load_off) { // Restart plen measurement
|
||||
hlw_cf_last = us;
|
||||
hlw_load_off = 0;
|
||||
} else {
|
||||
hlw_cf_plen = us - hlw_cf_last;
|
||||
hlw_cf_last = us;
|
||||
hlw_EDcntr++;
|
||||
hlw_Ecntr++;
|
||||
}
|
||||
}
|
||||
|
||||
void hlw_cf1_interrupt() // Service Voltage and Current
|
||||
{
|
||||
hlw_cf1_plen = micros() - hlw_cf1_last;
|
||||
hlw_cf1_last = micros();
|
||||
unsigned long us = micros();
|
||||
|
||||
hlw_cf1_plen = us - hlw_cf1_last;
|
||||
hlw_cf1_last = us;
|
||||
if ((hlw_cf1_timer > 2) && (hlw_cf1_timer < 8)) { // Allow for 300 mSec set-up time and measure for up to 1 second
|
||||
hlw_cf1_ptot += hlw_cf1_plen;
|
||||
hlw_cf1_pcnt++;
|
||||
|
@ -133,6 +145,11 @@ void hlw_200mS()
|
|||
}
|
||||
}
|
||||
|
||||
if (micros() - hlw_cf_last > (HLW_POWER_PROBE_TIME * 1000000)) {
|
||||
hlw_cf_plen = 0; // No load for some time
|
||||
hlw_load_off = 1;
|
||||
}
|
||||
|
||||
hlw_cf1_timer++;
|
||||
if (hlw_cf1_timer >= 8) {
|
||||
hlw_cf1_timer = 0;
|
||||
|
@ -181,9 +198,6 @@ void hlw_readEnergy(byte option, float &et, float &ed, float &e, float &w, float
|
|||
//snprintf_P(log, sizeof(log), PSTR("HLW: CF %d, CF1U %d (%d), CF1I %d (%d)"), hlw_cf_plen, hlw_cf1u_plen, hlw_cf1u_pcntmax, hlw_cf1i_plen, hlw_cf1i_pcntmax);
|
||||
//addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
if (!(power &1)) {
|
||||
hlw_cf_plen = 0; // Powered off
|
||||
}
|
||||
et = (float)(rtcMem.hlw_kWhtotal + (cur_kWhtoday / 1000)) / 100000;
|
||||
ed = 0;
|
||||
if (cur_kWhtoday) {
|
||||
|
@ -210,17 +224,17 @@ void hlw_readEnergy(byte option, float &et, float &ed, float &e, float &w, float
|
|||
}
|
||||
}
|
||||
w = 0;
|
||||
if (hlw_cf_plen) {
|
||||
if (hlw_cf_plen && (power &1) && !hlw_load_off) {
|
||||
hlw_w = (HLW_PREF * sysCfg.hlw_pcal) / hlw_cf_plen;
|
||||
w = (float)hlw_w / 10;
|
||||
}
|
||||
u = 0;
|
||||
if (hlw_cf1u_plen && w) {
|
||||
if (hlw_cf1u_plen && (power &1)) { // If powered on always provide voltage
|
||||
hlw_u = (HLW_UREF * sysCfg.hlw_ucal) / hlw_cf1u_plen;
|
||||
u = (float)hlw_u / 10;
|
||||
}
|
||||
i = 0;
|
||||
if (hlw_cf1i_plen && w) {
|
||||
if (hlw_cf1i_plen && w) { // No current if no power being consumed
|
||||
hlw_i = (HLW_IREF * sysCfg.hlw_ical) / hlw_cf1i_plen;
|
||||
i = (float)hlw_i / 1000;
|
||||
}
|
||||
|
@ -251,6 +265,7 @@ void hlw_init()
|
|||
hlw_cf1u_pcntmax = 0;
|
||||
hlw_cf1i_pcntmax = 0;
|
||||
|
||||
hlw_load_off = 1;
|
||||
hlw_Ecntr = 0;
|
||||
hlw_EDcntr = 0;
|
||||
hlw_kWhtoday = (RTC_Valid()) ? rtcMem.hlw_kWhtoday : 0;
|
||||
|
|
Loading…
Reference in New Issue