What I am doing wrong with this simple sketch

Hello everyone,
I am mechanical engineer and hooked in Arduino .
It looks Blynk is easy to use and share to other.
So I decided to do smart curtains.
I know I need motor which can be positioned like stepper motor or encoder dc motor or even servo, also I need home positioning any kind of sensor , controller with Bluetooth or wifi so go on
I finished couple of tutorials and here I am troubling with Blynk timer.
mycode () function only activates digital pin how simple is that but I am getting error like:
Login time-out
Connecting to Blynk-cloud.com:80()

 Add details : 
• wemos d1r1  Wifi .
• Smartphone OS (iOS ) Latest version 2020.08
• Blynk server ( I think)
• Blynk Library version volodymyr Shymanskyy version 0.6.1

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

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;

char auth[] = "hWc7LZyHvUAzymPAjm****iIN3dFt";
char ssid[] = "ipti****a";
char pass[] = "Myag****ar1**";

void mycode1();
#define LEDgreen  D6  
#define LEDred  D7 

void mycode1()
   digitalWrite(LEDgreen, HIGH); 
  digitalWrite(LEDred, LOW);

void setup()
  // Debug console

pinMode(LEDgreen, OUTPUT); 
  pinMode(LEDred, OUTPUT);
  digitalWrite(LEDgreen, HIGH); 
  digitalWrite(LEDred, HIGH);

     Blynk.begin(auth, ssid, pass);

void loop()

Seeing your full serial output from boot-up to error(s) would be useful.

Does this problem occur when you have nothing connected to your Wemos (other than the serial cable)?


thank you for quick replying.
please look at my code , nothing is changed but it is more easy to understand now.
before I was connected some sensors, relays, led
I disconnected and now nothing is connected to board except usb for flashing the sketch and powering.
but still same problem occours, I attached serial output pls find jpgerro

Okay, your device is connecting to your WiFo and obtaining an IP address, but it’s not managing to connect to the Blynk cloud server.

I’d start but rebooting your router and any other wireless access points/repeaters.
If that doesn’t work then try changing this line:

to this:

Blynk.begin(auth, ssid, pass, “blynk-cloud.com”, 8080);


I am Mongolian who s living in Korea , time difference, so tomorrow after work at 10-11 pm I will modify as you say
Btw, if I upload standalone example only modifying wifi info and toaken, it works perfectly . I think I am using Blynk timer in wrong way

Looks OK to me… although after the first second, nothing will change on your LED’s… once ON & OFF respectively, they stay that way… thus the interval timer is working, but really doing nothing much at all to show for its efforts.

If you want to see the action of the timer, try this…

void mycode1()
  digitalWrite(LEDgreen, !digitalRead(LEDgreen)); // Reads current state and sets to opposite state
  digitalWrite(LEDred, !digitalRead(LEDred)); // Reads current state and sets to opposite state

Hello Pete.
done my work and get here in home.
its time to blynk,
I tried this line which you suggest. it says multible library and i should use one of them.
I have no idea, may be google could help,
So I thought it could be solution to my problem so just letting you know.
Jumping to GTT’s suggestion.
btw, I am using older version, bcz I have avare of sudden things like losting library or what it could be, I know I have experiens only microsoft word or excel so i dont touch much other things in my computer, is it one of the problem?

@Miigaa1992 Re-type the quotation marks around “blynk-cloud.com” and that will fix that error.


Hello GTT.
in your suggestion ! look fantastic, never seen before, so I copied and paste,
nothing changed
but first it connected to the server with very high ping,
if I upload standalone sketch , ping could be 60-200ms.

what an noob,
I uploaded and it connected one time with high ping
pls find my previous comment which shows high ping also the code was my original code with GTT suggestion
and here it is with your suggestion
which is
Blynk.begin(auth, ssid, pass, “blynk-cloud.com”, 8080);

pls look at this wonderful 2 window

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

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
char auth[] = "hWc7LZyHvsssssss4yKRxiINssssssst";
char ssid[] = "ipssssssssssaa";
char pass[] = "Mysmsssssss2*";

void setup()
  // Debug console

  Blynk.begin(auth, ssid, pass);

void loop()

So it works fine with the simple sketch, but not your original one?

You said that you’re using a Wemos D1 R1, are you sure that’s correct, and what board type are you choosing when you compile your code?


I thinks so

Okay, it does seem to be a D1 R1 and you’ve chosen the correct board in the IDE.
I’m not familiar with these boards, as I prefer the D1 Mini, but I’m guessing that the pins you are using (D6 & D7) are causing a problem.
Try changing these to other pins instead.
Do you have any widgets in the app that are connected to digital pins?


I changed Pins 12 and 13
also 8 and 9 its shows same
my blynk app is very clear, i delete them all
BTW, I always use D before pin number, without D my serial monitor looks funny. like unknow symbols , scrolling ect
the problem is timer library i think
without these lines

BlynkTimer timer;

all working fine, I completed almost all blynk tutorials
exp: I can turn an and off LED
LED is connected to my D3 or any other
and button widget is connected to D3
sketch is simple sketch
but when I try to use timer its not connecting to the server
reason I using timer is, Blynk said keep the main loop clean.
it is the problem
BTW, today I bought NodeCMU and uploaded all the sketchs
its working fine,
so problem is now
Wemos d1r1 with blynk library, specially blynk timer, i think
Do I need toput away wemos d1 and use NodeCMU ?
after all I should contact with wemos d1 provider. :frowning:

That statement rings dome alarm bells with me.
The “funny symbols” are because the ESP8266 chip is outputting it’s boot data at a different baud rate to the rate set in your serial monitor. Change the serial monitor baud until these “funny symbols” make sense, and use this as the baud rate used in your void setup.
You’ll then have much more idea what the device is trying to tell you.


Okay, I will keep try until right baund rate
How about my original question
How to connect wemos d1 with Blynk server while keeping the loop clean

I would try using the actual GPIO numbers instead of the silk screened “D” numbers. You can find a reference as to how the “D” number relate to the actual GPIO numbers online. Due note that D6 is not GPIO 6.

I found this online, but not sure if it is corrct.

Yeah, I was seeing Nodemcu;s GPIO numbers
they say dont use silk screened D number , they are wrong, use GPIO numbering
and some other say if you want to use silk screened number with wemos d1, which is printed on the board,
I should use D before pin number
I am very confused, first it was funny serial print when I dont use Dx
and I googled found Dx works with wemos board so i stick with it
but now you are saying I need to use GPIO
I found it from arduino forum
forum link : https://forum.arduino.cc/index.php?topic=545113.15&fbclid=IwAR3F4YS5TzL3pBwOikwxIGZDF08tsuaz4zEASoG6W1T4Cj59pAB_0HuL6Xc
So, D6 is not 6 its 12 right?
lets look at the silk screen, I mean board
D6 is there and I write simple program using D6 and blynk
creat button wich connected to D6
and connect LED to D6
when I push the button LED is turning on,
WHAT ARE U talking about D6 is not d6,
code and LED is working perfectly also with blynk.
If D6 is not D6 the where to connect LED on board?

static const uint8_t D0   = 3;
static const uint8_t D1   = 1;
static const uint8_t D2   = 16;
static const uint8_t D3   = 5;
static const uint8_t D4   = 4;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 0;
static const uint8_t D9   = 2;
static const uint8_t D10  = 15;
static const uint8_t D11  = 13;
static const uint8_t D12  = 12;
static const uint8_t D13  = 14;
static const uint8_t D14  = 4;
static const uint8_t D15  = 5;

nah, I read about NodeMCU, its dangerous to noob like me,
io pins are taking very low currents also pins are more complicated than wemos.
so i will keep nodemcu and try to figure out wemos pin
ok, before it was, If i want to use Pin 6, then I write code using D, it looks like

define myLEDpin D6
 pinMode(myLEDpin , OUTPUT);
  digitalWrite(myLEDpin , HIGH); 

and I connet LED into D6 and Grond to gnd. so LED is on
If i want it to be controlled by my phone
I use blynk and cread buttin which connects to digital pin 6
so when I push the button LED is turned on,
CODE is D6 , Blynk is D6, also silk screen/ D6 is printed on the board
EVERYTHING was using D6
Okay, It is working but it is wrong,
so I need to use GPIO.
simply how I can use that?
like define myLED GPIO 6 (I believe it is not they way to use GPIO nubers)
and then expect to D12 light/ turn on ?
its funny, I looked at the silk screen/board D6 and D12 are on one PIN

somebody help me to use GPIO numbers in my code pls,
how about define myLED D9 = 2; and then connect LED to D2 ???
as follows it

static const uint8_t D9   = 2;