A peephole, spyhole, or peekhole is a small opening through the door that allows viewing from inside to outside. Such door holes allow seeing outside the door without opening it. Usually, these door holes have a fisheye lens to have a wider look of the outside. In this project, we have developed a digital version of the peekhole with the help of a Raspberry Pi camera and a Raspberry Pi board. The first apparent advantage of a digital peekhole is that it can be easily concealed in a door design compared to conventional peekholes. Secondly, a camera-based peekhole gives a 180˚ view of the outside. A programmatically sophisticated version of the same peekhole can provide features like visitor identification (through face detection), logging unidentified visitors, and playing pre-recorded voice messages to specific visitors.
The device designed in this project uses a Raspberry Pi camera, Raspberry Pi board, a PIR sensor, and a small LCD screen with HDMI input. It can be easily integrated into any door and easily concealed in a door design. The prototype demonstrated here is developed on Raspberry Pi 3. This project’s commercial or hobby version can be developed using Raspberry Pi Zero to make the design compact. Once installed in a door design, the whole device can be powered with the help of a 5V 2A adaptor.
- Raspberry Pi 2/3/4 or Raspberry Pi Zero x1
- Raspberry Pi Camera x1
- Ribbon Cable for connecting Raspberry Pi camera x1
- PIR Sensor x1
- 5″ HDMI LCD
- Connecting wires/Jumper wires for testing prototype on a breadboard
While testing the project, you can interface the Raspberry Pi with a desktop display. Connect a small HDMI LCD to the Raspberry Pi’s HDMI port. Connect the Raspberry Pi camera to the CSI port of the board.
For interfacing the PIR sensor with Raspberry Pi, connect the input pin of the PIR sensor to any GPIO. Here board pin 7 is connected to the input pin of the PIR sensor. Connect the VCC and GND pins of the PIR sensor with the Raspberry Pi’s 3.3V out and ground pins.
It should be noted that the sensitivity of the PIR sensor needs to be adjusted to get the proper digital input. The PIR sensor is calibrated to provide defined output during program testing.
How the project works
The Raspberry Pi camera and the PIR sensor are installed at the front of the door. The Raspberry Pi itself is installed at the rear of the door. The door has a small horizontal cut to pass through the ribbon cable of the Raspberry Pi camera. The entire circuit is powered at the rear of the door with the help of a power bank or DC adaptor. A 5-inch LCD is connected with the Raspberry Pi at the rear of the door.
The user can run the python script as the device is powered on and Raspberry Pi boots up. The python script can be made to launch on the startup automatically. As the python script runs, it starts a preview of the outside on the LCD. For testing the preview, Raspberry Pi can also be connected to a desktop display with HDMI input. The preview continues without interruption throughout the script execution. After launching a preview, the Raspberry Pi continuously checks for the digital signal from the PIR sensor. Here the PIR sensor is calibrated to give an output of digital HIGH as it detects any motion outside the door. As it detects any motion, the Raspberry Pi camera captures the outside image and stores it with a file name having an ascending number.
The python script begins with importing PiCamera class from the PiCamera library and RPi.GPIO class from GPIO library. If the PiCamera library is not installed, it must be installed using pip or installed manually. Similarly, time class is imported from the sleep library. The GPIO is set to board numbering, and board pin 7 is assigned to input from the PIR sensor. Variables to hold image number, image name, and image URL are declared. The GPIO.setwarning() is set to false.
An object of camera class is instantiated using the Picamera() method. The PIR sensor pin is set as a digital input. The camera preview is started using the start_preview() method. A delay of 5 seconds is provided after starting the preview. This helps to stabilize the camera to ambient light and exposure.
An infinite loop is run to capture images of any movement outside the door. If the PIR sensor detects any motion, it gives an output of logical HIGH. If the output of the PIR sensor is HIGH, the image number is increased by 1 and is concatenated to string “image” in variable ‘imagename’. The image name is appended to a file path in variable ‘pathname’. The image of the outside is captured with the updated file location using the capture() method. The new image name is logged to the console using the print() function. A delay of 5 seconds is provided after an image has been captured.
The following images and video are of the testing of the device using a desktop display. Note that how the device captures the image of the outside on detecting every movement.
You may also like:
Filed Under: Electronic Projects, Microcontrollers, Raspberry pi