Add ESP32 internal temperature measurement and automatic Actuator switch Off (#1384)
* Add automatic stop of relay following ESP32 temperature To avoid overheating when too much current goes through the device. Add internal temperature reporting to SYStoMQTT This function is not available with ESP32 S3 and C3 * Temp update and error log Update of the temperature to get closer to the datasheet of the ESP32 -40 +85C and add the module name to the error log
This commit is contained in:
1 parent
31ffdf1e2b
commit
c1cedcf333
5 files changed
+73
-3
No files matched your search
@@ -29,6 +29,7 @@
|
||||
#include "User_config.h"
|
||||
|
||||
#ifdef ZactuatorONOFF
|
||||
unsigned long timeinttemp = 0;
|
||||
|
||||
void setupONOFF() {
|
||||
pinMode(ACTUATOR_ONOFF_GPIO, OUTPUT);
|
||||
@@ -103,6 +104,25 @@ void MQTTtoONOFF(char* topicOri, char* datacallback) {
|
||||
}
|
||||
# endif
|
||||
|
||||
//Check regularly temperature of the ESP32 board and switch OFF the relay if temperature is more than MAX_TEMP_ACTUATOR
|
||||
# ifdef MAX_TEMP_ACTUATOR
|
||||
void OverHeatingRelayOFF() {
|
||||
# if defined(ESP32) && defined(SENS_SAR_MEAS_WAIT2_REG) // This macro is necessary to retrieve temperature and not present with S3 and C3 environment
|
||||
if (millis() > (timeinttemp + TimeBetweenReadingIntTemp)) {
|
||||
float internalTempc = intTemperatureRead();
|
||||
Log.trace(F("Internal temperature of the ESP32 %F" CR), internalTempc);
|
||||
if (internalTempc > MAX_TEMP_ACTUATOR && digitalRead(ACTUATOR_ONOFF_GPIO) == ACTUATOR_ON) {
|
||||
Log.error(F("[ActuatorONOFF] OverTemperature detected ( %F > %F ) switching OFF Actuator" CR), internalTempc, MAX_TEMP_ACTUATOR);
|
||||
ActuatorManualTrigger(!ACTUATOR_ON);
|
||||
}
|
||||
timeinttemp = millis();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
# else
|
||||
void OverHeatingRelayOFF() {}
|
||||
# endif
|
||||
|
||||
void ActuatorManualTrigger(uint8_t level) {
|
||||
# ifdef ACTUATOR_BUTTON_TRIGGER_LEVEL
|
||||
if (level == ACTUATOR_BUTTON_TRIGGER_LEVEL) {
|
||||
|
||||
Reference in new issue
Block a user