Virtual Peephole

9,515

56

22

Introduction: Virtual Peephole

There are an estimated 770 million surveillance cameras around the world. Some of them still have their default password, making them easily accessible, by anyone who has an internet connection.

This virtual peephole is a device to watch some of those unsecured cameras. Each time the peephole is opened, a different camera is shown.

Supplies:

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Raspberry Pi and Arduino Setup

The virtual peephole is made of 2 distinctive parts: a Raspberry Pi (with a small screen) and an Arduino Micro. The Raspberry Pi is connected to the internet and displays a website, that shows one random camera feed.
There is a light sensor inside the peephole, to detect if it is open or closed. Whenever the peephole is closed, a signal is sent to the Raspberry Pi (via the Arduino Micro), and the website switches to another camera feed. The camera data I used for this project was scraped from Insecam, a website that registers over 73,000 unsecured cameras.

The website to display

For my virtual peephole, I have built a website with the data I collected from insecam. You can very well build your own website, but this is out of the scope of this insctructable. If you don't feel like building your own website, you can use this link (it changes webcam each time the space bar is pressed; we will later trigger that key from the arduino), or see the source code.

Setting up the Raspberry pi

  1. Make sure your Raspberry Pi is working and setup (see this guide if you're new to raspberry pi)
  2. Hook the LCD screen to the Raspberry Pi
  3. Have the raspberry pi open a webpage at startup

Setting up the Arduino

Attention: to make this project, your Arduino board must support the keyboard library As mentioned on the library's page:

Supported models are the 32u4 and SAMD based boards (Leonardo, Esplora, Zero, Due and MKR Family)

  1. Hook your light sensor to the Arduino
  2. Upload the code on the Arduino.
    The code will first run calibration for 5 seconds (during which the min and max value of the photosensor will be registered), and then send a "space" key signal whenever the light value is below the throsehold (meaning the peephole is closed).
previousMillis = 0
//because light always varies, we will calibrate the photosesor at each boot.
long calibrationtime = 5000; 
long startMillis = 0;
//the max value for an analog sensor is 1024
int sensorMin = 1024;
int sensorMax = 0;
int average = 0;
int threshold = 5;
bool lastState = true;
bool isClosed = true;

void setup() {
  Serial.begin(9600); // open the serial port
  Keyboard.begin(); // start the keyboard library
  startMillis = millis(); //start the counter
}

void loop() {
  //stabilize the reading in the first 5 seconds
  //then, detect a variation in the stabilization. 
  unsigned long currentMillis = millis(); //set millis as the current time
  int sensorValue = analogRead(A0); //read the sensor
  if(currentMillis-startMillis < calibrationtime) { 
    //as long as we are in the calibration time
    //during this calibration time, open and close the peephole to calibrate it. 
    int elapsedtime = currentMillis - startMillis;
    Serial.println(elapsedtime);
    Serial.println(sensorMin);
    Serial.println(sensorMax);
    if(sensorValue < sensorMin){ //register the max and min value for the sensor
      sensorMin = sensorValue;
      average = (sensorMin + sensorMax )/2;
    }
    if(sensorValue > sensorMax){
      sensorMax = sensorValue;
      average = (sensorMin + sensorMax )/2;
    }
    delay(100); //delay
  }
  else{ //if the calibration is done
    if(sensorValue > average + threshold){ //detect if the peephole is open or closed
      isClosed = false;
      if(lastState != isClosed){
        }
    }
    else{
      isClosed = true;
      if(lastState != isClosed){
        Keyboard.print(" "); //send a key signal if the peephole is open
        }
    }
    lastState = isClosed;
    delay(100);
   } 
}

Step 2: Setup the Box

  • Drill a hole in the door eye, to fit the photosensor (this will detect if your peephole is opened or closed and then trigger the webcam change).
  • Drill a hole in the box so that you can fit the door eye
  • In front of the door eye, secure the raspberry pi with the screen (I used velcro)
  • Wire the arduino:
    • Wire the photosensor to the arduino
    • Put a USB cable between the Rpi and the Arduino. The arduino will act like a keyboard and send key signals to the raspberry pi.

Step 3: Start Up the Virtual Peephole

Once you have put everything in the box, you are now ready to run your virtual peephole.

  • Place the virtual peephole on a wall
  • Plug the Rapsberry pi to the power
  • You will now have 5 seconds to calibrate the photosensor located in the door eye, by opening and closing it multiple times.

The virtual peephole should now work !

Enjoy!

Step 4:

Raspberry Pi Contest 2020

Runner Up in the
Raspberry Pi Contest 2020

Be the First to Share

    Recommendations

    • Tiny Speed Challenge

      Tiny Speed Challenge
    • Clocks Contest

      Clocks Contest
    • PCB Design Challenge

      PCB Design Challenge

    22 Discussions

    1
    Super Useable

    Hahaha very nice, I'm gonna built it into my actual #BarbiePeepShow 24/7 in Amsterdam.
    Come and watch and knock on my door to possibly meet me when I'm in. Would love that!
    Thanks for this great project and website you made! EEFinvorm

    2015-04-03 16.48.15.jpg
    0
    carolinebuttet1
    carolinebuttet1

    Reply 27 days ago

    Cool, let me know how it goes! I'll definitely visit your installation if I come to Amsterdam.

    0
    Super Useable
    Super Useable

    Reply 26 days ago

    yess! Nice!!
    Will you keep your site long open as it is now?
    otherwise I would like to know where you find this and the code you use...
    TNKS!

    0
    carolinebuttet1
    carolinebuttet1

    Reply 26 days ago

    Yes, I plan to keep the website open. However, I plan to share the code on github and will also write an instructable. I will update you when this is done. :)
    Happy making

    0
    Super Useable
    Super Useable

    Reply 25 days ago

    Awsome <3

    0
    carolinebuttet1
    carolinebuttet1

    Reply 27 days ago

    Thanks Penelopy! :)

    1
    jessyratfink
    jessyratfink

    4 weeks ago

    This is a fantastic project :D

    3
    Matlek
    Matlek

    4 weeks ago

    Very nice project, both artistic and scary (Big Brother is watching you!).

    1
    andyk75
    andyk75

    4 weeks ago

    Wow, great! I like the idea how it combines the voyeurism of people with the stupidity and ignorance for cyber security of maybe the same people!

    0
    serlinfg
    serlinfg

    Question 4 weeks ago on Introduction

    Hello, very good project!!! I would like to build it in my classroom for my students, but I would need to know how you made the website to change the camera when you press the space bar. Also the software (I think in python) that loads the webside at startup. Please can you tell me?. Thank you.

    0
    carolinebuttet1
    carolinebuttet1

    Answer 27 days ago

    Hey serlinfg, feel free to get in touch for more info.

    0
    20-Below
    20-Below

    4 weeks ago

    Great project, I love it ! But what happens if I happen to witness a crime ? How do I explain to the police that I have no idea where in the world this just happened !? Or that I saw it by hacking into someone's security camera ? Oh err...

    0
    carolinebuttet1
    carolinebuttet1

    Reply 27 days ago

    Thank you! Yes, that's tricky. I guess I could set up some kind of log of the visited cameras, but it seems overkill for that kind of installation.. And it's not hacking into security cameras, it's just accessing publicly available data ;-)

    0
    ScarletStar
    ScarletStar

    4 weeks ago

    Needs a little button or something so you can favorite a cam you like to be able to find it again later or increase the chances of it appearing again.

    0
    carolinebuttet1
    carolinebuttet1

    Reply 27 days ago

    That's a great idea indeed! Will definitely think about it.