Raspberry Pi Timer

At one of our manufacturing customers, something strange was happening.

Employee lunch was at 11:45am. That became 11:40am over several months. And it was only moving earlier.

After tracing out the relay wiring for the alert system, we found the connector to the relay controlling the alert system inside one of the old timeclocks. When a customer of ours swapped their timecard software, their old timeclocks stopped updating the current time. Over several months, the time began to drift on the clock. Slowly, the clock became less and less accurate.

We needed to replace this clock with a clock that could keep the current time. It needed to be programmable. And, it needed to have pins to signal a relay.

Those requirements led to us purchasing a Raspberry Pi. The Raspberry Pi is a micro-computer, about the size of a credit card. For its size, it packs a lot of power. It has a quad-core CPU, a gig of RAM, and WiFi built in. The “hard drive” is actually a micro-SD card with Raspbian Linux installed.

Gurchetan, one of our application developers,  and I wrote a Python script for triggering the GPIO pin on the relay board. To test this, I bought a breadboard and wired a test LED. We also plugged in some speakers and had a bell chime since we couldn’t monitor the light all day.

After testing the script and ensuring it works for a few days, we moved to configuration of the Pi. In this case, all we had to do was the standard security stuff (change SSH port, change default username and password, install and configure Fail2Ban, etc.) and edit cron to include our Python script.

Then I wrote some documentation since this device will probably be triggering a relay for the rest of its life. The Python script went into our archives. Time was restored to normal; lunch is now at 11:45am.