https://www.learnsteps.com/raspberry-pi-motion-sensor-example/
Raspberry PI Motion Sensor example: Shutdown the systems on inactivity