Facing problem with my code getting login timeout error again and again

Before creating the topic

  1. Search forum for similar topics
  2. Check http://docs.blynk.cc and http://help.blynk.cc/
  3. Add details :
    • Node MCU
    • Smartphone ANDROID (6.0.1 MMB29M)
    • Blynk server
    • Blynk_Release_v0.4.4
    • Add your sketch code. :point_up:Code should be formatted as example below.

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.


/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example runs directly on ESP8266 chip.

  Note: This requires ESP8266 support package:
    https://github.com/esp8266/Arduino

  Please be sure to select the right ESP8266 module
  in the Tools -> Board menu!

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int UP=0;
int DOWN=12;
int cutoff_temp=40;
int relay=14;
int MOD=16;
int SW=4;
int a,da,up,down,mod,sw;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "****";
char pass[] = "********";

void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(UP,INPUT);
  pinMode(DOWN,INPUT);
  pinMode(A0,INPUT);
  pinMode(relay,OUTPUT);
  pinMode(MOD,INPUT);
  pinMode(SW,INPUT);
  
   digitalWrite(UP,LOW); 
   
   digitalWrite(DOWN,LOW); 
   
   digitalWrite(MOD,LOW); 
   
   digitalWrite(SW,LOW); 
   
   digitalWrite(relay,LOW); 

  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
 mod=digitalRead(MOD);
 

if(mod==LOW)
 {
  mod=digitalRead(MOD);
  a= analogRead(A0);
 da= (a-574.8)/6.13;
  up= digitalRead(UP);
 down= digitalRead(DOWN);
   Blynk.run();
  auto_mode();
   set_temp();
   Blynk.virtualWrite(1,da);
Blynk.virtualWrite(2,cutoff_temp);
 }


if(mod==LOW)
 {
  mod=digitalRead(MOD);
  a= analogRead(A0);
 da= (a-574.8)/6.13;
  up= digitalRead(UP);
 down= digitalRead(DOWN);
   Blynk.run();
   sw=digitalRead(SW);
  manual_mode();
   set_temp();
   Blynk.virtualWrite(1,da);
Blynk.virtualWrite(2,cutoff_temp);
 }



}






void auto_mode()
{
if(da>cutoff_temp)
  {
    digitalWrite(relay,HIGH);
  WidgetLED led1(V3);
  WidgetLED led2(V4);
  led1.on();
  led2.off();
  }
else if(da<=cutoff_temp-5)
  {
   digitalWrite(relay,LOW); 
    WidgetLED led1(V3);
  WidgetLED led2(V4);
  led1.off();
  led2.on();
 
  }}
void manual_mode()
  {
if(sw==HIGH)
{
  digitalWrite(relay,HIGH);
  WidgetLED led1(V3);
  WidgetLED led2(V4);
  led1.on();
  led2.off();
 
}
//else if(sw==LOW)
//  {
//   digitalWrite(relay,LOW); 
//    WidgetLED led1(V3);
//  WidgetLED led2(V4);
//  led1.off();
//  led2.on();
//  }
   else if(da>cutoff_temp)
  {
    digitalWrite(relay,LOW);
    WidgetLED led1(V3);
  WidgetLED led2(V4);
  led1.off();
  led2.on();
 
  }
  }

void set_temp()
{
  up= digitalRead(UP);
 down= digitalRead(DOWN);
  if(up==HIGH)
  {
    cutoff_temp++;
  }
  else if(down==HIGH)
  {
    cutoff_temp--;
  }
}


clean your loop !!!

void loop()
{
  Blynk.run();
  Timer.run();
}

nothing else for Blynk app

Pete.

Yes I allready used blynk standalone code without writing anything in void loop except blynk.run() function n it is working. But then what I have to do to execute any task by pressing button on blynk app

Use Virtual pins and the BLYNK_WRITE(VPin) callback function which is triggered automatically whenever the value of the virtual pin is changed by a widget in the app.

Pete.

http://help.blynk.cc/en/articles/512059-how-to-control-anything-with-blynk-app

http://help.blynk.cc/en/articles/512056-how-to-display-any-sensor-data-in-blynk-app

I was working with virtual pins and your links were very helpful. Thank u so much for that but I need more help because when we press on button widget on blynk app then I get either 1 or 0 hardware but only for once. What I have to do to get continuous value say 1 if my button widget is allways on in my blynk app

The app doesn’t work like that. It will send a 1/0 only once. Exactly how it does that will depend on whether you’ve configured the switch widget to work in push or switch mode.
If you need the code to then perform some sort of loop function while the button is in the on position then you need to do this yourself, probably with a timer.

Pete.

Thank u Mr. PeteKnight, I used timer for continuous value and get positive results thanks to all for your support

1 Like

Hello friends I have one more query and need your support on it.
1.)My problem is that, I want to send low signal to all pins or a particular pin of node MCU when it get disconnect to internet.

void connectionstatus() {
   if (WiFi.status() != WL_CONNECTED) {
    digitalWrite(XX, LOW);// off
.
.
.
2 Likes

Hlo Blynk_coeur I try this function in my code so results was like if my hotspot is connected to my nodemcu and if I turn off my mobile data then there is no change in pin output according to this function but if I turn off my hotspot then this function works. But I want to perform this function when internet is off

1 Like

Hello,
I’m no sure if Blynk.run() in void loop() is a good idea it could not be invoked only one time in setup ?

1 Like

In that case, I guess you want to detect when you loose connection to the Blynk server, not when you loose wifi connection. So you could try this:

void connectionstatus() {
    if (!Blynk.connected()) {
        digitalWrite(XX, LOW); // off
    .
.
.
1 Like