My esp8266 cannot connect with blynk

Hi everyone, i’m currently doing my iot mini project but, it seems like i can’t connect it to blynk. I can connect it to blynk at the first time after i finnished prototype it, but yesterday when i test it again, it became like this. Anyone know how to solve this?

#define BLYNK_TEMPLATE_ID "TMPL6JSJXk23b"
#define BLYNK_TEMPLATE_NAME "UltraS"
#define BLYNK_AUTH_TOKEN "UyCAchfCC_n7CgAnDAwMfCaBCNsWUPC4"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[]=BLYNK_AUTH_TOKEN;
char ssid[]="***";
char pass[]="***";
BlynkTimer timer;
float cm=0; 
int triggerPin=5;//D6
int echoPin=4;//D7
int buzz=16; //D0
int led=15;//D8
int gSense=A0;
int TH=400;

long readDis(int triggerPin, int echoPin)
{
  pinMode(triggerPin, OUTPUT);
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  
  pinMode(echoPin, INPUT);
  return pulseIn(echoPin, HIGH);
}


void sendGSense()
{
  int data = analogRead(gSense);
  Blynk.virtualWrite(V0,data);
  Serial.print("MQ4: ");
  Serial.println(data);
  if(data>TH)
  {
    if(cm>=1200)
    {
      Blynk.logEvent("gas_alert","Gas detected, quickly close the gas stove!!!");
    }
  }
}

void sendDisSense()
{
  int data2 = cm;
  Blynk.virtualWrite(V2,data2);
  Serial.print("Ultrasonic: ");
  Serial.println(data2);
}



void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth,ssid,pass,"blynk-cloud.com",8080);

  timer.setInterval(2500L,sendGSense);
  timer.setInterval(2500L,sendDisSense);
  pinMode(gSense,INPUT);
  pinMode(buzz,OUTPUT);



  pinMode(led,OUTPUT);
  


}

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


  cm = 0.01723 * readDis(triggerPin,echoPin);
  Serial.print(cm);
  Serial.println("cm"); 

  int gState=analogRead(gSense);
  Serial.print("Gas state: ");
  Serial.println(gState);

  if(cm>=1000)
  {
    if(gState>TH)
    {
      digitalWrite(led,HIGH);
      tone(buzz,1000);
      delay(100);
      digitalWrite(led,LOW);
      noTone(buzz);
      delay(100);
    }
    else if(gState<=TH)
    {
      digitalWrite(led,LOW);
      noTone(buzz);
    }
  } 
  else if(cm<1000)
  {
    if(gState>TH)
    {
      digitalWrite(led,HIGH);
      delay(100);
      digitalWrite(led,LOW);
      Serial.println("Warning!!! Warning!!! Smoke and gas detected!!!");
      Serial.println("Quickly close yer gas stove!!!");
      Serial.println("\t");
      delay(200);
    }
    else if(gState<=TH)
    {
      Serial.println("This place is safe");
      Serial.println("\t");
      delay(200);
    }
  }
}

and now this happens:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
�U�[76] Connecting to ***
[4407] Connected to WiFi
[4407] IP: 192.168.1.188
[4407] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.8 on Arduino

[4484] Connecting to blynk-cloud.com:8080
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

Exception (4):
epc1=0x4000dd24 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffd70 end: 3fffffd0 offset: 0160
3ffffed0:  000011b1 00000000 3ffe8640 0000000f  
3ffffee0:  00000000 0062cd1c 00002327 00000000  
3ffffef0:  00000000 0000194b 072b020c 00000000  
3fffff00:  00002327 00000000 0000194b 4020484d  
3fffff10:  00000000 0000194b 083126e9 001d3ec1  
3fffff20:  00000000 0000194b 06666666 00001183  
3fffff30:  00002327 0000194b 00000000 402055b4  
3fffff40:  00002327 00000000 3ffeee34 402011bd  
3fffff50:  00002327 00000000 3ffeee10 40201a34  
3fffff60:  00000000 0000194b 05a1cac0 001d3ebe  
3fffff70:  00000027 0000008c 3ffeeea4 00001183  
3fffff80:  00002327 3ffeee10 00000000 40202210  
3fffff90:  40207fb4 bc01a8c0 feefeffe feefeffe  
3fffffa0:  feefeffe feefeffe feefeffe 3ffef02c  
3fffffb0:  3fffdad0 00000000 3ffef000 402048f4  
3fffffc0:  feefeffe feefeffe 3fffdab0 4010130d  
<<<stack<<<

I have a similar issue but I’m not able to connect for the first time itself. any guidance is appreciated.

1 Like

@heyyo Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Also, please delete the screenshot of your serial monitor, set your serial monitor to the same baud rate that you’ve specified in the Serial.begin() statement (9600 in this case) then copy the text from your serial monitor and paste it (as text, not a screenshot) into your post, and once again add triple backticks at the beginning and end so that it displays correctly.

Pete.

1 Like

@Andy I’d suggest that you start by creating your own “need help with my project” topic and provide full information about your hardware, code (correctly formatted as described above) serial monitor output (also correctly formatted as described above), and any other relevant information that may assist forum members to resolve your issue.

Pete.

1 Like

This should say Blynk v1.3.2 if you have the latest library installed.

My guess is that you also have the Blynk for Chinese library installed, and your compiler is using that library instead of the proper Blynk library. If that’s the case then delete the Blynk for Chinese library.

It should also say “ESP8266”, “NodeMCU” or similar if you’re choosing the correct board type in the IDE.

Also, your void loop is a mess.
You can’t have a cluttered void loop like this when using Blynk, and you can’t use blocking delays either.
You should read this…

Pete.

1 Like

Yesssss, you are right Pete, I’ve installed the blynk Chinese library before and i just deleted and install with the proper one. Now that my esp8266 is able to connect with blynk. I can finally submit my mini project​:partying_face::partying_face::partying_face:. Thanks for helping ya

Hopefully you’ll sort-out that awful void loop and blocking delay rubbish first!

Pete.

Ok :laughing:

As a suggestion it would help if you read up on ‘functions’ They provide a very good way, if used properly, to keep your code tidy, readable and easier to debug.