Not able re-connect to wifi router

Hi, i encounter a problem. I noticed my Wifi WeMos D1 board not able re-connect to my wifi router after i add “Blynk.Timer” . The Board only able connect to wifi router when just upload the code. After uploaded the code ,I reboot my wifi router the Board not able re-connect again to the wifi router.Anyone can help? The sketch code are below:

#define BLYNK_PRINT Serial


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

BlynkTimer timer;

const int pin8 = D8; // Green LED Output V0
const int pin6 = D6; // Yello LED Output V1
const int pin7 = D7; // Red LED Outptut  V2
const int pin5 = D5; // Green LED sync   V3
const int pin4 = D4; // Yello LED sync   V4
const int pin3 = D3; // Red LED sync     V5

  
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxx";

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

BLYNK_CONNECTED()
{
  Blynk.syncAll();
  Blynk.syncVirtual(V0,V1,V2,V3,V4,V5);
}

BLYNK_WRITE(V0)
{
  int pin8State = param.asInt();
  digitalWrite(D8,pin8State);
}

BLYNK_WRITE(V1)
{
  int pin6State = param.asInt();
  digitalWrite(D6,pin6State);
}

BLYNK_WRITE(V2)
{
  int pin7State = param.asInt();
  digitalWrite(D7,pin7State);
}

void checkPin() {
  
  int pin5State = digitalRead(D5); //  V3
  int pin4State = digitalRead(D4); //  V4
  int pin3State = digitalRead(D3); //  V5
  
  if (pin5State == 1) {
    Blynk.virtualWrite(V3,255);
  } else {
    Blynk.virtualWrite(V3,0);
  }
    if (pin4State == 1) {
    Blynk.virtualWrite(V4,255);
  } else {
    Blynk.virtualWrite(V4,0);
  }
    if (pin3State == 1) {
    Blynk.virtualWrite(V5,255);
  } else {
    Blynk.virtualWrite(V5,0);
  }
}



void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  pinMode(pin8,OUTPUT);
  pinMode(pin6,OUTPUT);
  pinMode(pin7,OUTPUT);
  pinMode(pin5,INPUT);
  pinMode(pin4,INPUT);
  pinMode(pin3,INPUT);

  timer.setInterval(1000L,checkPin);
}

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

So you only have problems when you get disconnected fron your router ?

My problem the WeMos D1 board not able re-connect to the router after reboot the router. I did tried use other devices,the other are able re-connect to the router. Also i upload other sketch to the WeMos D1 board,it’s able re-connect to router when reboot the router. I think the code something wrong.

Use Blynk.config() instead, along with some connection management

i.e.

Blynk.connectWiFi(ssid, pass);
Blynk.config(auth);
Blynk.connect();

Hi Gunner, how to convert to Sketch Form?

Don’t know what you are asking about…there is no converting required… read the links I sent.

Ok.

I noticed that the WeMos D1 board is able connect to the router no matter how many time i reboot the router since i took out all wires from the board. It’s not able re-connect to router only happen when i connect back all wires to the board. I changed the code to : Blynk.config(auth);
Blynk.connectWiFi(ssid, pass);
Blynk.connect();

              Or 

Using the original code:
Blynk.begin(auth, ssid, pass);

The board have the same situation, take out all wires from board, the board is able re-connect to the router. Connect all wires back to the board, the board not able re-connect to the router.

ESP8266 (including Wemos) boards have peculiarities with booting when certain pins are LOW or HIGH… this is NOT a Blynk thing, but you can search for further info in this forum as well in the Internet.

Here is your problem. And it’s ESP related, study your hardware before attaching wires.

This really makes no sense at all.

Should be 115200 or 74880 for ESP standalone.

1 Like

I did trouble shoot pin by pin. As a result i noticed that D0,D1,D2,D8 and D9 can not be used as digital I/O or assigned as Virtual Pin. They will affect the Sketch do not work properly. Those pins have been labled as RX , TX , TX1 , not support I2C and FLASH mode. I tried to find these pin lable meaning of WeMos D1. But result show how to install driver for this board , how to upload sketch to this board, how to download the library and so on…
Anyone know where to get the information about the board pin lable?

I find the manufacturers site for these type of development boards to be very good for this type of information.
https://wiki.wemos.cc/products:d1:d1

I get this before. Anyway thank you.

99% sure that’s not correct. With effort almost any pin on the board can be used. It’s just that some are easier to use than others and the regular pins should be used before moving on to the special pins.

What information are you missing?

You can test much of this yourself.

Print out the pin status of all the pins before and after the connection to Blynk and it will tell you a lot. From this data you can then work out what code you need to change the high / low status to suit your project.

Ask again once you have the data if you need further assistance.

Anyone know Arduino Mega 2560 Board I/O voltage? 3.3V or 5V? Or else?

The Arduino Mega 2560 uses 5v TTL logic level compared to 3.3v for ESP8266/NodeMCU.

3.3v is the new 5v :grinning:

Pete.

Apparently Arduino knows a thing or two about their boards :wink:

https://store.arduino.cc/usa/arduino-mega-2560-rev3

Works great with Blynk by using my favorite ESP-01 as WiFi adapter :stuck_out_tongue_winking_eye:

But as pointed out, “newer” MCUs use 3.3v… don’t mix the two without caution…