Not Connecting to blynk.cloud:80 Blink 2.0

I have a project in blink 2.0, a thermostat that worked perfectly but when I updated it with another SSID it no longer connects to the server blynk.cloud:80.

Is it necessary to do something else?

The device should now connect to another Wi-Fi network, I haven’t changed anything in the code and the device takes ip but doesn’t connect to Blynk.

Debug serial port

WiFi connectado
IP address Termostato-BROKER: 192.168.1.230
IP address Termostato - BROKER: 192.168.1.230
_______________________________
Temperatura = 18.95
Humedad = 42.57
Temperatura sin ajuste = 22.95
Humedad sin ajuste = 47.57
INICIALIZADO Termostato-Broker
------------------------Iniciando Blynk ------------------------
[3619]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on ESP8266

 #StandWithUkraine    https://bit.ly/swua


[3636] Connecting to blynk.cloud:80
[9640] Connecting to blynk.cloud:80
[14641] Connecting to blynk.cloud:80

Part of code

#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxxxxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxxxxxxxxxxxxxxxxxxx"
#define BLYNK_FIRMWARE_VERSION  "1.0.1"

// Comentar para deshabilitar el Debug de Blynk
#define BLYNK_PRINT Serial   // Defines the object that is used for printing
//#define BLYNK_DEBUG        // Optional, this enables more detailed prints

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "Switch.h"               // Control del pulsador
#include "uMQTTBroker.h"          // Broker mqtt
#include <WEMOS_SHT3X.h>          // Sensor de temperatura
#include <BlynkSimpleEsp8266.h>   // Control externo mediante app
#include <Ticker.h>               // Temporizador funciones asincronas
#include <WidgetRTC.h>            // Fecha, dia y hora
#include <TimeLib.h>              // Fecha, dia y hora
#include <ArduinoOTA.h>           // Actualización por OTA
#include <ESP8266mDNS.h>          // Actualización por OTA
#include <WiFiUdp.h>              // Actualización por OTA
#include "LittleFS.h"             // Sistema archivos WifiManager
#include <ESPAsyncWebServer.h>    // WifiManager
#include <ESPAsyncWiFiManager.h>  // WifiManager        
#include <ArduinoJson.h>          // WifiManager  
#include <ESP8266HTTPClient.h>    // OTA a través de Blynk
#include <ESP8266httpUpdate.h>    // OTA a través de Blynk

//  Comentar para anular del debug serie
#define ___DEBUG___
//  Comentar para anular del debug serie correspondiente al Programador horario
//#define ___DEBUG2___
// Comentar si no se dispone de sensor SHT30 y el sensor de control es externo mediante mqtt
#define sensor_sht30

// IP fija del Termostato-Broker
IPAddress ip(192, 168, 1, 230);
IPAddress gateway(192,168,1,1);
IPAddress subnet (255,255,255,0);
IPAddress dns1(192,168,1,1);

//Token app Blynk
char blynk_token[34] = "BLYNK_TOKEN";

............
.............

// Conexión e Inicio variables a la app Blink

void startBlink(){

  #ifdef ___DEBUG___

    Serial.println("------------------------Iniciando Blynk ------------------------");

  #endif

  Blynk.config(blynk_token);  

  while (Blynk.connect() == false) {

  }

  rtc.begin();

  mqtt.off(); // Rele control caldera desconectado

  terminal.clear();

  terminal.println("   ---- TERMOSTATO BROKER INICIALIZADO ----");

  terminal.println("Firmware Versión: " + String(BLYNK_FIRMWARE_VERSION));

  terminal.println("IP address Termostato - BROKER: " + WiFi.localIP().toString());

  terminal.flush();

  mqttReconnectTimer.once(10, startBrokerMqtt); // Me conecto el Broker MQTT

}

............

void loop(){

  // Control pulsador

  PulsadorSwitch.poll();

  // Actualización código por OTA-LOCAL

  if (ota){

    ArduinoOTA.handle();  

  }

  else {  // Resto del código del dispositivo (Termostato-Broker)

    // Me conecto a la app Blink si no estoy conectado y si no estoy actualizando por OTA

    if ((Blynk.connected()) && (!(ota)))

      Blynk.run(); // Actualización app Blynk

    if ((!(Blynk.connected())) && (!(ota)&& (!(fabrica)))){  

      startBlink();  

      // Asisgno el estado del relé al requerido por la app tras conexión

      if ((client_rele == client_rele_init) && (estado_calefac == 0)){

        myBroker.publish(ReleControl, "0", 0, 1);

        digitalWrite(PIN_LED, HIGH);

      }

      if ((client_rele == client_rele_init) && (estado_calefac == 1)){

       evalua = true;

       myBroker.publish("cmnd/shelly/POWER", ""); // Estado del rele

      }

    }
 ..........................

.......................

I’d suggest that you post your entire sketch.

I’d also suggest that you read this…

Pete.

Hellow, It is not possible to put the code, it tells me that I missed characters. The strange thing is that without changing anything in the code, only the SSID and the PASS have stopped connecting

void loop(){

  // Control pulsador
  PulsadorSwitch.poll();
  // Actualización código por OTA-LOCAL
  if (ota){
    ArduinoOTA.handle();  
  }
  else {  // Resto del código del dispositivo (Termostato-Broker)
    // Me conecto a la app Blink si no estoy conectado y si no estoy actualizando por OTA
    if ((Blynk.connected()) && (!(ota)))
      Blynk.run(); // Actualización app Blynk
    if ((!(Blynk.connected())) && (!(ota)&& (!(fabrica)))){  
      startBlink();  
      // Asisgno el estado del relé al requerido por la app tras conexión
      if ((client_rele == client_rele_init) && (estado_calefac == 0)){
        myBroker.publish(ReleControl, "0", 0, 1);
        digitalWrite(PIN_LED, HIGH);
      }
      if ((client_rele == client_rele_init) && (estado_calefac == 1)){
       evalua = true; 
       myBroker.publish("cmnd/shelly/POWER", ""); // Estado del rele
      }
    }

    // ORDENES DESDE EL TERMINAL DE LA APP
    if (ordenes == "HELP"){              // Ayuda Ordes 
      ordenes = "";
      terminal.println("");
      terminal.println("ORDENES:");
      terminal.println("RESET -> Reinicio Termostato-Broker");
      terminal.println("RESET_ALL -> Termostato-Broker configuración de fábrica");
      terminal.println("UPDATE_OTA -> Permisivo para la actualización OTA-LOCAL");
      terminal.println("RESET_RELE -> Reinicio relé Shelly 1");
      terminal.println("ESTADO_RELE -> Muestra estado actual relé");
      terminal.println("COMUNICACION_RELE -> Muestra/Oculta la comunicación periódica con el relé");
      terminal.flush();
    }
    if (ordenes == "RESET"){              // RESET Termostato_Broker
      myBroker.publish(ReleControl, "0", 0, 1);
      digitalWrite(PIN_LED, HIGH);
      delay(300);
      ESP.restart();
    }
    // ORDENES DESDE EL TERMINAL DE LA APP
    if (ordenes == "RESET_ALL"){          // RESET Termostato_Broker
      terminal.println("");
      terminal.println("Conectate a la red WIFI Termostato_Broker_AP");
      terminal.println("Pon esta dirección en tu navegador http://192.168.4.1");
      terminal.println("Configura tu red WIFI y Token Blink");
      terminal.flush();
      delay(300);
      ordenes = "";
      myBroker.publish(ReleControl, "0", 0, 1);
      digitalWrite(PIN_LED, HIGH);
      fabrica = true;
      Blynk.disconnect(); // Me desconecto de Blynk
      WiFi.disconnect(true); // Me desconecto del WIFI
    }
    if (ordenes == "UPDATE_OTA"){         // Permisivo Actualización por OTA
      myBroker.publish(ReleControl, "0", 0, 1);
      digitalWrite(PIN_LED, HIGH);
      terminal.println(" Esperando actualización OTA-LOCAL");
      terminal.flush();
      delay(300);
      ota = true;
      Blynk.disconnect();
    }
    if (ordenes == "RESET_RELE"){         // RESET Relé
      ordenes = "";
      myBroker.publish("cmnd/shelly/Restart", "1");
      terminal.println("Rele Caldera Reiniciado");
      terminal.flush();
    }
    if (ordenes == "ESTADO_RELE"){         // Estado Relé
      ordenes = "";
      myBroker.publish("cmnd/shelly/POWER", "");
    }
    if (ordenes == "COMUNICACION_RELE"){   // Comunicación periódica Relé
      ordenes = "";
      latido = !latido;
      if (latido)
        terminal.println("Activada comunicación periódica Relé");
      if (!(latido))
        terminal.println("Desactivada comunicación periódica Relé");
      terminal.flush();
    }

    // watchdog SENSOR TEMPERATURA (5 min se mantiene el error )
    if (temp_medida < -10)
      watchdogSensor.attach_scheduled(600, Fallo_Sensor);
    else
      watchdogSensor.detach();

    // Control del Programador horario de la cáldera
    if (Programador)
      Control_Programador();

    // CONTROL DEL TERMOSTATO
    if ((client_rele == client_rele_init) && (estado_calefac) && 
      ((evalua) || ((mem_rele_calefac == 0) && (rele_calefac == 0)))){   // TERMOSTATO AUTO
      digitalWrite(PIN_LED, LOW);

      if (temp_medida < temp_setpoint - Banda_Diferencial){
        inicio = false;
        if ((rele_calefac == 0) || ((mem_rele_calefac == 0) && (rele_calefac == 0))) {   // CALEFACCION ON
          #ifdef ___DEBUG___
            Serial.print("Califaccion = "); Serial.println("ON Control");
          #endif  
          mem_rele_calefac = 0;
          rele_calefac = 1;
          myBroker.publish(ReleControl, (String)rele_calefac, 0, 1);
        }
      }
      
      if (((temp_medida > temp_setpoint - Banda_Diferencial) &&   // BANDA Diferencial CALEFACCION ON SOLO AL INICIAR
          (temp_medida < temp_setpoint) && (inicio))) {  
        #ifdef ___DEBUG___
          Serial.print("Califaccion = "); Serial.println("ON Control Banda Diferencial");
        #endif  
        mem_rele_calefac = 0;
        rele_calefac = 1;
        inicio = false;
        myBroker.publish(ReleControl, (String)rele_calefac, 0, 1); 
      }

      if (temp_medida >= temp_setpoint){
        inicio = false;
        if ((rele_calefac == 1) || ((mem_rele_calefac == 0) && (rele_calefac == 0))) {   // CALEFACCION OFF
          #ifdef ___DEBUG___
            Serial.print("Califaccion = "); Serial.println("OFF Control");
          #endif
          mem_rele_calefac = 1;
          rele_calefac = 0;
          myBroker.publish(ReleControl, (String)rele_calefac);
        }
      }
      
      evalua = false;
    } 

    if (!(estado_calefac)){                             // TERMOSTATO APAGADO
      digitalWrite(PIN_LED, HIGH);
      if((client_rele == client_rele_init) && ((rele_calefac == 1) ||     
        ((mem_rele_calefac == 0) && (rele_calefac == 0)))){  // inicio
        myBroker.publish(ReleControl, "0", 0, 1);
        mem_rele_calefac = 1;
        rele_calefac = 0;
        #ifdef ___DEBUG___
          Serial.print("Califaccion = "); Serial.println("APAGADA Control");
        #endif
      }
      inicio = true;
    }
  }
}

I have no idea what any of this means!

Without your entire sketch we won’t be able to help you.

Pete.

Hellow, link my entire sketch.

https://drive.google.com/file/d/1kzk6GOazw6HOtfg53QqoKe49VPPa2DVr/view?usp=sharing

I have simplified the code and it does not connect to Blynk

#define BLYNK_TEMPLATE_ID "xxxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxx"
#define BLYNK_FIRMWARE_VERSION  "1.0.1"

// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>   // Control externo mediante app

char ssid[] = "xxxxxxxxxxxxxxxxxxx";     
char pass[] = "xxxxxxxxxxxxxxxxxxxxxxxxxx";

// IP fija del Termostato-Broker
IPAddress ip(192, 168, 1, 230);
IPAddress gateway(192,168,1,1);
IPAddress subnet (255,255,255,0);
IPAddress dns1(192,168,1,1);

char blynk_token[34] = BLYNK_AUTH_TOKEN;

void startBlink(){
  Blynk.config(blynk_token);  
  while (Blynk.connect() == false) {
  }
  
}

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();

  // Setup WiFi network
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  WiFi.config(ip, gateway, subnet, dns1);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("WiFi conectado");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

}

void loop() {
  
  if ((Blynk.connected()))
      Blynk.run(); // Actualización app Blynk
  else 
      startBlink(); 
  
}

DEGUB SERIAL


.......WiFi conectado
IP address: 192.168.1.230
[4302]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on ESP8266

 #StandWithUkraine    https://bit.ly/swua


[4312] Connecting to blynk.cloud:80
[10316] Connecting to blynk.cloud:80
[15317] Connecting to blynk.cloud:80
[20318] Connecting to blynk.cloud:80
[25319] Connecting to blynk.cloud:80
[30320] Connecting to blynk.cloud:80
[35321] Connecting to blynk.cloud:80

So is this simply a new SSID that you’ve set up on the same router etc, or is thus a totally different physical location?

Are you 100% sure that the router is located at 192.168.1.1 as you’ve specified here? :

and that the IP address of 192.168.1.230 is available on this network?

Commenting-out this line:

Would allow the router to assign these details via DHCP, and that would be a good first test.

I would also reboot the router to ensure that it isn’t an issue.

Some of your sketch is a bit weird, like this for example…

You would normally put the Blynk.config() command in the void setup, as it’s only needed once, and there is no need for the while() command with Blynk.connect().

But, regardless of that I think it should connect provided your network details are correct and your router isn’t misbehaving.

It is possible that your ISP is blocking the Blynk protocol, but you won’t know if that is the case until you’ve exhausted the other possibilities that I’ve discussed above.

The more info about exactly what has changed with your network then the more likely we are going to be able to help.

Pete.

Helow, I have substituted

IPAddress dns1(192,168,1,1) by IPAddress dns1(8,8,8,8) and already connects to Blynk.

thanks for your help and your patience

1 Like