How can i still run my system if blynk does not successfully connect. Is there a way for the blynk.run to not block the code so that it can run even not connected to the internet.
void loop(){
Blynk.run();
timer.run();
char keyInput = customKeypad.getKey(); // For getting keypad inputs
DateTime now = rtc.now();
displayCurTime = millis();
if(displayCurTime - displayPrevTime >= displayTimer) {
// ULTRASONIC SENSOR READING
// measure the ping time in cm
cm = 0.01723 * readUltrasonicDistance(triggerPin, echoPin);
cm = 60 - cm;
// convert to inches by dividing by 2.54
inches = (cm / 2.54);
if(cm > 0){
displayTime(now); // Function call to display current time
displayFeedLevel(); // Function call to display feed level
}
else{
lcd.clear();
Blynk.logEvent("empty_feed_level");
digitalWrite(relayPin, HIGH);
tone(buzzerPin, 300, 500);
//lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" LOW FEED LEVEL");
lcd.setCursor(0, 2);
lcd.print(" FEED LEVEL: ");
lcd.print(cm);
lcd.print(" cm");
delay(1000);
lcd.clear();
}
}
}
I am using Arduino Mega 2560 with Esp 01s. I also tried to used Blynk.connected to check internet before calling Blynk.run but it did not work.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.