structure7 / hvacMonitor

Monitoring supply/return air temps, run status, and on/off durations.
MIT License
10 stars 6 forks source link

Control baby! #62

Closed structure7 closed 7 years ago

structure7 commented 8 years ago

ubpnw

Twerks:

#include <SimpleTimer.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
//#define BLYNK_DEBUG
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h> // Used by WidgetRTC.h

char auth[] = "auth";

int fan = 0;
int cooling = 2;

SimpleTimer timer;

WidgetLED led1(V18); // Heartbeat

void setup()
{
  pinMode(fan, OUTPUT); // Fan relay K1
  pinMode(cooling, OUTPUT); // Cooling relay K2

  Serial.begin(9600);
  Blynk.begin(auth, "herp", "derp");

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  timer.setInterval(5000L, sendHeartbeat); // Blinks Blynk LED to reflect online status
}

void loop()
{
  Blynk.run();
  timer.run();
}

BLYNK_WRITE(V17) {
  switch (param.asInt())
  {
    case 1: { // OFF
        Serial.println("OFF");
        digitalWrite(fan, LOW);
        digitalWrite(cooling, LOW);
        break;
      }
    case 2: { // Fan Only On
        Serial.println("Fan Only On");
        digitalWrite(fan, HIGH);
        digitalWrite(cooling, LOW);
        break;
      }
    case 3: { // Cooling On
        Serial.println("Cooling On");
        digitalWrite(fan, LOW);
        digitalWrite(cooling, HIGH);        
        break;
      }
    default: {
        Serial.println("Unknown item selected");
      }
  }
}

void sendHeartbeat()
{
  led1.on();
  timer.setTimeout(2500L, sendHeartbeatAlt);
}

void sendHeartbeatAlt()
{
  led1.off();
}
structure7 commented 8 years ago

Maybe add something in status if under "bypass control."

structure7 commented 7 years ago

Use of Eventor (new idea): In the app my rule is when K's room gets to 68, set vPin 25 = heatingKK. However, I would need to know what the trigger temperature was. So when I get that call, I could record KK's room temp and use that to produce the desired temperature to shut down.

Pseudo (at the relay device):

bool coolingKK;
double tempKK;
double triggerTempKK;
double targetTempKK;
string callStatus;
int tempSplit = 3;       // Predefined value of how much I want to heat or cool above trigger point.

void loop(){
  if (runStatus == TRUE && targetTemp >= triggerTemp && heatRelay == CLOSED

void checkTriggers() {
  Blynk.syncVirtual(V25);
}

BLYNK_WRITE(V25) {
  callStatus = param.asString();
}

if (callStatus == heatingKK){   // Only run this once on trigger.
   triggerTempKK = tempKK;  // 68
   targetTempKK = triggerTempKK + tempSplit;  // 73
   closeRelayForHeatingKK();}

void closeRelayForHeatingKK(){
   heatRelay(CLOSED);
structure7 commented 7 years ago

You know, I'm not feeling Eventor. There's a little too much fooling with vPin syncs, etc. Bah!

New idea: One big scrolling menu in app with a giant switch case setup.