Esp8266 and virtual pins

Hi, i have a problem with my project, when i have to write something in the virtual pins it didn’t work an also sometimes the connction with the wifi restart and disconnect the arduino from the wifi.
/*************************************************************
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.

 *************************************************************
  WARNING!
It's very tricky to get it working. Please read this article:
http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  NOTE:
  BlynkTimer provides SimpleTimer functionality:
http://playground.arduino.cc/Code/SimpleTimer

  App project setup:
Value Display widget attached to Virtual Pin V5
 *************************************************************/

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


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// 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[] = "";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

this is my sketch
the hardware is arduino uno and esp8266

So are you saying that the value display widget that you have attached to V5 isn’t updating with the number of seconds since your Arduino last rebooted?

Pete.

in the app i use a value display connected to the virtual pin 5, and when the arduino it sign “arduino connected” in the value display i didn’t see any value

What are you seeing in your serial monitor?
Copy and paste the text here.

Pete.

[9] 
___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
    /___/ v0.6.1 on Arduino Uno

[99] Con2:Wifi
[6910] WIFI GOT IP
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK
[10759] IP = +CIPSTA:ip:"192.168.43.57"
+CIPSTA:gateway:"192.168.43.1"
+CIPSTA:netmask:"255.255.255.0"
[10803] WOK
[21268] Ready (ping: 37ms).

Do you have multiple devices defined in your app project, or multiple projects in your app?

Pete.

I have two projects but there is two tokens

My guess is that you’re using the token for the wrong device in the wrong project.

Pete.

no because if i use the skech like blink blink it works (i place in the app a button with pin d13 and the led turn on or if i ask to read pin A0 it works)

Post screenshots of your D13 LED widget setup and your V5 value display widget setup.

Pete.

I’m out of ideas I’m afraid.
Maybe someone else can spot the problem?

Pete.

[I am not sure, I may be wrong.]
While creating a new project what device did you select ?
Was it Arduino UNO or ESP8266 ?
May be wrong selection of boards may be causing this issue !
or if you have multiple devices under the same project, then make sure the token is matching to the widget.

Try deleting the project
Create a new project
See if the problem resolves.
Also upload the sketch with new token.

i select the arduino Uno board, because i need to control it no the esp8266.
i only use the arduino in my project so the token is correct because if i don’t use the blynktimer and i try to write somethink in the virtual pin, it works.

Make sure your loop is free of any BLYNK_WRITE or Blynk.virtualWrite.
This will cause the server to flood and it automatically disconnects.

It is better to switch over to ESP8266(NODEMCU,WEMOS, etc etc). or ESP32.
Even i had struggled to get the ESP-UNO setup working good.

And for this (ESP&UNO) price you can get NODEMCU and that is more powerful and easy to use.(just my opinion).

the void loop is free of any type of virtual write, i try to use a BLYNK_READ outside any void, and put in a Blynk.virtualWrite, and it work, but i need to use repetitive functions outside the virtual pins, for example, read an analog pin and write in a digital pin

Can you show us your latest code? May be someone can help !

[Unformatted code removed by moderator]

Please format your code with triple backticks " ``` " at beggining and ending.
This will be easier to read the code.

Keep your void loop clean.

where i put that commands if blynktimer and virtual pins didn’t work outside loop?
because this sketch works