The Shed

THE SMART PEEPHOLE

LEARN HOW TO USE TECHNOLOGY TO MAKE YOU AND YOUR HOME FEEL MORE SECURE

- By Enrico Miglino Photograph­s: Enrico Miglino

As stated in the first article of this series, all the projects I present should be easy to make and easy to implement in a generic home setting with as few modificati­ons as possible. Therefore, this is also what we will try to do with this issue’s project: a digital peephole.

I have already published an article in The Shed Issue No. 81, showing the basis of how to build a magic mirror. A magic mirror is essentiall­y a half-reflective mirror with a black sheet on the back and a rectangula­r square showing a display, also with a black background. That project is also included in the new Best of The Shed 2, in shops now or very soon.

Now it is time to recall the project for a useful applicatio­n as part of our smart home improvemen­ts. The idea is to make something nice, with a practical use, to hang inside the door of your home: moving the traditiona­l peephole to the next level.

Hardware and settings

In this project, I have used a Raspberry Pi seven-inch touchscree­n display but the choice depends on what kind of display you are using; it is also possible to use an old HDMI display without the plastic case. To reach the best effect it is important that the flat screen is fixed to the back of the semitransp­arent mirror.

The back frame

The back frame performs two roles: it creates the black background behind the one-way mirror and it keeps the display in place.

It should be pure black and robust enough to support the weight of the display. In the project illustrate­d in this article, where I used the standard Raspberry Pi seven-inch LCD display, a 2–3mm thick plywood or black acrylic sheet is sufficient; the thickness of the frame depends on the weight of the display you will use.

Keep pressing the back frame to the one-way mirror with L-shaped supports fixed to the internal sides of the frame; I have printed them

adapting the design to the size of my handmade wooden frame but commercial aluminium ones will work just as well.

The electronic Raspberry Pi and the wires are lightweigh­t so do not require any kind of support. You can fix them on the back-side cover of the mirror.

The peephole

To make the peephole I have fixed the Raspberry Pi camera to the back of the mirror. The connectors between the Raspberry Pi and the camera and display will determine the position of the board inside the magic mirror. I have positioned the display on the front side at about one-third of the height of the mirror and the camera at almost the same height in the middle of the back cover of the mirror. For good ventilatio­n I have added a series of 3D-printed supports, leaving about 3cm of space between the back and the front frame of the mirror, thereby avoiding a completely closed box.

The final component I added, to make it easy to control the outside view through the peephole, is an HC-SR04 ultrasonic sensor. We have already used one in the previous smart home article in The Shed Issue No. 93, Improving the Kitchen.

In the kitchen project, the sensor was used to detect the presence of the pan on the cooking plate as well as the presence of a person in the kitchen. Here, the same sensor is used in a more sophistica­ted way.

The sensor

The ultrasonic sensor can also be used to measure the distance from a subject in a precise way; it consists of two main components soldered on a small board: an emitter and a receiver.

The Raspberry Pi sends a short signal of 10 millisecon­ds (ms) to trigger the sensor; as the sensor is activated (triggered) the emitter component sends a burst of eight pulses at a frequency of 40kHz. When the ultrasonic emission meets a subject an echo is generated and a return frequency is detected by the receiver component.

The sensor calculates the time passed between the end of the sent burst of pulses and the received signal. The distance of the subject can be calculated with this simple formula:

Knowing that the speed of the emitted ultrasound burst is 34,300 centimetre­s per second (cm/s) we can then calculate with good precision the distance of the subject by applying this formula:

Note that we have applied the formula to half of the speed of sound because the distance calculated is half of the path of the frequency from the emitter and receiver components.

We will use the ultrasonic sensor as a switch to change the display screen when a person is encountere­d near the magic mirror. Being able to calculate the distance with the precision of 1cm, it is possible to fine-tune the distance that the sensor should react.

The HC-SR04 ultrasonic sensor is wired to the Raspberry Pi and positioned — in this project — on top of the frame. In fact, it can be positioned in the most convenient place for you.

The Python sensor software

I have tried to structure the software to be as modular as possible. There are three modules: the magic mirror applicatio­n that stays on top the ultrasonic sensor that runs in the background the camera image that is shown live until the person is positioned in front of the magic mirror.

Let’s look at the parts in detail. The camera show is driven by the distance_sensor.py Python script.

service starting on boot. To achieve this there are some small changes and components that should be set up, well explained on the main page of the GitHub repository: github.com/ alicemirro­r/SuperSmart­Home.

What happens when the sensor detects a subject close to the magic mirror? It starts a camera live visualizat­ion, shown on top of the screen for a predefined period of time.

The camPreview(sec) function shown below is just an example of what can be triggered by the sensor when the desired distance is reached:

# Shows the camera preview for a number of seconds def camPreview(sec):

camera.rotation = 180 # Image is bottom-top

# Show the camera preview

camera.start_ preview(alpha=192)

# And brightness 0

camera.brightness = 0 # Progressiv­ely increase the brightness

# to the maximum for i in range(0, 50): camera.brightness = i time.sleep(0.1)

# Leave the preview visible for the desired

# number of seconds time.sleep(sec) camera-stop_preview()

Newspapers in English

Newspapers from Australia