Hello guys !
I’m finally committing to migrate all my projects to the new blynk 2.0. I’m very sad moving away from my local servers as they have been up and running on tiny NanoPis for over 5 years now with not a single hiccup. (the one i use at home running blynkserver and many other services has over 2 years of uptime).
Hopefully one of you can help me with this new venture.
I’m trying to side load some very simple scripts that can run wether or not the device connects to blynk 2.0 server or even has an active wifi connection.
I’m using blynk.edgent and i can’t figure out how make a physical button trigger a function without being connected to blynk’s server.
Because of the constant power and internet outages here my devices can’t depend on an active internet connection or even a wifi connection as they mostly monitor power systems. they need up and ready kick back power when there’s an outtage.
I’ve look in the community without any luck I’ve looked into Connection Management, but haven’t found the solution yet.
#define BLYNK_DEVICE_NAME "”
#define BLYNK_FIRMWARE_VERSION “V2.01b”
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
#include <ezButton.h>
const int StartSwitch = D7; // SWITCH CONTACT
const int RunRelay = D1; // GENSET ON/RUN
const int CrankRelay = D2; // GENSET START
const int AcRelay = D5; // AC ATS Relay
ezButton toggleSwitch1(StartSwitch);
int Relay1State = HIGH;
int Relay3State = HIGH;
#define USE_WEMOS_D1_MINI
#include “BlynkEdgent.h”
BlynkTimer timer;
void GenSetStart(){
timer.setTimeout(100L, {
digitalWrite(AcRelay, HIGH);
});
timer.setTimeout(3000L, {
digitalWrite(RunRelay, HIGH);
Relay1State = !Relay1State;
Serial.println (digitalRead (RunRelay), DEC);
Serial.println(“AC ON - SUCCESSFUL START”);
});
}
void GenSetStop(){
timer.setTimeout(5000L, {
digitalWrite(AcRelay, HIGH);
Serial.println(“AC OFF - 15s COOLING DOWN”);
Serial.println(“RELAY RELEASED”);
});
}
void setup()
{
Serial.begin(115200);
pinMode(RunRelay, OUTPUT);
pinMode(CrankRelay, OUTPUT);
pinMode(AcRelay, OUTPUT);
digitalWrite(RunRelay, LOW);
digitalWrite(CrankRelay, LOW);
digitalWrite(AcRelay, LOW);
toggleSwitch1.setDebounceTime(3000);
delay(100);
BlynkEdgent.begin();
}
void loop() {
timer.run();
toggleSwitch1.loop();
if (toggleSwitch1.isPressed()) {
Serial.println("----------------Button is pressed!");
GenSetStart();
Relay1State = !Relay1State;
}
if (toggleSwitch1.isReleased()){
Serial.println("----------------The button is released");
GenSetStop();
}
BlynkEdgent.run();
}