A Raspberry Pi application for timing races with GPIO inputs and a UI
- SOC: Raspberry Pi B+
- Inputs: 5 buttons connected to GPIO pins
- Outputs: Horn signal on GPIO pin + HD UI on mini HDMI
- GPIO Provider:
pigpiodsystem level service asroot - UI + Logic: ElectronJS as system service
- Backend: NodeJS v18.10
Reading information from the GPIO headers requires root privileges on said computer. This means that it's difficult to connect it with traditional UI-based applications which should not be ran as root. This solution utilized the pigpiod service running as the root to provide an interface for other local users to connect via localhost. The ElectronJS application connects to this API and polls the information on an event-driven basis. The applications is added as a service with the name racetimer to start it up with the system.
- Copy the project onto your Raspberry Pi device
- Install
nvmif not yet installed:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash(v0.40.2 is the latest at the time of this project). Restart the terminal session afterwards - Install NodejS 18:
nvm install 18 && nvm use 18 - Edit the racetimer.service file and update the
racetimeruser name inService.User,Service.WorkingDirectory, andService.Environmentto the user that will be automatically logged in when the device boots up (likely your current userwhoami) - Compile and install the service:
./install.sh - Restart the device, and the application should start up automatically in fullscreen mode
For this projets a Raspberry Pi B+ was used, but it can be easily reconfigured to work for any by editing the pin configuration in main.js
| Physical Pin | GPIO Header | Unconnected Voltage | Logical Function |
|---|---|---|---|
| 11 | 17 | LOW | Reset Button |
| 12 | 18 | LOW | Start Button |
| 13 | 27 | - | Horn Output |
| 3 | 2 | HIGH | Contestant 1 Button |
| 5 | 3 | HIGH | Contestant 2 Button |
| 7 | 4 | HIGH | Contestant 3 Button |
| 8 | 14 | HIGH | Contestant 3 Button |
| 10 | 15 | HIGH | Contestant 4 Button |
- https://www.npmjs.com/package/pigpio-client
- https://abyz.me.uk/rpi/pigpio/sif.html
- https://www.electronjs.org/docs/latest/tutorial/examples
- https://projects.raspberrypi.org/en/projects/physical-computing/1
- https://raspberrypi.stackexchange.com/questions/135965/fullscreen-gui-app-on-raspbian-startup
- https://www.npmjs.com/package/pigpio
- https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/5