Nodemcu v1 using blynk

Thank you guys for the great support @Jamin @Gunner the code is working like charm
i will post it here in case somebody need it

/**************************************************************
   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 :)

 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SSD1306_LCDHEIGHT 64

#define OLED_RESET LED_BUILTIN  //4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

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

void setup()
{
  display.clearDisplay();
  pinMode(13, OUTPUT);
  Serial.begin(115200);
  Blynk.begin(auth, "ssid name", "pass");
}
void actionRelays()
{
  relay1_ON(); // turn on relay1
  timer.setTimeout(1000, relay2_ON); // delay 2sec then turn on relay2
  sendOLED();
  timer.setTimeout(5000, relays_OFF); 
  timer.setTimeout(5000, relays_OFF);// delay 15sec from first action and turn off both relays

  timer.setTimeout(5000, sendOLED);
  timer.setTimeout(5000, screen_clear);
}

void screen_clear()
{
   display.clearDisplay();
  display.display();
  }

void relay1_ON()
{
  digitalWrite(13, LOW); // turn on relay1
  Blynk.virtualWrite(V10, 255); // turn on an LED widget (optional)
}

void relay2_ON()
{
  digitalWrite(13, HIGH); // turn on relay2
  Blynk.virtualWrite(V20, 255); // turn on an LED widget (optional)
}
void relays_OFF()
{
  digitalWrite(13, LOW); // turn off relay2
  Blynk.virtualWrite(V20, 0); // turn off an LED widget (optional)
}


void sendOLED()
{

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.display();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Hello from:");
  display.print("Door is Open ");
  display.display();
  display.startscrollright(0x00, 0x0F);
 

}

BLYNK_WRITE(V7)
{
  if (param.asInt() == 1 )
  {
    actionRelays();
    // oled();
    // sendOLED();
  }
}



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

1 Like