Lock your laptop screen automatically using a person sensor - Raspberry Pi Projects, Tutorials, Learning DIY Electronics - Makergenix

Breaking

 


Lock your laptop screen automatically using a person sensor

 When you walk away from your laptop, lock the screen. If someone is watching you, even minimize the primary window.

Lock your laptop screen automatically using a person sensor

A tiny $10 hardware module called the Person Sensor from Useful Sensors can identify close faces. I'll demonstrate how to utilize it in this example to automatically lock your screen when you walk away and shrink the open window if someone is watching you.


Start by connecting the sensor with the port on the end of the Trinkey using the cable. When connected to a USB port on your laptop, push the Trinkey's bootsel button. The file viewer should now display an RPI-RP2 drive.

The short version is that you download CircuitPython for the Trinkey and copy it to the RPI-RP2 disc. There is a step-by-step tutorial for installing CircuitPython on a Trinkey here. You should notice a new CIRCUITPYTHON drive appear once the copying is finished.


The first step is to download a sizable bundle of all the CircuitPython libraries from circuitpython.org/libraries since we need the adafruit hid library to accomplish keyboard emulation. The right package for your version of CircuitPython must be found.

Lock your laptop screen automatically using a person sensor

Open the package on your local PC after you've downloaded it. Copy the adafruit hid directory from the unpacked bundle's lib folder to the lib folder on the CIRCUITPYTHON disc using the file reader.


The CircuitPython code is now required to verify the sensor and, if necessary, lock the screen. If you are acquainted with git, you may clone the github.com/usefulsensors/person sensor screen lock repository using the command line. If not, you may simply unpack the code on your computer by downloading it as a ZIP package from this link.


The code should function without modification if you're using Windows. You will need to change the keys supplied to make the screen lock on MacOS or Linux. The choices for the various operating systems should be commented out if you look at the end of code.py. Add a # before the Windows line in a text editor, then take the # off before the bar for your OS.


Copy the code.py file from this repository into the CIRCUITPYTHON disc after Trinkey is configured. You'll see that when the Person Sensor detects your face, the green LED on it illuminates. The screen should lock if you point it away from yourself for more than five seconds. If it notices someone watching you for more than a second, it will also try to minimize the open window.


The sensor must be oriented correctly, with the connector at the top and facing in your direction. If your Qwiic cable is long enough, you may consider placing it on top of your laptop's display.

 


Most Viewed Posts

Write For Us

Name

Email *

Message *

All Blogs