Brayan Andrés BermúdezEdgard Daniel Ucha
Published © GPL3+

WiFi Security System Using WeMos D1mini (ESP8266) And Blynk!

A system that allows you to detect movement, send alert through your smartphone and turn on and off the lights of your home over internet!

IntermediateFull instructions provided4 hours19,788

Things used in this project

Hardware components

Wemos D1 Mini
Espressif Wemos D1 Mini
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1

Software apps and online services

Blynk
Blynk
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Conections to upload program to Wemos D1mini(ESP8266)

Hardware conections

Code

Wemos D1mini(ESP8266) code

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

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

SimpleTimer timer;

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

int state;
int contador=0;
int flag=1;

WidgetLED led1(V1);
WidgetLED ledmovimiento(V2);

void myTimerEvent()
{
  contador = contador+1;
  
  if(contador==5)
  {
    ledmovimiento.off();
    contador=0;
    flag = 1;
  }

  int MovimientoPersona = digitalRead(D7);
  if (MovimientoPersona) // You can write any condition to trigger e-mail sending
  {
    if (flag == 1)
    {
        Serial.println("Persona Detectada"); // This can be seen in the Serial Monitor
        Blynk.email("Subject: PIR Sensor", "Hay movimiento en la casa...");
        Blynk.notify("Heey....!! Hay movimiento en tu casa!");
        digitalWrite(D4, LOW);
        led1.on();
        // Or, if you want to use the email specified in the App (like for App Export):
        //Blynk.email("Subject: Button Logger", "You just pushed the button...");
        ledmovimiento.on();
        flag=2;
      
    }
  }
}




void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(D4, OUTPUT);
  timer.setInterval(1000L, myTimerEvent);
}

BLYNK_WRITE(V0)
{
  state = param.asInt();
  if (state == 1){
    digitalWrite(D4, LOW);
    led1.on();
  }
  else {
    digitalWrite(D4, HIGH);
    led1.off();
  }
}


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

Simple Timer Library

Blynk Library

Credits

Brayan Andrés Bermúdez

Brayan Andrés Bermúdez

9 projects • 19 followers
Edgard Daniel Ucha

Edgard Daniel Ucha

3 projects • 4 followers
An electronic engineer, hardware designs,

Comments