How to build your own LagBox

This guide will teach you how to build the hardware for your own LagBox, install all necessary software and conduct your own measurements on input devices of your choice.

More information on the project can be found here.

If you already have conducted measurements, you can share them with us here.

Hardware build guide

 What you will need
What you need:
  • Raspberry Pi computer (e.g. Raspberry Pi Model 3B)
  • optocoupler, model no. A817 (Link to datasheet)
  • 150 ohm resistor
  • perfboard
  • male pin headers
  • jumper wires
  • crocodile clips
  • An input device you want to use for your measurements (e.g. a mouse)
  • tools to open your input device (screwdriver, etc.)

Build a small circuit with the Optocoupler:
  • solder sockets for the Optocoupler IC to the perfboard.
  • connect one pin of the LED side of the Optocoupler to a protective resistor (150 Ohm).
  • add pin headers to both the LED side and the transistor side of the Optocoupler so both can be connected using jumper wires.

Make sure the Optocoupler is placed in the correct way in the socket (see datasheet).

 What you will need  What you will need
Connect the circuit to the Raspberry Pi as shown in the diagram. Our code uses GPIO pin 22 of the Raspberry Pi. You may use any other pin, but this would require a change of the corresponding constant in the source code.

 What you will need
Open the device you want to test.
 What you will need
Locate the contact points of the button you want to use.

 What you will need
Attach probes to the contacts of the button or permanently solder wires to them.

Optional: Use a multimeter set to Continuity Test Mode to check if the circuit over the attached wires will be closed if the button is pressed.

 What you will need  LagBox circuit
Final setup:
  1. connect the Raspberry Pi to a monitor
  2. attach a keyboard and a mouse to the Raspberry Pi (you will need a dedicated mouse for in order to control the software. Therefore you will need a second mouse if you want to measure the input latency of a mouse as shown in the image)
  3. connect the device you want to use for your measurements to the optocoupler as shown in the schematic
  4. start the LagBox software on your Raspberry Pi and you are ready to go! A guide on how to install the software can be found in the section below

How to install the Software

1. Install the latest version of Raspbian on your Raspberry Pi
2. Open a terminal
3. Install all dependencies available in Raspbian (PyQt5, Matplotlib, Seaborn):

sudo apt install python3-pyqt5 python3-matplotlib python3-seaborn

4. Install the evdev module for Python via pip (it's not available as a Raspbian package):

pip3 install evdev

5. Clone the code from the LagBox GitHub Repository to a folder of your choice:

git clone

6. Navigate to the src/ folder inside the LagBox folder you downloaded (e.g. cd LagBox/src/). Run the following command:


How to use the software

  1. Open a terminal
  2. Navigate to the folder where you installed the software, e.g. …/LagBox/
  3. Navigate to the gui/ folder (e.g. cd LagBox/gui/)
  4. Start the software with the following command:


Figure 1: LagBox circuit
  • Select the device you want to use for measurements from the dropdown. All devices connected via USB will be listed here.
  • The correct device type will be preselected, but can be changed manually.
  • Name the device to make the output log clearly attributable
  • (Optional) Provide the European Article Number (EAN)/ Universal Product Code of the device. This makes sure that the device can be easy identified by other people

Figure 1: LagBox circuit
Press the button on the device once. The software should automatically detect the correct ID.

Figure 1: LagBox circuit
Make sure the probes/wires are connected to the corresponding button. Press the button one more time and the measurement will start automatically.

Figure 1: LagBox circuit
After the measurement is finished, the results will be displayed. The output folder where all data including the diagram is saved will be displayed

Figure 1: LagBox circuit
You will be asked if you want to share your measurement results with us.

Figure 1: LagBox circuit
If you decide to upload your measurements, just fill out the form on this screen. Make sure that your Raspberry Pi is connected to the internet.