mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 13:46:37 +00:00
Fix Shelly 2.5 overtemp detection
Fix Shelly 2.5 overtemp detection
This commit is contained in:
parent
bbd23dd745
commit
736f63e9ae
@ -584,6 +584,16 @@ float ConvertTemp(float c)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ConvertTempToCelsius(float c)
|
||||||
|
{
|
||||||
|
float result = c;
|
||||||
|
|
||||||
|
if (!isnan(c) && Settings.flag.temperature_conversion) {
|
||||||
|
result = (c - 32) / 1.8; // Celsius
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
char TempUnit(void)
|
char TempUnit(void)
|
||||||
{
|
{
|
||||||
return (Settings.flag.temperature_conversion) ? 'F' : 'C';
|
return (Settings.flag.temperature_conversion) ? 'F' : 'C';
|
||||||
|
@ -162,7 +162,7 @@ void Ade7953EnergyEverySecond()
|
|||||||
|
|
||||||
void Ade7953EverySecond()
|
void Ade7953EverySecond()
|
||||||
{
|
{
|
||||||
if (power && (global_temperature > ADE7953_OVERTEMP)) { // Device overtemp, turn off relays
|
if (power && (ConvertTempToCelsius(AdcTemperature()) > ADE7953_OVERTEMP)) { // Device overtemp, turn off relays
|
||||||
SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP);
|
SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#define ANALOG_B 3350.0 // Thermistor Beta Coefficient
|
#define ANALOG_B 3350.0 // Thermistor Beta Coefficient
|
||||||
|
|
||||||
uint16_t adc_last_value = 0;
|
uint16_t adc_last_value = 0;
|
||||||
|
float adc_temp = 0;
|
||||||
|
|
||||||
uint16_t AdcRead(uint8_t factor)
|
uint16_t AdcRead(uint8_t factor)
|
||||||
{
|
{
|
||||||
@ -69,6 +70,22 @@ void AdcEvery250ms(void)
|
|||||||
}
|
}
|
||||||
#endif // USE_RULES
|
#endif // USE_RULES
|
||||||
|
|
||||||
|
void AdcEverySecond(void)
|
||||||
|
{
|
||||||
|
if (my_module_flag.adc0_temp) {
|
||||||
|
int adc = AdcRead(2);
|
||||||
|
// Steinhart-Hart equation for thermistor as temperature sensor
|
||||||
|
double Rt = (adc * ANALOG_R21) / (1024.0 * ANALOG_V33 - (double)adc);
|
||||||
|
double T = ANALOG_B / (ANALOG_B/ANALOG_T0 + log(Rt/ANALOG_R0));
|
||||||
|
adc_temp = ConvertTemp(TO_CELSIUS(T));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float AdcTemperature(void)
|
||||||
|
{
|
||||||
|
return adc_temp;
|
||||||
|
}
|
||||||
|
|
||||||
void AdcShow(bool json)
|
void AdcShow(bool json)
|
||||||
{
|
{
|
||||||
if (my_module_flag.adc0) {
|
if (my_module_flag.adc0) {
|
||||||
@ -83,14 +100,8 @@ void AdcShow(bool json)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (my_module_flag.adc0_temp) {
|
if (my_module_flag.adc0_temp) {
|
||||||
int adc = AdcRead(2);
|
|
||||||
// Steinhart-Hart equation for thermistor as temperature sensor
|
|
||||||
double Rt = (adc * ANALOG_R21) / (1024.0 * ANALOG_V33 - (double)adc);
|
|
||||||
double T = ANALOG_B / (ANALOG_B/ANALOG_T0 + log(Rt/ANALOG_R0));
|
|
||||||
double temp = ConvertTemp(TO_CELSIUS(T));
|
|
||||||
|
|
||||||
char temperature[33];
|
char temperature[33];
|
||||||
dtostrfd(temp, Settings.flag2.temperature_resolution, temperature);
|
dtostrfd(adc_temp, Settings.flag2.temperature_resolution, temperature);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
ResponseAppend_P(JSON_SNS_TEMP, "ANALOG", temperature);
|
ResponseAppend_P(JSON_SNS_TEMP, "ANALOG", temperature);
|
||||||
@ -127,6 +138,9 @@ bool Xsns02(uint8_t function)
|
|||||||
AdcEvery250ms();
|
AdcEvery250ms();
|
||||||
break;
|
break;
|
||||||
#endif // USE_RULES
|
#endif // USE_RULES
|
||||||
|
case FUNC_EVERY_SECOND:
|
||||||
|
AdcEverySecond();
|
||||||
|
break;
|
||||||
case FUNC_JSON_APPEND:
|
case FUNC_JSON_APPEND:
|
||||||
AdcShow(1);
|
AdcShow(1);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user