carolinebuttet
Published © GPL3+

Virtual Peephole

Spy on cameras around the world.

IntermediateShowcase (no instructions)8,966
Virtual Peephole

Things used in this project

Hardware components

Arduino Micro & Genuino Micro
Arduino Micro & Genuino Micro
×1
Photo resistor
Photo resistor
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Raspberry Pi Screen
×1
Wooden Box
×1
Door Eye
×1

Hand tools and fabrication machines

Drill, Screwdriver
Drill, Screwdriver

Story

Read more

Schematics

Photocell diagram

This is a simple photocell diagram.

Photocell diagram

Code

Light variation detection + Keyboard signal

Arduino
This code detects a light variation in the photocell and sends out a keyboard signal.
long previousMillis = 0;
long calibrationtime = 5000;
long startMillis = 0;
int sensorMin = 1024;
int sensorMax = 0;
int average = 0;
int threshold = 5;
bool lastState = true;
bool isClosed = true;

#include "Keyboard.h"

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("setup");
  Keyboard.begin();
  startMillis = millis();
}

void loop() {
  unsigned long currentMillis = millis();
  int sensorValue = analogRead(A0);
  //Serial.println(sensorValue);

  if(currentMillis-startMillis < calibrationtime) {
    // save the last time you blinked the LED 
    // print out the value you read:
    int elapsedtime = currentMillis - startMillis;
    Serial.println(elapsedtime);
    Serial.println(sensorMin);
    Serial.println(sensorMax);
    if(sensorValue < sensorMin){
      sensorMin = sensorValue;
      average = (sensorMin + sensorMax )/2;
    }
    if(sensorValue > sensorMax){
      sensorMax = sensorValue;
      average = (sensorMin + sensorMax )/2;
    }
    delay(100); 
  }
  else{
    if(sensorValue > average + threshold){
      isClosed = false;
      if(lastState != isClosed){
        }
    }
    else{
      isClosed = true;
      if(lastState != isClosed){
        Keyboard.print(" ");
        }
    }
    lastState = isClosed;
    delay(100);
   }
 
  //stabilize the reading in the first 3 seconds
  //then, detect a variation in the stabilization. 
  //also provide a reset button just in case.
  
}

Virtual Peephole website source code

This is the website that is displayed in the virtual peephole. Use the spacebar to navigate through webcams.

Credits

carolinebuttet

carolinebuttet

1 project • 17 followers

Comments