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.


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;
    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){
      isClosed = true;
      if(lastState != isClosed){
        Keyboard.print(" "); //send a key signal if the peephole is open
    lastState = isClosed;

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 !


Step 4:

Raspberry Pi Contest 2020

Runner Up in the
Raspberry Pi Contest 2020