opengeodata.de

Raspberry Pi Punchclock - Part 1

2017-10-06

Suppose, you’re lazy. Really lazy. Lazy like in: too lazy to ignore not one but two time tracking techniques which cost you time already. So lazy, you can’t be bothered to even type something in the computer.

Raspberry Pi & PIR to the rescue! The idea is pretty simple: get the computer to track when you’re not on your computer. Therefore, hook up the PIR to the Raspberry and write some code which measures movement over a time period n. If the average of these measurements drops below a certain threshold, you’re likely not on your computer (or asleep). In this event, write some data in a database (date, timestamp, time since last measurement). After this squiggle some SQL on the screen and export the data in the format you need.

First part is done (see the gist), SQL squiggling to be completed.

The code has a logging function, will create/connect to a sqlite database and takes - as for now - 50 measurements over 200 seconds which will be averaged afterwards. The threshold is set at 0.05 which is due to the improper placement of the sensor, at the moment. I will share the SQL (adjusted to my specific needs) some time later.