Putting my computer to sleep with a piicodev distance sensor

IMG_0841 2

For when you’re too lazy to simply close the lid. :joy:

When the piicodev sensor detects proximity within 100 mm, my Python script publishes a message to my MQTT broker, subscribed to by a script on my computer. This script triggers a command to send to computer to sleep.

Next step is to figure out how to put my computer to sleep when I’ve been away from the desk a little while.

I used the paho-mqtt python package, mqtt in a docker container, and it’s all running off a Raspberry Pi.


Very interesting use of a PiicoDev Distance Sensor.
Thanks for sharing.


Hi Steven,

Welcome back!! :slight_smile:

Very elegant and great experiment!
I watched an interesting video recently on the difference between a motion sensor and actual human detection and came across this sensor: mmWave Radar - Human Presence Detection | DFRobot SEN0395 | Core Electronics Australia

I’m keen to see how you go!

1 Like

Hi Liam. The human presence detection looks interesting. A range of 9 m would work in most living areas and I could see it used in home automation set ups.