Virtual Peephole

11,708

78

29

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

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

    • Furniture Contest

      Furniture Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Arduino Contest

      Arduino Contest

    29 Comments

    0
    tanyabobanya
    tanyabobanya

    Question 1 year ago

    Hi, I am starting over finally with a new 5 inch screen. Curious if a smaller one would work. I was also wondering if your insecam link is old existing video or live? If I get to that point I’ll be relieved. I also don’t understand why if this is a raspberry pi project, would I be using a computer screen. I have too many components for someone who knows so little. Wish me luck.

    0
    carolinebuttet1
    carolinebuttet1

    Answer 1 year ago

    Hey Tanya,
    The link shows live videos. Good luck with this project!
    Feel free to drop me an email if you have some issues: carolinebuttet@gmail.com

    0
    tanyabobanya
    tanyabobanya

    1 year ago

    i'm a total novice. Do i use my laptop as the "keyboard" or a different keyboard?
    I'm trying to find a chord that will fit in laptop. but i have a little keyboard for an iPad too. not sure what to use.

    0
    carolinebuttet1
    carolinebuttet1

    Reply 1 year ago

    Hey,
    You can just use any keyboard as long as it is connected to the computer you are using. If you use a Raspberry Pi, then you need an external keyboard that you can plug via USB. If you use your laptop, then your laptop keyboard is fine.
    Happy hacking!

    0
    tanyabobanya
    tanyabobanya

    Reply 1 year ago

    Thank you! I’m using the rasperry pi and I see only lines on the screen . Maybe it’s the little screen that’s not ok. Frustrating.

    0
    carolinebuttet1
    carolinebuttet1

    Reply 1 year ago

    Hey Tanya,
    Lines on the screen are normal when you boot the raspberry pi, but they should disapear after 30 seconds or so.
    If the lines do not disapear then maybe you should consider changing your power supply. Make sure your power supply delivers enough current for your raspberry pi.

    0
    tanyabobanya
    tanyabobanya

    Reply 1 year ago

    I’m using the recommended power source with an extension cord and tried plugging directly into wall, still got lines that stay. I’ll order another screen. Or raspberry pi.

    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 1 year 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 1 year 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 1 year 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 1 year ago

    Awsome <3

    0
    carolinebuttet1
    carolinebuttet1

    Reply 1 year ago

    Thanks Penelopy! :)

    1
    jessyratfink
    jessyratfink

    1 year ago

    This is a fantastic project :D

    3
    Matlek
    Matlek

    1 year ago

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

    1
    andyk75
    andyk75

    1 year 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!