BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Esp 01 does not connect using ESP core version 2.4 or higher and Blynk 0.5.4

esp8266
#3

Ok nice!
Yes I mean ESP Arduino Core.
I am using Arduino IDE 1.8.7. a Samsung Galaxy Edge S7, Blynk app 2.27.1.
You have seen the code I am using, did you notice something that might affect the performance negatively?
I think for example a library name changed in a previous version of Blynk like:
#include <BlynkSimpleEsp8266.h>

#include <ESP8266mDNS.h>
    #include <WiFiUdp.h>
    #include <ArduinoOTA.h>
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>

   long myWiFiTimeout = 5000;
   long myServerTimeout =5000;

    char ssid[] = "XXXX";
    char pass[] = "XXXX";

    // Blynk
    char server[] = "blynk-cloud.com";
    char auth[]   = "XXXX";

    void setup() {
      // put your setup code here, to run once:
      WiFi.mode(WIFI_STA);
      WiFi.begin(ssid, pass);
      ArduinoOTA.begin();
      checkBlynk();
      
      unsigned long startWiFi = millis();
      while (WiFi.status() != WL_CONNECTED)
      {
        delay(500);
        if(millis() > startWiFi + myWiFiTimeout)
        {
          break;
        }       
      }
      Blynk.config(auth, server);
    }

    void loop() {
      // put your main code here, to run repeatedly:
    ArduinoOTA.handle();
    checkBlynk();
    if (Blynk.connected()) 
    {
      Blynk.run();
    }
    }

    void checkBlynk() 
    {
      if (WiFi.status() == WL_CONNECTED)  
      {
        unsigned long startConnecting = millis();    
        while(!Blynk.connected())
        {
          Blynk.connect();  
          if(millis() > startConnecting + myServerTimeout)
          {
            break;
          }
        }
      }
    }
0 Likes

#4

@Hannes_Sapiens your sketch will not work with any version of the Arduino IDE, Blynk libraries or ESP8266 core.

You are missing the definition of two global long variables:

long myWiFiTimeout = 5000;
long myServerTimeout =5000;
0 Likes

#5

oh crap, you are right, I forgot to put these lines in. Even with these lines it works with previous versions and it does not work with higher versions.

0 Likes

#6

@Hannes_Sapiens worked for me with IDE 1.8.8, Blynk 0.5.4 and Core 2.5.0beta2.

Maybe you are using a bad auth token.

0 Likes

#7

I just tried with the IDE 1.8.9 hourly build, Blynk 0.5.4 and Core 2.5.0beta2 on my Desktop.
It compiles and uploads just fine, but it just wont make a connection to the app.
When I upload the same sketch with Arduino IDE 1.8.7, Core 2.3.0, Blynk 0.5.3 it connects without issues.
So the Auth token works just fine.
Maybe the problem lies in the Generic ESP8266 Module upload settings?
On the Desktop with the latest version I use:

0 Likes

#8

@Hannes_Sapiens most ESP01’s don’t have 4MB flash.

0 Likes

#9

I soldered a 4 MB chip on it.
On the laptop with the older versions I use:

0 Likes

#10

@Hannes_Sapiens from your sketch I am guessing you are working “blind” without Serial Monitor. Get yourself sorted out with Serial Monitor with mods to the sketch and a USB2TTL adaptor. You will then know what your problem is.

0 Likes

#11

I have a USB2TTL adaptor.
I tried adding the Serial.begin line in Void Setup() and this line:
#define BLYNK_PRINT Serial
Like the Blynk example for Esp8266 devices has, but all I get is garbage in the monitor even though the Baud rates match.
If you have any suggestions, I would love a sketch for debugging or a link.

0 Likes

#12

This is working fine on a decent ESP8266 (WeMos).

/*
 * OTAtest.ino 
 */

#define BLYNK_PRINT Serial    /* Comment this out to disable prints and save space */
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char ssid[] = "xx";
char pass[] = "xx";

long myWiFiTimeout = 5000; // 5s timeout
long myServerTimeout = 5000; // 5s timeout

// Blynk
char server[] = "xx";
char auth[]   = "xx";

void setup() 
{
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  ArduinoOTA.begin();
  checkBlynk();
  
  unsigned long startWiFi = millis();
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    if(millis() > startWiFi + myWiFiTimeout)
    {
      break;
    }       
  }
  Blynk.config(auth, server);
  Serial.print(F("\nLAN IP address: "));
  Serial.print(WiFi.localIP()); 
}

void loop() 
{
  ArduinoOTA.handle();
  checkBlynk();
  if (Blynk.connected()) 
  {
    Blynk.run();
  }
}

void checkBlynk() 
{
  if (WiFi.status() == WL_CONNECTED)  
  {
    unsigned long startConnecting = millis();    
    while(!Blynk.connected())
    {
      Blynk.connect();  
      if(millis() > startConnecting + myServerTimeout)
      {
        break;
      }
    }
  }
}
0 Likes

#13

ESP-01, Arduino IDE 1.8.7, ESP Core 2.1.0, Blynk 0.5.3 this code works as expected:

#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
    
char ssid[] = "Hannes";
char pass[] = "19811981";
char ssidOTA[] = "Ziggo7D69ADC";
char passOTA[] = "cpkessj8jbeK";

// Blynk
char auth[]   = "09be2b05000c462f81f0cc85d2a4d3e7";

#define buttonPin 0
boolean OTA = 1;

void setup()
{
  delay(2000);
  // Debug console
  pinMode(buttonPin, INPUT_PULLUP);
  int buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH)
  {
    OTA = 0;
  }
  delay(3000);
  if (OTA == 0)
  {
    // Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
    Blynk.begin(auth, ssid, pass);
  } else if (OTA == 1)
  {
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssidOTA, passOTA);
    ArduinoOTA.begin();
  }
}

void loop()
{
  if (OTA == 0)
  {
    Blynk.run();
  }  else if (OTA == 1)
  {
    ArduinoOTA.handle();
  }
}

Updated through the managers to ESP core 2.5.0beta2, Blynk 0.5.4 and the code compiles and uploads, but I cant connect to the mobile hotspot or use OTA.
Uploaded using these settings:
Laptop
Also tried Flash frequency 80 Mhz, still no go.

0 Likes

#14

Why should how you flash the code to the device affect how OTA works?

And what is with this convoluted if()… just leave your OTA command in the loop() running as fast as it can so as to be able to do its job.

PS works fine on ESP Core 2.4.2 for me

0 Likes

#15

Thanks for the tip!
Did you use an ESP-01 and try to connect it to your phone with blynk?
ESP32 works fine, but ESP-01 does not connect to the hotspot and Blynk or wifi for OTA with ESP core 2.4.0 and Blynk 0.5.4.

I included:
#define BLYNK_PRINT Serial // This prints to Serial Monitor //#define BLYNK_DEBUG

serial monitor shows nothing

0 Likes

#16

Of course, full phone and OTA functionality… otherwise connecting it via a USB-Serial adapter is a pain… although I leave that option open to add one in, in case I do something silly like overload the ESP-01 with Neopixel routines and Image Gallery fan rotation experiments (not shown, but lower in the project window) that can interfere with OTA, if I am not careful… due the hogging of processor time :blush:

It is a bit of a test bench project… but missing the DHT-11 in this picture.

0 Likes

#17

You keep mixing up your numbers… there is no such thing as ESP core 4.2.0 (and what is Blynk 2.4 in your title?) Makes it hard for us to track what you are actually doing :wink:

0 Likes

#18

Sorry about that. I corrected it, its 2.4.0. I am trying different ESP cores.
Your setup looks good. I love RGB leds and am working on LED hoops and other ws2812b based led projects.
Your Blynk app design looks great.
I dont understand why you can connect the ESP to your phone and why mine keeps failing.
It also fails to connect to Blynk on my iphone 4s.
Also thank you for helping me out.

0 Likes

#19

I don’t know it it will help… but this is he settings I use when flashing my ESP-01…

I use QIQ flash mode… I don’t entirely understand all the differences, but I do recall that some ESP8266 chipsets (like on my sonoffs) get persnickety if set incorrectly.

You said you have added memory to yours, so adjust accordingly.

0 Likes

#20

Thank you for sharing. I will try your settings and report back.

0 Likes

#21

Thank you so so much! :grinning::sunglasses:
Your settings worked like a charm and I learned a thing or two :slight_smile:

1 Like

#22

I had a couple of other ESP’s which worked with flash mode : DIO settings.
Then I got a couple that didnt. I googled the issue and tried the tips. Flash Mode : DOUT worked.
So I have been focussed on using DOUT. Never thought about using the QIO setting.

0 Likes