diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 58c510225..68ae053a5 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -2,6 +2,8 @@ * Enable ADC0 by default in my_user_config.h (#5671) * Add user configurable ADC0 to Module and Template configuration compatible with current FLAG options (#5671) * Add support for Shelly 1PM Template {"NAME":"Shelly 1PM","GPIO":[56,0,0,0,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18} (#5716) + * Fix Sonoff Pow R2 / S31 invalid energy increments (#5789) + * Add device OverTemp (>73 Celsius) detection to any Energy Monitoring device with temperature sensor powering off all outputs * * 6.5.0.9 20190418 * Add command SetOption63 0/1 to disable relay state feedback scan at restart (#5594, #5663) diff --git a/sonoff/xdrv_03_energy.ino b/sonoff/xdrv_03_energy.ino index 3075b7c27..2793c3663 100644 --- a/sonoff/xdrv_03_energy.ino +++ b/sonoff/xdrv_03_energy.ino @@ -27,6 +27,8 @@ #define ENERGY_NONE 0 +#define ENERGY_OVERTEMP 73.0 // Industry standard lowest overtemp in Celsius + #define FEATURE_POWER_LIMIT true #include @@ -318,6 +320,15 @@ void EnergyMqttShow(void) energy_power_delta = 0; } +void EnergyOverTempCheck() +{ + if (global_update) { + if (power && (global_temperature > ENERGY_OVERTEMP)) { // Device overtemp, turn off relays + SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); + } + } +} + /*********************************************************************************************\ * Commands \*********************************************************************************************/ @@ -742,7 +753,7 @@ bool Xsns03(uint8_t function) break; case FUNC_EVERY_SECOND: EnergyMarginCheck(); - XnrgCall(FUNC_EVERY_SECOND); + EnergyOverTempCheck(); break; case FUNC_JSON_APPEND: EnergyShow(true); diff --git a/sonoff/xnrg_07_ade7953.ino b/sonoff/xnrg_07_ade7953.ino index b70daa9b6..a4a0b65c4 100644 --- a/sonoff/xnrg_07_ade7953.ino +++ b/sonoff/xnrg_07_ade7953.ino @@ -34,8 +34,6 @@ #define ADE7953_UREF 26000 #define ADE7953_IREF 10000 -#define ADE7953_OVERTEMP 73.0 // Industry standard lowest overtemp in Celsius - #define ADE7953_ADDR 0x38 uint32_t ade7953_active_power = 0; @@ -160,15 +158,6 @@ void Ade7953EnergyEverySecond() } } -void Ade7953EverySecond() -{ -#ifndef USE_ADC_VCC - if (power && (ConvertTempToCelsius(AdcTemperature()) > ADE7953_OVERTEMP)) { // Device overtemp, turn off relays - SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); - } -#endif // USE_ADC_VCC -} - void Ade7953DrvInit(void) { if (!energy_flg) { @@ -248,9 +237,6 @@ int Xnrg07(uint8_t function) case FUNC_ENERGY_EVERY_SECOND: Ade7953EnergyEverySecond(); break; - case FUNC_EVERY_SECOND: - Ade7953EverySecond(); - break; case FUNC_COMMAND: result = Ade7953Command(); break; diff --git a/sonoff/xsns_02_analog.ino b/sonoff/xsns_02_analog.ino index 4730a6f94..76c19c1df 100644 --- a/sonoff/xsns_02_analog.ino +++ b/sonoff/xsns_02_analog.ino @@ -81,11 +81,6 @@ void AdcEverySecond(void) } } -float AdcTemperature(void) -{ - return adc_temp; -} - void AdcShow(bool json) { if (ADC0_INPUT == my_adc0) { @@ -99,7 +94,7 @@ void AdcShow(bool json) #endif // USE_WEBSERVER } } - if (ADC0_TEMP == my_adc0) { + else if (ADC0_TEMP == my_adc0) { char temperature[33]; dtostrfd(adc_temp, Settings.flag2.temperature_resolution, temperature);