Sleep-Mode with Blynk

Hello Blynkers, When I push the button on the App then makes an GPIO HIGH on my ESP8266 Adafruit.
I will take my ESP with a battery… But for this I need the Sleep-Mode and this is my problem. The User for this project push the button in the App on HIGH and in this moment maybe the ESP is sleeeping. When he wakes up… In circuit of time, he check the blynk server any Button pushed in his sleep-Times. When it is… He do this. How can i this realise??
Thanks for answer.

Study syncVirtual in the comprehensive docs.

Thx for your help. Now i have the problem, when the ESP reconnected he activate the GPIO 12 for him self. The Code is correct but why he activate this Pin when he Comes from SleepMode?

/*********************************************************************************/
// * 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
// * Blynk community: http://community.blynk.cc
// * Social networks: 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.
// *
// * You need to install this for ESP8266 development:
// * 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 :slight_smile:
// *
/*********************************************************************************/
//Definitonen
/*********************************************************************************/
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h> // Essential for all Blynk Projects
/*********************************************************************************/
// PIN-Deklaration
/*********************************************************************************/
const int gpio12 = 12;
const int sleepTimeS = 10;
bool isFirstConnect = true;

/*********************************************************************************/
SimpleTimer timer;
/*********************************************************************************/
//Schlüssel zur Geräteidentifikation
/*********************************************************************************/
// Dieser Schlüssel-Code wird von der Blynk App ausgegeben.

auth is clone…

Network connection i had delet!!

/*********************************************************************************/
// Nach dem Neustart werden alle Buttons auf Ihren Status überprüft und angewandt
/*********************************************************************************/
BLYNK_CONNECTED()
{
if (isFirstConnect)
{
// Blynk.syncAll(); //Mit diesem Befehl werden alle Widgetswerte vom Server abgefragt und gesetzt
Blynk.syncVirtual(V3); //VirtualPin V3 wird einzeln abgefragt und zurückgesetzt
Blynk.syncVirtual(V0); //VirtualPin V0 wird einzeln abgefragt und zurückgesetzt
}
}
/*********************************************************************************/
// BLYNK_WRITE liest vom Server anstehende Werte ab, erhält bei jedem Flanken-
//wechsel einen anderen Wert und wird dadurch ausgeführt
/*********************************************************************************/
BLYNK_WRITE(V3)
{
const int wertV3 = param.asInt();
if (wertV3)
{
Serial.println("");
Serial.println("");
Serial.println(“The Sleepmode is activity i go to sleep”);
digitalWrite(12, LOW);
ESP.deepSleep(sleepTimeS * 1000000); //ESP-Schlafmodus
delay(100);

ESP.restart();                        //ESP-Neustart

} else {
Serial.println(“The Sleepmode isnt activ i check V0!”);

}
}
/*********************************************************************************/
// BLYNK_WRITE liest vom Server anstehende Werte ab, erhält bei jedem Flanken-
//wechsel einen anderen Wert und wird somit ausgeführt
/*********************************************************************************/
BLYNK_WRITE(V0)
{
const int wertV0 = param.asInt();
if (wertV0)
{
Serial.println("");
Serial.println("");
Serial.println(“V0 is activ i work now!”);

digitalWrite(12, HIGH);               // Setzt GPIO12 auf HIGH

}
else {
Serial.println("");
Serial.println("");
Serial.println(“V0 isnt activ, i go to sleep”);

digitalWrite(12, LOW);                // Setzt GPIO12 auf LOW

delay(1000);
ESP.deepSleep(sleepTimeS * 1000000);  //ESP-Schlafmodus
delay(100);
ESP.restart();                        //ESP-Neustart

}
}
/*********************************************************************************/
//Setup
/*********************************************************************************/
void setup()
{
Serial.begin(9600); // Baudrate
Blynk.begin(auth, ssid, pass);
//Blynk.begin(auth, ssid, pass); // Autentifizierung
pinMode(gpio12, OUTPUT);
}
/*********************************************************************************/
// Schlaufe
/*********************************************************************************/
void loop()
{
Blynk.run();
}
/*********************************************************************************/

@facanon you are calling pin 12 at various points in your sketch so presumably that is why you are seeing it active.

If this is not the case please describe in more detail what the problem is.

Thx. The problem was a edge from pin12 self. I solve this with a pulldown resistor. But the next hurdle i must take is, how can i the esp in deepsleepMode bringing back? I make a Bridge from
RST-Gpio16.
I have 3 Mode

  1. He is activ
  2. He sleep for preset time
  3. I will him wake up from the 2 point.

Is it smart and how can i him get out of sleep mode ??

@facanon I assume you know what to do for 1 and 2.

For 3 there is not a lot you can do without additional hardware.

What you can do is put a slider in your project from say 0 to 60 (minutes) and if you normally sleep for 60 minutes move the slider to 0 or say 1 whilst the ESP is asleep. When the ESP wakes it can then stay awake or just have sleep for a short period (again with sync). You can then receive a push or email message to say it is awake. This way you are not waiting around for it to wake up.

To actually force it to wake up early you can use a switch or a second ESP.

Thank you for your help.
I saw that is the next problem thats is coming. Because when I must allways waiting for wake up circuit it isnt the best solve. I try your Info today in the evening.
The other way is i wouldnt take deepsleep function. And I take an interupt to wake up… When he is in the light Sleep… But i dont know how i can this realize… I didnt know an other Sleepfunction only a Internet-Site …http://www.espressif.com/sites/default/files/9b-esp8266-low_power_solutions_en_0.pdf

@facanon is your project run from batteries or mains voltage?

If you are using batteries then you really need deepSleep to maximise run time between recharging the batteries. If you are running from the mains then there really isn’t any need for any of the sleep modes.

My Project run with battery.