8/16 Input Event Logger

There usually comes a time where something doesn't work the way you expect or a piece of kit has an intermittent fault and you wish you could record the sequence of events leading up to and during the failure. To help with this I wrote a script for the Raspbery Pi that will record the date & time of events to a log file whilst dislaying the thirty most recent. The script monitors the GPIO and records the assigned function name, date/time and condition each time an input changes of state. Hardware design to interface the Pi is left to the to individual to suit their requirements - although I would recommend as a minimum to isolate the GPIO to reduce the chance of damaging the Raspberry Pi. The script will run on any Raspberry Pi with the 40 pin GPIO header.

Update v2.1: This update occurred due to the logger being too sensitive to rf interference caused by light or socket switches. I built a couple of Hats which optically isolate the 16 inputs (8 on each) from the device being monitored and taking the opporunity to reduce the pull up resistor values from 10K ohms to 1K2 ohms. By making this reduction it takes much more rf energy to affect the Raspberry Pi inputs - taking it well out of the range of that generated by light switches etc. If you are drawing or sinking currrent from the GPIO pins be careful of the limits - less than 3mA each.

Other changes are the GPIO allocations, simply due to the proto Hat used and now when first run the current state of each input is recorded so you have a starting point when looking back at events.

RPi 8 Input Event Logger Script (just copy & past into IDLE 2.7).

RPi 16 Input Event Logger Script (just copy & past into IDLE 2.7).

The isolated input Hat schematic.

Data Logger
Data Logger screen.

Demonstration of the 8 Input Event Logger

Demonstration of the RPi TDM with 16 Input Event Logger, relay contact states being recorded.