WiFi Security System

1,390

12

3

About: I go by millerman4487, and I am here to share what I make. Hopefully, you can learn from watching what I have done and even improve upon it. So here you go! If you have any ideas for future projects, send...

Intro: WiFi Security System

On Christmas Eve, children all over anticipate the arrival of Santa. Some might even stay up late to see if they can catch a glimpse. 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.

Step 1: Set Up the Circuit

For a complete bill of materials, visit my website. 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

Share

    Recommendations

    • Tiny Home Contest

      Tiny Home Contest
    • Fix It! Contest

      Fix It! Contest
    • Audio Contest 2018

      Audio Contest 2018

    3 Discussions

    0
    None
    Pib2

    9 months ago

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

    2 replies
    0
    None
    millerman4487Pib2

    Reply 9 months 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