Update Basic_Connect_Blynk_Bug.ino

Update Basic_Connect_Blynk_Bug.ino

แก้ไขปัญหาเชื่อม Blynk แล้วหลุด

diff --git a/ESP8266/Basic_Connect_Blynk_Bug/Basic_Connect_Blynk_Bug.ino b/ESP8266/Basic_Connect_Blynk_Bug/Basic_Connect_Blynk_Bug.ino
index 534e305..8ac7de7 100644
--- a/ESP8266/Basic_Connect_Blynk_Bug/Basic_Connect_Blynk_Bug.ino
+++ b/ESP8266/Basic_Connect_Blynk_Bug/Basic_Connect_Blynk_Bug.ino
@@ -23,6 +23,27 @@ BLYNK_CONNECTED() {  // ฟังก์ชันนี้ทำงานเม
 
 void loop() {
   
-  Blynk.run();
-  delay(200);
+  if(WiFi.status() == WL_CONNECTED){
+
+    if (!Blynk.connected()){
+            if(Blynk.connect()){
+              BLYNK_LOG("Reconnected");
+              digitalWrite(WIFI_LED,LOW);
+      
+
+        }else {
+      
+      BLYNK_LOG("Not reconnected");
+
+   
+            }
+                            }
+
+    if(Blynk.connected()) {   // to ensure that Blynk.run() function is only called if we are still connected to the server
+       
+    Blynk.run();
+  }
+     
+    
+}
 }

GitHub
sha: a532508a