Please don’t post screenshots.
The serial monitor makes no sense without the sketch that goes with it.
Pete.
Please don’t post screenshots.
The serial monitor makes no sense without the sketch that goes with it.
Pete.
08:39:04.799 -> [33169831] Connecting to blynk.cloud:8080
08:39:04.799 -> [33175935] Connecting to blynk.cloud:80
08:39:04.799 -> [33181936] Connecting to blynk.cloud:8080
08:39:24.831 -> [33188041] Connecting to blynk.cloud:80
08:39:24.831 -> [33194042] Connecting to blynk.cloud:8080
08:39:24.831 -> [33200147] Connecting to blynk.cloud:80
08:39:44.864 -> [33206148] Connecting to blynk.cloud:8080
08:39:44.864 -> [33212252] Connecting to blynk.cloud:80
08:39:44.864 -> [33218254] Connecting to blynk.cloud:8080
08:40:04.896 -> [33224359] Connecting to blynk.cloud:80
08:40:04.896 -> [33230360] Connecting to blynk.cloud:8080
08:40:04.896 -> [33236464] Connecting to blynk.cloud:80
08:40:04.896 -> [33242466] Connecting to blynk.cloud:8080
08:40:24.929 -> [33248570] Connecting to blynk.cloud:80
08:40:24.929 -> [33254571] Connecting to blynk.cloud:8080
08:40:24.929 -> [33260675] Connecting to blynk.cloud:80
08:40:44.962 -> [33266677] Connecting to blynk.cloud:8080
08:40:44.962 -> [33272781] Connecting to blynk.cloud:80
08:40:44.962 -> [33278782] Connecting to blynk.cloud:8080
08:41:04.994 -> [33284886] Connecting to blynk.cloud:80
08:41:04.994 -> [33290888] Connecting to blynk.cloud:8080
08:41:04.994 -> [33296992] Connecting to blynk.cloud:80
08:41:25.027 -> [33302994] Connecting to blynk.cloud:8080
08:41:25.027 -> [33309098] Connecting to blynk.cloud:80
08:41:25.027 -> [33315099] Connecting to blynk.cloud:8080
08:41:25.027 -> [33321204] Connecting to blynk.cloud:80
08:41:45.059 -> [33327205] Connecting to blynk.cloud:8080
08:41:45.059 -> [33333309] Connecting to blynk.cloud:80
08:41:45.059 -> [33339311] Connecting to blynk.cloud:8080
08:42:05.092 -> [33345415] Connecting to blynk.cloud:80
08:42:05.092 -> [33351417] Connecting to blynk.cloud:8080
08:42:05.092 -> [33357521] Connecting to blynk.cloud:80
08:42:24.400 -> [33363523] Connecting to blynk.cloud:8080
08:42:24.400 -> [33369627] Connecting to blynk.cloud:80
08:42:24.400 -> [33375629] Connecting to blynk.cloud:8080
08:42:24.400 -> [33381734] Connecting to blynk.cloud:80
08:49:10.626 -> [33387737] Connecting to blynk.cloud:8080
08:49:10.626 -> [33393841] Connecting to blynk.cloud:80
08:49:10.626 -> [33399843] Connecting to blynk.cloud:8080
08:49:29.767 -> [33793345] Connecting to blynk.cloud:80
08:49:29.767 -> [33799346] Connecting to blynk.cloud:8080
08:49:29.767 -> [33805450] Connecting to blynk.cloud:80
08:49:49.799 -> [33811452] Connecting to blynk.cloud:8080
08:49:49.799 -> [33817556] Connecting to blynk.cloud:80
08:49:49.799 -> [33823558] Connecting to blynk.cloud:8080
09:09:51.224 -> [33829662] Connecting to blynk.cloud:80
09:09:51.224 -> [33835664] Connecting to blynk.cloud:8080
09:09:54.294 -> [35034172] Connecting to blynk.cloud:8080
09:10:00.400 -> [35040276] Connecting to blynk.cloud:80
09:10:06.421 -> [35046280] Connecting to blynk.cloud:8080
09:10:12.493 -> [35052384] Connecting to blynk.cloud:80
09:10:18.502 -> [35058386] Connecting to blynk.cloud:8080
09:10:24.609 -> [35064491] Connecting to blynk.cloud:80
09:10:30.601 -> [35070492] Connecting to blynk.cloud:8080
09:10:36.702 -> [35076597] Connecting to blynk.cloud:80
The board went offline last night and similar SM results
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#define BLYNK_TEMPLATE_ID "TMPL_vJdFuLm"
#define BLYNK_TEMPLATE_NAME "x"
#define BLYNK_AUTH_TOKEN "x"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "x";
char pass[] = "x";
#define BLYNK_GREEN "#23C48E"
#define BLYNK_RED "#D3435C"
#define BLYNK_YELLOW "#ED9D00"
int CEBsensor = 0;
int CEBstate = 0;
int Timerstate = 0;
int InvTimerstate = 0;
int inverterstate = 0;
//Voltage Sensor
int Vsensor = A0;
float correctionfactor = 7.40;
float vout = 0.0;
float vin = 0.0;
float fuelcon = 0.0;
float R1 = 30000;
float R2 = 7500;
int value = 0;
//Declare millis for timers
unsigned long msec = 0;
unsigned long msec2 = 0;
float times = 0.0;
float hourmeter = 0.0;
BlynkTimer timer;
//Blynk LED Widgets
WidgetLED led1(V3); //COIL LED
WidgetLED led2(V7); //FUEL LED
WidgetLED led3(V4); //STARTER LED
WidgetLED led13(V13); //GENERATOR SHUTOFF LED
WidgetLED led14(V14); //CEB STATUS LED
WidgetLED led15(V18); //INVERTER STATUS LED
WidgetLED led16(V20); //INVERTER SHUTOFF LED
WidgetLED led17(V24); //CHANGEOVER RELEASE INDICATOR
int newTimer = 1;
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(16, OUTPUT); //STARTER Relay D0
pinMode(14, OUTPUT); //FUEL Relay D5
pinMode(12, OUTPUT); //COIL Relay D6
pinMode(13, OUTPUT); //INVERTER Relay D7
pinMode(5, INPUT); //CEB LDR Sensor D1
pinMode(Vsensor, INPUT); //Voltage Sensor (A0)
{
//(To prevent self-trigger during initial boot)
digitalWrite(16,HIGH); //D0
digitalWrite(14,HIGH); //D5
digitalWrite(12,HIGH); //D6
}
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(5000L,CEBsensor1);
timer.setInterval(1000L,runtime);
timer.setInterval(1000L,invertertime);
timer.setInterval(10000L,Voltagesensor1);
}
void loop()
{
Blynk.run();
timer.run();
}
BLYNK_CONNECTED() {
Blynk.syncVirtual(V10,V18); //Works, Doesn't get triggered when not on
}
void invertertime()
{
if(CEBstate == LOW){
if(inverterstate == HIGH){
led15.on();
Blynk.setProperty(V10, "color", "#23C48E");
Blynk.setProperty(V18, "color", "#23C48E"); //Inverter Status (ON) GREEN
digitalWrite(13,HIGH); //INV RELAY ON D7
delay(100);
Blynk.setProperty(V2, "offLabel", "OFF Inverter Before Starting");
Blynk.setProperty(V2, "onLabel", "OFF Inverter!");
} else {
Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
Blynk.setProperty(V10, "color", "#ED9D00");
digitalWrite(13,LOW); //INV RELAY OFF D7
delay(100);
Blynk.setProperty(V2, "offLabel", "Hold to Start");
Blynk.setProperty(V2, "onLabel", "Release");
}
} else {
}
if(inverterstate == HIGH && CEBsensor ==LOW){
led16.on(); //Inverter Shutoff Indicator ON
} else {
led16.off(); //Inverter Shutoff Indicator OFF
}
}
void runtime()
{
if(CEBstate == HIGH && Timerstate == HIGH){
times = ((millis() - msec));
Blynk.setProperty(V16, "label", "Current Generator Run Time");
Blynk.setProperty(V17, "label", "Current Fuel Consumption");
{
String readableTime;
getReadableTime(readableTime);
Blynk.virtualWrite(V16, readableTime);
Blynk.virtualWrite(V17, 1.7 * ((millis() - msec)/1000)/3600);
delay(100);
}
} else {
}
if(InvTimerstate == HIGH && CEBstate == LOW && Timerstate == LOW){
times = ((millis() - msec2));
Blynk.setProperty(V16, "label", "Inverter Run Time");
{
String readableTime;
getReadableTime(readableTime);
Blynk.virtualWrite(V16, readableTime);
}
delay(100);
} else {
}
}
void getReadableTime(String &readableTime) {
unsigned long currentMillis;
unsigned long seconds;
unsigned long minutes;
unsigned long hours;
unsigned long days;
currentMillis = times;
seconds = currentMillis / 1000;
minutes = seconds / 60;
hours = minutes / 60;
days = hours / 24;
currentMillis %= 1000;
seconds %= 60;
minutes %= 60;
hours %= 24;
if (days > 0) {
readableTime = String(days) + " ";
}
if (hours > 0) {
readableTime += String(hours) + "H:";
}
if (minutes < 10) {
readableTime += "0";
}
readableTime += String(minutes) + "m:";
if (seconds < 10) {
readableTime += "0";
}
readableTime += String(seconds) + "s";
}
BLYNK_WRITE(V1)
//attach Button on virtual V1,
//it will control the Coil
{
if (param.asInt() == 1){
delay(100);
digitalWrite(12,LOW); //COIL RELAY ON D6
delay(100);
led1.on();
msec = millis();
CEBstate = 1;
}
if (param.asInt() == 0){
digitalWrite(12,HIGH); //COIL RELAY OFF D6
led1.off();
CEBstate = 0;
Blynk.setProperty(V16, "label", "Previous Generator Run Time");
Blynk.setProperty(V17, "label", "Previous Fuel Consumption");
//Blynk.setProperty(V23, "isDisabled", true);
Blynk.logEvent("generator_off");
}
}
BLYNK_WRITE(V2)
//attach Button on virtual V2,
//it will control the Starter
{
if(param.asInt()){
newTimer = timer.setTimeout(2000,Starter); // button pressed for >2Sec
}
else {
timer.disable(newTimer);
}
}
void Starter()
{
if(inverterstate == LOW){
led3.on();
digitalWrite(16,LOW); //STARTER CRANK ON D0
delay(1200); //CRANK DURATION
digitalWrite(16,HIGH); //STARTER CRANK OFF D0
led3.off();
Blynk.logEvent("generator_on");
//Blynk.setProperty(V23, "isDisabled", true);
}else{
}
}
BLYNK_WRITE(V9)
//attach Button on virtual V9,
//This will control the Fuel
{
if (param.asInt() == 1){
digitalWrite(14,LOW); //FUEL RELAY ON D5
delay(100);
led2.on();
Timerstate = 1;
}
if (param.asInt() == 0){
digitalWrite(14,HIGH); //FUEL RELAY OFF D5
led2.off();
Timerstate = 0;
}
}
BLYNK_WRITE(V10)
//attach Button on virtual V10,
//it will control the Inverter Relay
{
if (param.asInt() == 1){
inverterstate = 1;
delay(100);
msec2 = millis();
InvTimerstate = 1;
Blynk.logEvent("inverter_on");
Blynk.setProperty(V22, "isDisabled", true);
Blynk.setProperty(V23, "isDisabled", false);
}
if (param.asInt() == 0){
inverterstate = 0;
InvTimerstate = 0;
delay(100);
Blynk.logEvent("inverter_off");
Blynk.setProperty(V22, "isDisabled", false);
}
}
BLYNK_WRITE(V15)
//attach Button on virtual V15,
//This will update System Status
{
if (param.asInt() == 1){
Blynk.virtualWrite(V8, map(WiFi.RSSI(), -110, -30, 30, 100));
}
}
BLYNK_WRITE(V19)
//attach Button on virtual V19,
//This will reset Coil/Fuel Status
{
if (param.asInt() == 1){
Blynk.virtualWrite(V1, 0);
led1.off();
Blynk.virtualWrite(V9, 0);
led2.off();
Blynk.setProperty(V16, "label", "Previous Run Time");
Blynk.setProperty(V17, "label", "Previous Fuel Consumption");
Blynk.logEvent("generator_off");
Timerstate = 0;
CEBstate = 0;
}
if (param.asInt() == 0){
}
}
void CEBsensor1()
//Run every 5 second
{
CEBsensor = digitalRead(5); //LDR Sensor D1
Blynk.virtualWrite(V12, CEBsensor);
//If COIL ON and CEBsensor LOW, Trigger "Grid Restored" Blynk Automation
if(CEBsensor == LOW && CEBstate == HIGH){
led13.on(); //Shutoff Indicator ON
} else {
led13.off(); //Shutoff Indicator OFF
}
//CEB STATUS LED
if(CEBsensor == HIGH){
led14.on();
Blynk.setProperty(V14, "color", "#D3435C"); //CEB Status (ON) RED
Blynk.logEvent("grid_failure");
Blynk.setProperty(V23, "isDisabled", false);
Blynk.setProperty(V22, "isDisabled", false);
} else {
Blynk.setProperty(V14, "color", "#23C48E"); //CEB Status (ON) GREEN
Blynk.setProperty(V23, "isDisabled", true);
Blynk.setProperty(V22, "isDisabled", true);
}
}
void Voltagesensor1()
//Run every 10 sec
{
int sdata = 0;
value = analogRead(Vsensor);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
vin = vin - correctionfactor;
Blynk.virtualWrite(V5, vin);
if(vin < 12.0){
Blynk.setProperty(V5, "color", "#D3435C"); //If UPS Voltage < 12.5v, Gauge RED
}else{
Blynk.setProperty(V5, "color", "#F7CE46"); //If UPS Voltage > 12.5v, Gauge ORANGE
}
}
//BETA
BLYNK_WRITE(V22)
//attach Button on virtual V22,
//it will control the GENtoINV
{
if(param.asInt()){
newTimer = timer.setTimeout(2000,GENtoINV); // button pressed for >2Sec
}
else {
timer.disable(newTimer);
}
}
void GENtoINV()
{
if(inverterstate == LOW){
{
led17.on();
//FUEL
Blynk.virtualWrite(V1, 0);
led1.off();
digitalWrite(12,HIGH); //COIL RELAY OFF D6
delay(100);
CEBstate = 0;
Blynk.setProperty(V16, "label", "Previous Generator Run Time");
Blynk.setProperty(V17, "label", "Previous Fuel Consumption");
Blynk.logEvent("generator_off");
}
delay(1500);
{
//COIL
Blynk.virtualWrite(V9, 0);
led2.off();
digitalWrite(14,HIGH); //FUEL RELAY OFF D5
Timerstate = 0;
}
delay(2000);
{
//INV Relay
Blynk.virtualWrite(V10, HIGH);
inverterstate = 1;
msec2 = millis();
InvTimerstate = 1;
Blynk.logEvent("inverter_on");
led17.off();
}
}else{
}
}
BLYNK_WRITE(V23)
//attach Button on virtual V23,
//it will control the INVtoGEN
{
if(param.asInt()){
newTimer = timer.setTimeout(2000,INVtoGEN); // button pressed for >2Sec
}
else {
timer.disable(newTimer);
}
}
void INVtoGEN()
{
{
//INV RELAY OFF
led17.on();
inverterstate = 0;
InvTimerstate = 0;
Blynk.logEvent("inverter_off");
{
Blynk.virtualWrite(V10, 0);
Blynk.setProperty(V10, "color", "#ED9D00");
Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
digitalWrite(13,LOW); //INV RELAY OFF D7
delay(100);
Blynk.setProperty(V2, "offLabel", "Hold to Start");
Blynk.setProperty(V2, "onLabel", "Release");
}
Blynk.setProperty(V22, "isDisabled", false);
}
delay(3000);
{
//FUEL
Blynk.virtualWrite(V9, 1);
digitalWrite(14,LOW); //FUEL RELAY ON D5
led2.on();
Timerstate = 1;
}
delay(1500);
{
//COIL
Blynk.virtualWrite(V1, 1);
digitalWrite(12,LOW); //COIL RELAY ON D6
led1.on();
msec = millis();
Blynk.setProperty(V23, "isDisabled", true);
CEBstate = 1;
}
delay(2000);
{
//STARTER
if(inverterstate == LOW){
led3.on();
digitalWrite(5,LOW); //STARTER CRANK ON D0
delay(1200); //CRANK DURATION
digitalWrite(5,HIGH); //STARTER CRANK OFF D0
led3.off();
Blynk.logEvent("generator_on");
led17.off();
}
}
}
Update,
Tried another router from a different ISP, still goes offline.
Looking at your code and serial output with debug enabled, here’s what part of it means…
This part comes from void invertertime()…
Blynk.setProperty(V10, "color", "#23C48E"); << Your code
23:16:50.354 -> [134488] <[13|04|F9|00|10]18[00]color[00]#ED9D00 << Command sent to Blynk
23:16:50.402 -> [134533] >[00|04|F9|00|C8] << Response from Blynk
Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
23:16:50.450 -> [134555] <[13|04|FA|00|10]10[00]color[00]#ED9D00
23:16:50.497 -> [134656] >[00|04|FA|00|C8]
Blynk.setProperty(V2, "offLabel", "Hold to Start");
23:16:50.543 -> [134656] <[13|04|FB|00|18]2[00]offLabel[00]Hold[20]to[20]Start
23:16:50.591 -> [134702] >[00|04|FB|00|C8]
Blynk.setProperty(V2, "onLabel", "Release");
23:16:50.638 -> [134724] <[13|04|FC|00|11]2[00]onLabel[00]Release
23:16:50.684 -> [134768] >[00|04|FC|00|C8]
led16.off(); //Inverter Shutoff Indicator OFF
23:16:50.732 -> [134791] <[14|04|FD|00|07]vw[00]20[00]0
*** From void CEBsensor1() …"
Blynk.virtualWrite(V12, CEBsensor);
23:16:51.013 -> [135152] <[14|04|FE|00|07]vw[00]12[00]0
led13.off(); //Shutoff Indicator OFF
23:16:51.061 -> [135220] <[14|04|FF|00|07]vw[00]13[00]0
The commands from void invertertime() repeat again 1 second after the first time…
23:16:51.153 -> [135287] <[13|05|00|00|10]14[00]color[00]#23C48E
23:16:51.200 -> [135331] >[00|05|00|00|C8]
23:16:51.200 -> [135354] <[13|05|01|00|0F]23[00]isDisabled[00]1
23:16:51.247 -> [135400] >[00|05|01|00|C8]
23:16:51.294 -> [135421] <[13|05|02|00|0F]22[00]isDisabled[00]1
23:16:51.342 -> [135468] >[00|05|02|00|C8]
23:16:51.387 -> [135488] <[13|05|03|00|10]18[00]color[00]#ED9D00
23:16:51.434 -> [135533] >[00|05|03|00|C8]
23:16:51.434 -> [135555] <[13|05|04|00|10]10[00]color[00]#ED9D00
23:16:51.529 -> [135656] >[00|05|04|00|C8]
23:16:51.529 -> [135656] <[13|05|05|00|18]2[00]offLabel[00]Hold[20]to[20]Start
23:16:51.624 -> [135701] >[00|05|05|00|C8]
23:16:51.624 -> [135724] <[13|05|06|00|11]2[00]onLabel[00]Release
23:16:51.671 -> [135769] >[00|05|06|00|C8]
23:16:51.719 -> [135791] <[14|05|07|00|07]vw[00]20[00]0
The commands from void CEBsensor1()) repeat again 1 second after the first time, even though your sketch has them on a 5 second timer…
23:16:52.000 -> [136152] <[14|05|08|00|07]vw[00]12[00]0
23:16:52.046 -> [136220] <[14|05|09|00|07]vw[00]13[00]0
23:16:52.141 -> [136287] <[13|05|0A|00|10]14[00]color[00]#23C48E
23:16:52.188 -> [136331] >[00|05|0A|00|C8]
I’m not sure why the void CEBsensor1())
code is being repeated every second instead of every 5 seconds - maybe you changed the code?
What is clear is that your code is very badly written, because you’re repeating the same commands to update the status and properties of your widgets, even if they are already displaying the correct information.
You also still have lots of delays scattered throughout your code, which doesn’t help when it comes to Blynk disconnections.
Taking a step back though, have you tried running a simple sketch which uses a timer to push millis()/1000
to a label widget?
This will prove if the issue is with your router/ISP or with your sketch.
Pete.
Also, I’d suggest that you change the way that you format your code when you use nested if
statements. This is almost impossible to read…
void invertertime()
{
if(CEBstate == LOW){
if(inverterstate == HIGH){
led15.on();
Blynk.setProperty(V10, "color", "#23C48E");
Blynk.setProperty(V18, "color", "#23C48E"); //Inverter Status (ON) GREEN
digitalWrite(13,HIGH); //INV RELAY ON D7
delay(100);
Blynk.setProperty(V2, "offLabel", "OFF Inverter Before Starting");
Blynk.setProperty(V2, "onLabel", "OFF Inverter!");
} else {
Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
Blynk.setProperty(V10, "color", "#ED9D00");
digitalWrite(13,LOW); //INV RELAY OFF D7
delay(100);
Blynk.setProperty(V2, "offLabel", "Hold to Start");
Blynk.setProperty(V2, "onLabel", "Release");
}
} else {
}
if(inverterstate == HIGH && CEBsensor ==LOW){
led16.on(); //Inverter Shutoff Indicator ON
} else {
led16.off(); //Inverter Shutoff Indicator OFF
}
}
void runtime()
{
if(CEBstate == HIGH && Timerstate == HIGH){
times = ((millis() - msec));
Blynk.setProperty(V16, "label", "Current Generator Run Time");
Blynk.setProperty(V17, "label", "Current Fuel Consumption");
{
String readableTime;
getReadableTime(readableTime);
Blynk.virtualWrite(V16, readableTime);
Blynk.virtualWrite(V17, 1.7 * ((millis() - msec)/1000)/3600);
delay(100);
}
} else {
}
if(InvTimerstate == HIGH && CEBstate == LOW && Timerstate == LOW){
times = ((millis() - msec2));
Blynk.setProperty(V16, "label", "Inverter Run Time");
{
String readableTime;
getReadableTime(readableTime);
Blynk.virtualWrite(V16, readableTime);
}
delay(100);
} else {
}
}
Using indents sensibly (the Arduino IDE Tools > Auto Format will do most of the work for you) and adding some narrative will make the code much easier to follow. As you can (now) see there is an inconsistency about how you’ve written the last part of the code in this function…
void invertertime()
{
if (CEBstate == LOW)
{
if (inverterstate == HIGH)
{
// we get here if CEBstate == LOW and inverterstate == HIGH
led15.on();
Blynk.setProperty(V10, "color", "#23C48E");
Blynk.setProperty(V18, "color", "#23C48E"); //Inverter Status (ON) GREEN
digitalWrite(13, HIGH); //INV RELAY ON D7
delay(100);
Blynk.setProperty(V2, "offLabel", "OFF Inverter Before Starting");
Blynk.setProperty(V2, "onLabel", "OFF Inverter!");
}
else
{
// we get here if CEBstate == LOW and inverterstate == LOW
Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
Blynk.setProperty(V10, "color", "#ED9D00");
digitalWrite(13, LOW); //INV RELAY OFF D7
delay(100);
Blynk.setProperty(V2, "offLabel", "Hold to Start");
Blynk.setProperty(V2, "onLabel", "Release");
}
}
else
{
// we get here if CEBstate == HIGH
// but we do nothing! maybe the code below should be incorportated here?
}
if (inverterstate == HIGH && CEBsensor == LOW)
{
// we get here if CEBstate == HIGH and CEBsensor == LOW
led16.on(); //Inverter Shutoff Indicator ON
}
else
{
// we get here with any other combination of CEBstate and CEBsensor, eg -
// CEBstate == HIGH and CEBsensor == LOW
// CEBstate == LOW and CEBsensor == LOW
// CEBstate == LOW and CEBsensor == HIGH
led16.off(); //Inverter Shutoff Indicator OFF
}
}
A few other things…
Don’t assign a value to the variable that will hold your timer ID…
These are assigned by the BlynkTimer library and are zero based.
There used to be a bug regarding timer ID’s, which was solved using a sacrificial timer, but I’m not sure if the bug still exists. More info here…
The way that you’re using aliases for your virtual pins makes no sense…
You’d be far better doing this…
//Blynk LED Widgets
WidgetLED COIL_LED(V3);
WidgetLED FUEL_LED(V7);
WidgetLED STARTER_LED(V4);
WidgetLED GENERATOR_SHUTOFF_LED (V13);
WidgetLED CEB_STATUS_LED(V14);
WidgetLED lNVERTER_STATUS_LED(V18);
WidgetLED INVERTER_SHUTOFF_LED(V20);
WidgetLED CHANGEOVER_RELEASE_INDICATOR(V24);
That way, you’ll be using meaningful names within your code, rather than simply mapping one meaningless number to another.
You also seem to have one widget that’s not mapped, and which you address directly…
Blynk.virtualWrite(V12, CEBsensor);
Pete.
Pete I really do appriciate the feedback and I will try to make the suggested improvements.
However I am still puzzled to why the board disconnects from blynks servers even when using the blank example with only the credentials?!
Turn on debugging for that sketch, and post the results and the sketch.
Pete.
I switched to a ESP32-WROOM for testing. Will update if this board also crashes with the following code, which the D1 mini did.
/*************************************************************
Blynk is a platform with iOS and Android apps to control
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
You can easily build mobile and web interfaces for any
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: https://www.blynk.io
Sketch generator: https://examples.blynk.cc
Blynk community: https://community.blynk.cc
Follow us: https://www.fb.com/blynkapp
https://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on ESP32 chip.
NOTE: This requires ESP32 support package:
https://github.com/espressif/arduino-esp32
Please be sure to select the right ESP32 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME "TEST"
#define BLYNK_AUTH_TOKEN ""
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
}
Well there was zero difference and the boards still go offline and continously attempt to connect to blynk servers. I’m loosing my mind here!
Can we both agree that it isnt the code thats causing this and start looking at the probability that its something to do with Blynks servers in my region?!
You seem to have rejected my suggestion to turn on debugging for the simple sketch, so pretty-much impossible to draw any conclusions.
However, if you see how the forum blows-up when there’s an issue with one of the regional servers then you can be 100% sure that your issue isn’t server related.
Most likely something to do with either your LAN or WAN.
Pete.
There appears to be some issues with th sgp1 server
It is apparantly solved but I still am experiencing disconnect issues as well!
At this stage do you have an example code that will automatically restart the board when it looses connection with Blynk server?
if(!Blynk.connected())
{
ESP.restart();
}
Pete.
Thank you.
Would decreasing the Heartbeat improve anything? How may I try this?
Decreasing the heartbeat time would make the device more susceptible to disconnections.
Pete.
I see, would increasing it do the opposite?
I’ve not seen any serial output from you with Heartbeat timeout
messages, so I think you’re chasing the wrong issue there.
I’m going to stop responding to this topic until you’ve taken my earlier advice and uploaded a simple (non-Edgent) sketch with Blynk debugging enabled, then posted the serial output which relates to the time around the device going offline.
Pete.
I already tried running blynk debug on the above code BUT I will do it again tonight and will upload the code and any Serial monitor output as soon as I have the data
Well it didnt take long for it to crash. Here are the results…
This time the board automatically connected. I am still monitoring the SM and will update if I get any other results.
Also I am aware my token is still displayed on the SM output, but this is a test board so I am not worried
/*************************************************************
Blynk is a platform with iOS and Android apps to control
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
You can easily build mobile and web interfaces for any
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: https://www.blynk.io
Sketch generator: https://examples.blynk.cc
Blynk community: https://community.blynk.cc
Follow us: https://www.fb.com/blynkapp
https://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on ESP8266 chip.
NOTE: This requires ESP8266 support package:
https://github.com/esp8266/Arduino
Please be sure to select the right ESP8266 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL669iSps_V"
#define BLYNK_TEMPLATE_NAME "TEST"
#define BLYNK_AUTH_TOKEN "x"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "x";
char pass[] = "x";
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
}
14:05:42.571 -> 0⸮~?⸮4⸮Ҷ⸮⸮OCE⸮⸮a_SAM4⸮,C|X[75] Connecting to xxxxxx
14:05:54.792 -> [10404] Connected to WiFi
14:05:54.825 -> [10404] IP: 192.168.8.147
14:05:54.858 -> [10404]
14:05:54.858 -> ___ __ __
14:05:54.894 -> / _ )/ /_ _____ / /__
14:05:54.927 -> / _ / / // / _ \/ '_/
14:05:54.927 -> /____/_/\_, /_//_/_/\_\
14:05:54.961 -> /___/ v1.2.0 on ESP8266
14:05:54.994 ->
14:05:54.994 -> #StandWithUkraine https://bit.ly/swua
14:05:55.060 ->
14:05:55.060 ->
14:05:55.060 -> [10533] Connecting to blynk.cloud:80
14:05:55.095 -> [10694] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:05:55.161 -> [10772] >[00|00|01|00|C8]
14:05:55.195 -> [10772] Ready (ping: 78ms).
14:05:55.229 -> [10772] Free RAM: 48984
14:05:55.229 -> [10839] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:06:09.448 -> [25071] Connecting to blynk.cloud:80
14:06:10.022 -> [25622] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:06:10.089 -> [25719] >[00|00|01|00|C8]
14:06:10.124 -> [25719] Ready (ping: 96ms).
14:06:10.157 -> [25719] Free RAM: 48480
14:06:10.191 -> [25786] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:06:10.394 -> [25958] >[00|00|02|00|C8]
14:06:55.245 -> [70871] <[06|00|03|00|00]
14:06:56.090 -> [71691] >[00|00|03|00|C8]
14:07:40.258 -> [115872] <[06|00|04|00|00]
14:07:43.047 -> [118677] >[00|00|04|00|C8]
14:08:25.253 -> [160873] <[06|00|05|00|00]
14:08:25.597 -> [161212] >[00|00|05|00|C8]
14:09:10.262 -> [205874] <[06|00|06|00|00]
14:09:13.293 -> [208911] >[00|00|06|00|C8]
14:09:55.251 -> [250875] <[06|00|07|00|00]
14:09:55.353 -> [250965] >[00|00|07|00|C8]
14:10:40.247 -> [295876] <[06|00|08|00|00]
14:10:41.778 -> [297388] >[00|00|08|00|C8]
14:11:25.255 -> [340877] <[06|00|09|00|00]
14:11:25.475 -> [341082] >[00|00|09|00|C8]
14:12:10.262 -> [385878] <[06|00|0A|00|00]
14:12:10.785 -> [386416] >[00|00|0A|00|C8]
14:12:55.253 -> [430879] <[06|00|0B|00|00]
14:12:55.725 -> [431336] >[00|00|0B|00|C8]
14:13:40.265 -> [475880] <[06|00|0C|00|00]
14:13:42.108 -> [477731] >[00|00|0C|00|C8]
14:14:25.278 -> [520881] <[06|00|0D|00|00]
14:14:25.482 -> [521086] >[00|00|0D|00|C8]
14:15:10.257 -> [565882] <[06|00|0E|00|00]
14:15:10.359 -> [565986] >[00|00|0E|00|C8]
14:15:55.270 -> [610884] <[06|00|0F|00|00]
14:15:55.337 -> [610967] >[00|00|0F|00|C8]
14:16:40.261 -> [655885] <[06|00|10|00|00]
14:16:46.208 -> [661815] >[00|00|10|00|C8]
14:17:25.266 -> [700886] <[06|00|11|00|00]
14:17:26.422 -> [702038] >[00|00|11|00|C8]
14:18:10.277 -> [745887] <[06|00|12|00|00]
14:18:10.381 -> [746016] >[00|00|12|00|C8]
14:18:55.277 -> [790888] <[06|00|13|00|00]
14:18:55.523 -> [791147] >[00|00|13|00|C8]
14:19:40.271 -> [835890] <[06|00|14|00|00]
14:19:40.490 -> [836113] >[00|00|14|00|C8]
14:20:25.259 -> [880891] <[06|00|15|00|00]
14:20:26.078 -> [881695] >[00|00|15|00|C8]
14:21:10.278 -> [925892] <[06|00|16|00|00]
14:21:10.387 -> [926001] >[00|00|16|00|C8]
14:22:11.904 -> [970893] <[06|00|17|00|00]
14:22:11.904 -> [971164] >[00|00|17|00|C8]
14:22:51.969 -> [1015894] <[06|00|18|00|00]
14:22:51.969 -> [1023964] Connecting to blynk.cloud:80
14:22:51.969 -> [1025116] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:22:51.969 -> [1025236] >[00|00|01|00|C8]
14:22:51.969 -> [1025236] Ready (ping: 119ms).
14:22:51.969 -> [1025236] Free RAM: 48480
14:22:51.969 -> [1025303] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:22:51.969 -> [1025481] >[00|00|02|00|C8]
14:23:52.066 -> [1070397] <[06|00|03|00|00]
14:23:52.066 -> [1070914] >[00|00|03|00|C8]
14:24:32.131 -> [1115399] <[06|00|04|00|00]
14:24:32.131 -> [1115796] >[00|00|04|00|C8]
14:25:12.197 -> [1160401] <[06|00|05|00|00]
14:25:12.197 -> [1163280] >[00|00|05|00|C8]
14:25:52.262 -> [1205402] <[06|00|06|00|00]
14:25:52.262 -> [1205481] >[00|00|06|00|C8]
14:26:52.359 -> [1250404] <[06|00|07|00|00]
14:26:52.359 -> [1250471] >[00|00|07|00|C8]
14:27:32.424 -> [1295405] <[06|00|08|00|00]
14:27:32.424 -> [1295501] >[00|00|08|00|C8]
14:28:12.490 -> [1340407] <[06|00|09|00|00]
14:28:12.490 -> [1340512] >[00|00|09|00|C8]
14:28:52.555 -> [1385408] <[06|00|0A|00|00]
14:28:52.555 -> [1386115] >[00|00|0A|00|C8]
14:29:51.191 -> [1430410] <[06|00|0B|00|00]
14:29:51.191 -> [1430561] >[00|00|0B|00|C8]
14:30:19.807 -> [1475411] <[06|00|0C|00|00]
14:30:20.388 -> [1476013] >[00|00|0C|00|C8]
14:31:04.810 -> [1520413] <[06|00|0D|00|00]
14:31:10.533 -> [1526144] >[00|00|0D|00|C8]
Funny how right when I send the above response, the board is now doing this.
I am seeing a lot of Login timeout events and attemps to connect to Blynk.cloud:80
14:34:36.803 -> [1724422] <[06|00|15|00|00]
14:34:36.803 -> [1724614] Heartbeat timeout: 1724614, 1661613, 1724422
14:34:36.803 -> [1729423] Connecting to blynk.cloud:80
14:34:46.835 -> [1738130] Connecting to blynk.cloud:8080
14:34:56.868 -> [1744132] Connecting to blynk.cloud:80
14:34:56.868 -> [1750134] Connecting to blynk.cloud:8080
14:35:06.901 -> [1754023] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:35:06.901 -> [1757416] >[00|00|01|00|C8]
14:35:06.901 -> [1757416] Ready (ping: 3392ms).
14:35:06.901 -> [1757416] Free RAM: 46944
14:35:06.901 -> [1757483] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:35:26.967 -> [1774727] Connecting to blynk.cloud:80
14:35:26.967 -> [1775647] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:35:26.967 -> [1781649] Login timeout
14:35:26.967 -> [1781950] Connecting to blynk.cloud:80
14:35:37.000 -> [1787952] Connecting to blynk.cloud:8080
14:35:37.000 -> [1788717] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:35:47.032 -> [1794719] Login timeout
14:35:47.032 -> [1795020] Connecting to blynk.cloud:80
14:35:47.032 -> [1801022] Connecting to blynk.cloud:8080
14:35:57.065 -> [1807025] Connecting to blynk.cloud:80
14:36:07.098 -> [1813027] Connecting to blynk.cloud:8080
14:36:07.098 -> [1813771] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:36:07.098 -> [1814355] >[00|00|01|00|C8]
14:36:07.098 -> [1814355] Ready (ping: 583ms).
14:36:07.098 -> [1814355] Free RAM: 45944
14:36:07.098 -> [1814422] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:36:17.131 -> [1828163] Connecting to blynk.cloud:80
14:36:17.131 -> [1831174] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:36:27.164 -> [1835023] >[00|00|01|00|C8]
14:36:27.164 -> [1835023] Ready (ping: 3849ms).
14:36:27.164 -> [1835023] Free RAM: 45944
14:36:27.164 -> [1835090] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:36:37.197 -> [1848845] Connecting to blynk.cloud:80
14:36:37.197 -> [1849382] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:36:47.230 -> [1855383] Login timeout
14:36:47.230 -> [1855684] Connecting to blynk.cloud:80
14:36:47.230 -> [1859095] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:36:57.263 -> [1865097] Login timeout
14:36:57.263 -> [1865398] Connecting to blynk.cloud:80
14:36:57.263 -> [1871400] Connecting to blynk.cloud:8080
14:37:07.295 -> [1873781] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:37:07.295 -> [1879783] Login timeout
14:37:07.295 -> [1880084] Connecting to blynk.cloud:80
14:37:17.328 -> [1886085] Connecting to blynk.cloud:8080
14:37:17.328 -> [1892087] Connecting to blynk.cloud:80
14:37:27.361 -> [1895973] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:37:27.361 -> [1901974] Login timeout
14:37:37.393 -> [1902275] Connecting to blynk.cloud:80
14:37:37.393 -> [1908277] Connecting to blynk.cloud:8080
14:37:37.393 -> [1908564] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:37:50.185 -> [1914565] Login timeout
14:37:50.185 -> [1914866] Connecting to blynk.cloud:80
14:37:50.185 -> [1920868] Connecting to blynk.cloud:8080
14:38:10.203 -> [1926870] Connecting to blynk.cloud:80
14:38:10.203 -> [1927792] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:38:10.203 -> [1928729] >[00|00|01|00|C8]
14:38:10.203 -> [1928729] Ready (ping: 937ms).
14:38:10.203 -> [1928730] Free RAM: 44944
14:38:10.203 -> [1928796] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:38:10.203 -> [1943458] Connecting to blynk.cloud:80
14:38:15.738 -> [1946461] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:38:15.765 -> [1949329] >[00|00|01|00|C8]
14:38:15.765 -> [1949329] Ready (ping: 2867ms).
14:38:15.765 -> [1949329] Free RAM: 44944
14:38:15.765 -> [1949396] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:38:28.568 -> [1964199] Connecting to blynk.cloud:80
14:38:34.605 -> [1970201] Connecting to blynk.cloud:8080
14:38:40.588 -> [1976203] Connecting to blynk.cloud:80
14:38:46.589 -> [1982204] Connecting to blynk.cloud:8080
14:38:52.584 -> [1988206] Connecting to blynk.cloud:80
14:38:58.229 -> [1993797] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:39:04.168 -> [1999798] Login timeout
14:39:04.472 -> [2000099] Connecting to blynk.cloud:80
14:39:05.227 -> [2000828] <[1D|00|01|00|20]Vnk3zsjgDnrvhx8TzrtoHb6SiVPyjght
14:39:07.163 -> [2002773] >[00|00|01|00|C8]
14:39:07.196 -> [2002774] Ready (ping: 1945ms).
14:39:07.229 -> [2002774] Free RAM: 44944
14:39:07.263 -> [2002841] <[11|00|02|00]qver[00]1.2.0[00]h-beat[00]45[00]buff-in[00]1024[00]dev[00]ESP8266[00]fw-type[00]TMPL669iSps_V[00]build[00]Jun[20|20]6[20]2023[20]14:01:16[00]tmpl[00]TMPL669iSps_V[00]
14:39:07.984 -> [2003583] >[00|00|02|00|C8]
14:39:52.314 -> [2047935] <[06|00|03|00|00]
14:39:54.067 -> [2049664] >[00|00|03|00|C8]