Introduction: Work From Home Time Recorder Using a Raspberry Pi
Over the past year, I have had the opportunity to work from home. For which I needed to keep track of the hours that I work.
Starting by using an excel spreadsheet and entering the ‘clock-in’ and ‘clock-out’ times manually, I soon found this to be quite tedious (and I would forget to enter times).
I have a Raspberry Pi on my desk, and so decided to set up a work time recording solution using it and a few components from my son’s Arduino starter projects kit.
- Raspberry Pi
- 450ohm resistor x3
- 2 LED
- Mini Arduino button
- Breadboard for prototype
- Dupont connectors
Step 1: Prototyping
I started by building a prototype of the time recorder on a half-size breadboard. Once I was happy with the way it works the plan was to put together a boxed version using a 3d printed case and soldered connections.
The components are connected using Dupont wires as shown by the fritzing diagram.
Step 2: Setting Up the Raspberry Pi
I produced a short python script that would detect the button push and switch the LED states. On switching, the time is recorded in an excel workbook.
I’ve used the Openpyxl Library to interact with the workbook(which I created manually in the home folder on the Raspberry Pi).
The script enters a start time, end time, and a total for the work period.
Create a script in the home directory using your preferred editor(I used Thonney Python IDE) and save as clockin.py
Install LibreOffice on the Pi, if it’s not installed already, and create a blank workbook named hours.xlsx Run the script from the terminal using the terminal command python3 clockin.py. Or run it in Python shell or Thonney.
The red LED should light up to show that it’s running. When the button is pressed the blue LED lights up, the red one goes out, and the time is recorded in the spreadsheet.
Step 3: Python Script
Step 4: Boxing It Up
The Raspberry time recording device is working how I want, so it’s time to make it look more professional.
Using SketchUp to model a simple box to hold the button and two LEDs, with a hole for the wires to enter.
The design and print files can be found on Thingiverse
Step 5: Soldering
Again using Dupont wires, solder the components in place in the printed box.
Step 6: Sealing With Candle Wax
Adding a piece of heat-shrink at the exit of the box to pull the wires together and finishing off the unit by filling it with candle wax.
The addition of the candle wax protects and holds the connections in place, at the same time adding weight to help stop it moving around during use.
Step 7: Connect to the Raspberry Pi
The finished unit connected and running
At the end of the week, I copy the worksheet into another workbook to format and add up my hours worked.
This set-up is great for keeping track of ‘work from home’ hours, much better than manually entering times.
See this project on my website myprojectcorner.com/raspberry-pi-time-recorder/