Add device OverTemp (>73 Celsius) detection to selected Energy Monitoring devices

* 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
This commit is contained in:
Theo Arends 2019-05-14 17:46:40 +02:00
parent 475a73b7ef
commit e472d3232a
4 changed files with 15 additions and 21 deletions

View File

@ -2,6 +2,8 @@
* Enable ADC0 by default in my_user_config.h (#5671) * 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 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) * 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 * 6.5.0.9 20190418
* Add command SetOption63 0/1 to disable relay state feedback scan at restart (#5594, #5663) * Add command SetOption63 0/1 to disable relay state feedback scan at restart (#5594, #5663)

View File

@ -27,6 +27,8 @@
#define ENERGY_NONE 0 #define ENERGY_NONE 0
#define ENERGY_OVERTEMP 73.0 // Industry standard lowest overtemp in Celsius
#define FEATURE_POWER_LIMIT true #define FEATURE_POWER_LIMIT true
#include <Ticker.h> #include <Ticker.h>
@ -318,6 +320,15 @@ void EnergyMqttShow(void)
energy_power_delta = 0; 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 * Commands
\*********************************************************************************************/ \*********************************************************************************************/
@ -742,7 +753,7 @@ bool Xsns03(uint8_t function)
break; break;
case FUNC_EVERY_SECOND: case FUNC_EVERY_SECOND:
EnergyMarginCheck(); EnergyMarginCheck();
XnrgCall(FUNC_EVERY_SECOND); EnergyOverTempCheck();
break; break;
case FUNC_JSON_APPEND: case FUNC_JSON_APPEND:
EnergyShow(true); EnergyShow(true);

View File

@ -34,8 +34,6 @@
#define ADE7953_UREF 26000 #define ADE7953_UREF 26000
#define ADE7953_IREF 10000 #define ADE7953_IREF 10000
#define ADE7953_OVERTEMP 73.0 // Industry standard lowest overtemp in Celsius
#define ADE7953_ADDR 0x38 #define ADE7953_ADDR 0x38
uint32_t ade7953_active_power = 0; 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) void Ade7953DrvInit(void)
{ {
if (!energy_flg) { if (!energy_flg) {
@ -248,9 +237,6 @@ int Xnrg07(uint8_t function)
case FUNC_ENERGY_EVERY_SECOND: case FUNC_ENERGY_EVERY_SECOND:
Ade7953EnergyEverySecond(); Ade7953EnergyEverySecond();
break; break;
case FUNC_EVERY_SECOND:
Ade7953EverySecond();
break;
case FUNC_COMMAND: case FUNC_COMMAND:
result = Ade7953Command(); result = Ade7953Command();
break; break;

View File

@ -81,11 +81,6 @@ void AdcEverySecond(void)
} }
} }
float AdcTemperature(void)
{
return adc_temp;
}
void AdcShow(bool json) void AdcShow(bool json)
{ {
if (ADC0_INPUT == my_adc0) { if (ADC0_INPUT == my_adc0) {
@ -99,7 +94,7 @@ void AdcShow(bool json)
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
} }
} }
if (ADC0_TEMP == my_adc0) { else if (ADC0_TEMP == my_adc0) {
char temperature[33]; char temperature[33];
dtostrfd(adc_temp, Settings.flag2.temperature_resolution, temperature); dtostrfd(adc_temp, Settings.flag2.temperature_resolution, temperature);