WiFi Security System

2,076

18

3

Introduction: WiFi Security System

About: I am here to share what I make. Hopefully, you can learn from watching what I have done and even improve upon it. As an Amazon Associate I earn from qualifying purchases.

This project will track movement and the light level of the surrounding area. You can put this in your room to let you know if your dog is snooping around, use it as a home security system, or to find Santa in your house on Christmas eve.

Step 1: Set Up the Circuit

Using a breadboard and jumper wires, follow the diagram to build this circuit. To power it, use a micro-USB cable.

Step 2: Set Up the App

In the Blynk app you need to create these widgets:

  • A SuperChart
  • Two Gauges

One gauge is for tracking the light level and the other is for movement. The SuperChart is used to track both of these over time. Follow the pictures for how to set them up.

Step 3: Upload the Code

Upload this code to your Blynk Board in the Arduino IDE and remember to change these three things:

  • char BlynkAuth[] = "yourauthcode";
  • char WiFiNetwork[] = "yournetworkname";
  • char WiFiPassword[] = "yourwifipassword";
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define BLYNK_PRINT Serial

char BlynkAuth[] = "";
char WiFiNetwork[] = "";
char WiFiPassword[] = "";

int calibrationTime = 30;
long unsigned int lowIn;
long unsigned int pause = 5000;
boolean lockLow = true;
boolean takeLowTime;

void setup() {
  pinMode(A0, INPUT);
  Blynk.begin(BlynkAuth, WiFiNetwork, WiFiPassword);
  pinMode(12, INPUT);
  digitalWrite(12, LOW);
  for (int i = 0; i < calibrationTime; i++) {
    delay(1000);
  }
  delay(50);
}

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

BLYNK_READ(V5) {              //hardware to app
  int light = analogRead(A0);
  Blynk.virtualWrite(5, light);
}

BLYNK_READ(V4) {              //hardware to app
  if (digitalRead(12) == HIGH) {
    if (lockLow) {
      lockLow = false;
      delay(50);
    }
    takeLowTime = true;
  }
  if (digitalRead(12) == LOW) {
    if (takeLowTime) {
      lowIn = millis();          //save the time of the transition from high to LOW
      takeLowTime = false;       //make sure this is only done at the start of a LOW phase
    }
    if (!lockLow && millis() - lowIn > pause) {
      lockLow = true;
      delay(50);
    }
  }

  Blynk.virtualWrite(4, digitalRead(12));
}

You will need to have the Blynk library installed in order for this code to work. Download it in the attached file.

How to install a Library: www.arduino.cc/en/Guide/Libraries

Design For Kids Challenge

Participated in the
Design For Kids Challenge

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Wireless Contest

Participated in the
Wireless Contest

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    3 Discussions

    0
    Pib2
    Pib2

    2 years ago

    Cool!, have you ever used an arduino Yun with blink? Is it the same process?

    0
    millerman4487
    millerman4487

    Reply 2 years ago

    I have never used a Yun board but from what I have just read about it, the process should be fairly similar. Just change the device you're using in the Blynk app (through the nut icon in the upper right) and you should be good to go.

    Screenshot_20171209-162927-01.jpeg
    0
    Pib2
    Pib2

    Reply 2 years ago

    Thanks!