After AutoConnect esp8266 not can to connect to Blynk cloud

Hi, blynkers. I need help.

NodeMCU esp8266, Arduino IDE 1.6.8, Blynk library 0.3.10

In my project I use WiFiManager library.
My probleme - after connection to the my network via WiFi esp8266 can’t connect to the Blynk cloud.

#define BLYNK_PRINT Serial
#define TIME_SECONDS 1000
#define TIME_UNIT TIME_MINUTES
#include DNSServer.h>
#include ESP8266WiFi.h>
#include ESP8266WebServer.h>
#include ESP8266WiFi.h>
#include BlynkSimpleEsp8266.h>

#include EEPROM.h>
#include ESP8266mDNS.h>
#include WiFiManager.h>
#include TimeLib.h>
#include WidgetRTC.h>

#include SimpleTimer.h>

char auth[] = “6f774b8297a74ca7b06058c0e6c6b5ba”;

SimpleTimer timer;
int timerId;

WiFiManager wifi;
WidgetRTC rtc;
BLYNK_ATTACH_WIDGET(rtc, V0);

//---------Setup function----------------
void setup()
{
Serial.begin(115200);

  wifi.autoConnect("AutoConnectAP");
  Serial.println("connected");


wifi.autoConnect("Blynk");
String ssid = wifi.getSSID();
String pass = wifi.getPassword();
Blynk.begin(auth, ssid.c_str(), pass.c_str());
while (Blynk.connect() == false) 
    {
        // Wait until connected
    }


delay(1000);
//setup pins
for (int i = 0; i < 4; i++)
    {
    pinMode(ValvePins[i], OUTPUT);    
    digitalWrite(ValvePins[i], LOW);  
    delay(10);
    }
 rtc.begin();
//setup timers
timer.setInterval(10000L, clockDisplay);

Serial.println("done setup");
}

//Main loop*************
void loop()
{
//blynk connect and run loop
Blynk.run();
//timer run loop
timer.run();
}

This shows messages on terminal:

*WM: AutoConnect
*WM: Connecting as wifi client…
*WM: Already connected. Bailing out.
*WM: IP Address:
*WM: 192.168.0.202
*WM: Reading SSID
*WM: SSID:
*WM: Tenda_076EF0
*WM: Reading Password
*WM: Password: ghjvjcyfcnrf
[6734] Connecting to Tenda_076EF0
[6737] Connected to WiFi
[6739] IP: 192.168.0.202
[6742] Blynk v0.3.10 on NodeMCU
[6745] Connecting to blynk-cloud.com:8442
[6845] Ready (ping: 1ms).
done setup
[12935] Connecting to blynk-cloud.com:8442
[13023] Ready (ping: 0ms).
[19343] Connecting to blynk-cloud.com:8442
[19441] Ready (ping: 1ms).

On smartphone Blynk Ap periodicaly appears message:
Your NodeMCU was disconnected.
If in Setup instead wifi.autoConnect(“AutoConnectAP”); I use function
Blynk.begin(auth, ssid, pass); then connection to the Blynk is successfully.

What is not properly?

Lots of things but let’s start with this fix In case you see SMTHNG strange in Blynk - #8 by Costas

Hi, blynkers. I need help.

NodeMCU esp8266, Arduino IDE 1.6.8, Blynk library 0.3.10

In my project I use WiFiManager library.
My probleme - after connection to the my network via WiFi esp8266 can’t connect to the Blynk cloud.

#define BLYNK_PRINT Serial
#define TIME_SECONDS 1000
#define TIME_UNIT TIME_MINUTES
#include DNSServer.h>
#include ESP8266WiFi.h>
#include ESP8266WebServer.h>
#include ESP8266WiFi.h>
#include BlynkSimpleEsp8266.h>
#include EEPROM.h>
#include ESP8266mDNS.h>
#include WiFiManager.h>
#include TimeLib.h>
#include WidgetRTC.h>
#include SimpleTimer.h>

char auth[] = "6f774b8297a74ca7b06058c0e6c6b5ba";

SimpleTimer timer;
int timerId;

WiFiManager wifi;
WidgetRTC rtc;
BLYNK_ATTACH_WIDGET(rtc, V0);

//---------Setup function----------------
void setup()
{
Serial.begin(115200);

  wifi.autoConnect("AutoConnectAP");
  Serial.println("connected");


wifi.autoConnect("Blynk");
String ssid = wifi.getSSID();
String pass = wifi.getPassword();
Blynk.begin(auth, ssid.c_str(), pass.c_str());
while (Blynk.connect() == false) 
    {
        // Wait until connected
    }


delay(1000);
//setup pins
for (int i = 0; i < 4; i++)
    {
    pinMode(ValvePins[i], OUTPUT);    
    digitalWrite(ValvePins[i], LOW);  
    delay(10);
    }
 rtc.begin();
//setup timers
timer.setInterval(10000L, clockDisplay);

Serial.println("done setup");
}

//************Main loop*************************
void loop()
{
//blynk connect and run loop
Blynk.run();
//timer run loop
timer.run();
}

This shows messages on terminal:

*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Already connected. Bailing out.
*WM: IP Address:
*WM: 192.168.0.202
*WM: Reading SSID
*WM: SSID:
*WM: Tenda_076EF0
*WM: Reading Password
*WM: Password: ghjvjcyfcnrf
[6734] Connecting to Tenda_076EF0
[6737] Connected to WiFi
[6739] IP: 192.168.0.202
[6742] Blynk v0.3.10 on NodeMCU
[6745] Connecting to blynk-cloud.com:8442
[6845] Ready (ping: 1ms).
done setup
[12935] Connecting to blynk-cloud.com:8442
[13023] Ready (ping: 0ms).
[19343] Connecting to blynk-cloud.com:8442
[19441] Ready (ping: 1ms).

On smartphone Blynk Ap periodicaly appears message:
Your NodeMCU was disconnected.
If in Setup instead wifi.autoConnect(“AutoConnectAP”); I use function
Blynk.begin(auth, ssid, pass); then connection to the Blynk is successfully.

What is not properly?

@klg you can’t simply add backticks to a badly formatted piece of code and it display correctly.

Procedure is:

3 backticks
paste formatted code (replace token with xxxx)
3 backticks

Did you try to compile your sketch?

In the badly formatted version you don’t have the #'s before the defines and includes. The includes are missing opening <'s etc.

ValvePins hasn’t been declared.

wifi.getSSID can’t be retrieved from WiFi Manager and neither can wifi.getPassword.

If all you want WiFiManager to do is connect you to a router all you need in the start of setup() is:

  wifi.autoConnect("AutoConnectAP");
  Serial.println("\nconnected");
  Blynk.config(auth, "192.168.10.229");
  while (Blynk.connect() == false) 
  {
      // Wait until connected
  }

Note, Blynk.config not Blynk.begin as detailed in the comprehensive notes, because begin tries to connect to a router but you have already done that with WiFiManager.

HTH