Overload protection prep
This commit is contained in:
@@ -78,6 +78,12 @@ int energyResetCounter;
|
||||
//-------------------------------
|
||||
bool relayOveride = false;
|
||||
bool relayControl = false;
|
||||
bool safeLoad = true;
|
||||
bool previousSafeLoad = true;
|
||||
|
||||
int loadAttempt = 0;
|
||||
bool resetRequired = false;
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "timer.h"
|
||||
@@ -170,5 +176,5 @@ void loop() {
|
||||
RelayOff();
|
||||
}
|
||||
}
|
||||
|
||||
previousSafeLoad = safeLoad; // Flag
|
||||
}
|
||||
|
||||
@@ -21,3 +21,12 @@ Temperature temp = {
|
||||
* This is an anti-short cycle feature.
|
||||
*/
|
||||
int cooldownPeriod = 30;
|
||||
|
||||
// Max current allowed before disconnecting relay. Sonoff says the s31 is rated for 15 amps.
|
||||
#define maxSafeLoad 15
|
||||
|
||||
// Cooldown before attempting to reconnect load
|
||||
#define loadCooldown 30
|
||||
|
||||
// Attempts before giving up and leaving relay off until reset
|
||||
#define loadConnectAttempts 3
|
||||
+19
@@ -5,10 +5,12 @@
|
||||
// Toggle the relay on
|
||||
void RelayOn()
|
||||
{
|
||||
if (!resetRequired) {
|
||||
digitalWrite( RELAY, HIGH );
|
||||
relayState = true;
|
||||
Blynk.virtualWrite( V0, HIGH ); // Sync the Blynk button widget state
|
||||
Blynk.virtualWrite( V1, relayState*255 );
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle the relay off
|
||||
@@ -313,3 +315,20 @@ byte returnConfigVersion() {
|
||||
EEPROM.get(3,grabbedVersion);
|
||||
return grabbedVersion;
|
||||
}
|
||||
|
||||
bool overloadCheck() {
|
||||
if (current > 15) {
|
||||
safeLoad = false;
|
||||
return true;
|
||||
timerReset(4);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void safetyNet() {
|
||||
if (!safeLoad && timerCheck(4) >= loadCooldown*1000 && loadAttempt < loadConnectAttempts) {
|
||||
safeLoad = true;
|
||||
loadAttempt++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
* 1 - Reads button
|
||||
* 2 - Update Blynk app data
|
||||
* 3 - Heater trigger cooldown
|
||||
* 4 - Overload cooldown
|
||||
*/
|
||||
|
||||
|
||||
#define countDataAmount 4 //Number of timers
|
||||
#define countDataAmount 5 //Number of timers
|
||||
unsigned long countData[countDataAmount] = {0}; //Holds count information. (Adjust for numeber of timers needed.)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user