WTF-Counter version2

Nikolaus Gradwohl2018-11-11T04:15:20+00:00

nine years ago I build the first version of my wtf-counter - a huge emergency button connected to an arduino and a linux box that later got replaced with a raspberry pi. The button can be hit whenever a WTF! situation is happening in the office and the current count is displayed on a monitor. The installation is still in place and used quite a lot - but since I'm currently working at a customers site, I've build a second version. But since the toolstack I used for v1 is a bit dated by todays standards I decided to modernize it a bit.

The new version of the WTF-Counter uses a raspberry pi zero and the emergency button is directly connected to one of the gpio pins of the raspberry using only a resitor and a ts-jack. The pi writes an entry to a log file whenever the button is hit and uses a small monitor to display the current count using a small pygame programm. I didn't install an X-Server but draw the graphics directly on the framebuffer of my pi.

wtf counter v2

Reacting to a io-pin change is pretty easy - I registered a call back function that gets triggered whenever the pi recognizes a state change on the pin. The callback function then writes a line to a backup file with the current timestamp and increases the counter.

import RPi.GPIO as GPIO
import time;
import datetime;

count = 0;

def button_callback(channel):
    global count

    t = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
    f = open('wtf.txt', 'a+');
    f.write("%s WTF!\n" %t);
    f.close();
    print("WTF! %d" %count);
    count += 1

buttonPin = 10
GPIO.setmode(GPIO.BOARD)
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(buttonPin,GPIO.FALLING,callback=button_callback, bouncetime=200)

I also printed a small enclosure for my WTF-Counter on my 3D Printer and added a small text logo on the lid of the enclosing box by cutting out the letters from the lid and embossing them on a small plane so I could then glue them together.

The result looks way more polished than v1 and I'm quite pleased with the result.

Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

Arduino based Office-WTF-Counter
grease pencil experiment 6 - grid
grease pencil experiment 4 - filled shapes
grease pencil experiment 4 - depth of field
grease pencil experiment 3 - animated circles

Trackbacks

Comments

Leave a response

Leave a comment