I always liked the concept of automatically locking my workstation when I leave the desk unattended for a short period of time. Oh well, apparently the LD2410, the presence sensor everyone is talking about for being cheap, practical, and functional is the perfect fit for the project.
Simply: the sensor operates with 5V, which I can provide via USB, and sets a pin HIGH at 3.3V (fantastic, no level shifting required) if a human is detected. Have a MCU that supports USB natively and presto the solution is ready.
I connected the sensor to my favorite dev board (a Seed Xiao nrf52840) using the pin D7. The rest is very simple code.
Wait for the pin to go high, set a timeout and when the timeout triggers send the corresponding lock sequence keyboard shortcut (on Mac: GUI + CTRL + Q). I resisted the temptation of using interrupts as the MCU has literally nothing to do, it's connected to a reliable power source and further thinking totally overboard.
A built-in LED echoes the status reported by the sensor for easy monitoring (is the thingy powered on?)
The only improvement left is to have the LED blink during the timeout period in order to attract enough attention to avoid a surprise lock when not appropriate.
Enjoy
INGREDIENTS:
- your favorite MCU supporting USB emulation
- an LD2410 sensor
- the code
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.