
Sub
google/mozc-devices
Circuit diagrams and firmware source code for Gboard DIY keyboards

A smart foosball table built for the UbiLab university course. The table identifies players by RFID, tracks the ball and score in real time, shows match status on an on-cabinet LCD per side, and streams everything live…
Ubi lab is an open-source printed circuit board by navidjavid, from the navidjavid/table-football-feedback repository on GitHub. It is a 2-layer board of 76 × 68 mm with 15 parts on 66 nets, routed with 131 tracks and 0 vias.
Its parts include 3 connectors, 2 resistors and 1 IC. It belongs with the radio and wireless boards and the RP2040 boards of this library.
A smart foosball table built for the UbiLab university course. The table identifies players by RFID, tracks the ball and score in real time, shows match status on an on-cabinet LCD per side, and streams everything live to a web dashboard hosted on a Raspberry Pi 4 — no internet connection required, the Pi runs its own WiFi hotspot.
This repo contains two independently-runnable projects:
| Part | Where | Runs on | Language |
|---|---|---|---|
| Embedded firmware | src/, include/, lib/ | Raspberry Pi Pico 2 W ×2 | C (Pico SDK) |
| Server + dashboard | server/ | Raspberry Pi 4 | Python (Flask) |
They talk to each other over MQTT/WiFi — but the two Picos also talk directly to each other over a shared I2C bus, so registration keeps working even with no Pi/WiFi present at all (see §3).
┌──────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
│ Ball tracker │────I2C (shared)▶│ Side A PCB │ │ Side B PCB │
│ (external, │────────────────▶│ Pico 2W + RFID + │◀─▶│ Pico 2W + RFID + │
│ other team) │ both boards │ display (PRIMARY) │I2C│ display (SECONDARY) │
└──────────────┘ listen └───────────┬──────────┘ └──────────┬────────────┘
│ MQTT/WiFi │ MQTT/WiFi
▼ ▼
┌─────────────────────────────────────────────┐
│ Raspberry Pi 4 │
│ WiFi hotspot "TableFootball" │
│ Mosquitto MQTT broker │
│ Flask web app (SSE) + SQLite (WAL) │
└───────────────────┬───────────────────────────┘
│ HTTP / SSE
▼
Any phone/laptop on the hotspot —
live dashboard, player profiles,
admin panel, tournament bracketsTwo independent PCBs, one per side — each has its own Pico 2 W, PN532
RFID reader, and EA DOGL128 display. Both boards listen to the same
shared I2C bus from the ball-tracker hardware. Exactly one board is
configured PICO_ROLE_PRIMARY (owns reporting ball position/score/state
to the Pi); the other only reports its own side's RFID taps + heartbeat —
this avoids the server ever getting duplicate/racing data from both
boards for the same table.
Data flow, end to end:
GAME_PLAYING with no update for 45s (a
board crashed/rebooted mid-match), the Pi's own watchdog auto-abandons
it — so a later reconnect never resumes a long-dead game.[PICTURE: photo of the assembled table — both enclosures, PN532s, LCDs visible]
hardware/enclosure/ in a sibling directory to this repo — not
version-controlled here) with a display window and a cable
pass-through for the shared I2C busPlus shared infrastructure:
[PICTURE: each component individually — Pico board, PN532 module with DIP switches labeled, EA DOGL128 display, an assembled enclosure, an RFID card]
The physical table is 140 cm long × 76 cm wide. The dashboard's
field visualization is intentionally drawn at this exact 140:76 aspect
ratio (server/static/style.css, .field { aspect-ratio: 140 / 76; }),
and ball coordinates are normalized to a 0–1000 × 0–500 grid before
being sent over MQTT so the same ratio holds end to end.
[PICTURE: top-down schematic of the table with dimensions labeled, goal positions marked]
| Component | Signal | Pico GPIO | Physical pin |
|---|---|---|---|
| PN532 (SPI1) | SCK | GP10 | 14 |
| MOSI | GP11 | 15 | |
| MISO | GP12 | 16 | |
| NSS/CS | GP13 | 17 | |
| RSTO | GP15 | 20 | |
| VCC / GND | 3.3V / GND | 36 / 38 | |
| EA DOGL128 (bit-bang SPI) | SI (MOSI) | GP19 | 25 |
| SCL (SCK) | GP18 | 24 | |
| A0 (data/cmd) | GP20 | 26 | |
| RST | GP21 | 27 | |
| CS1B | GP17 | 22 | |
| Shared ball-tracker I2C bus | SDA | GP4 | 6 |
| SCL | GP5 | 7 |
The display additionally needs 9 capacitors for its internal charge
pump (5×1µF on V0–V4, 3×1µF on the CAP1/2/3 chain, 4.7µF on VOUT) — see
docs/hardware_connections.md for the
full, datasheet-verified capacitor wiring table; it will not power on
without them, and the topology is easy to get wrong (this project did,
once, before it was corrected).
The shared I2C bus needs 4.7kΩ pull-ups on both SDA and SCL, and all boards (both side PCBs + the ball tracker) must share a common GND.
[PICTURE: wiring diagram / breadboard schematic showing all of the above]
The per-side board above is laid out in KiCad as
PCB/ubi_lab.kicad_sch +
PCB/ubi_lab.kicad_pcb — open both together in
KiCad 10. It's a two-layer, 1.6 mm board with a 76 × 68 mm outline,
carrying a socket footprint for a Pico-family board on the back plus three
connectors: J1 (8-pin, PN532, fed from the board's 3.3V rail), J2
(40-pin, EA DOGL128L-6), and J3 (4-pin, labeled I2C_SIMULATOR — VBUS/
GND/SDA/SCL on pins 1–4, for bench-testing against test_i2c_simulator
before the real ball tracker is wired in). R1/R2 are the 4.7kΩ I2C
pull-ups called out above.
A few things to confirm before sending a board to fab or assembling one:
ubi_lab:RaspberryPi_Pico_Socket_THT footprint is embedded
in the PCB, but its source library isn't in this repo — KiCad will need
it to re-sync the PCB from schematic edits.RaspberryPi_Pico_W, and the socket
footprint's own description also mentions Pico 2 W — double check the
exact variant, header orientation, and display-module/connector mating
against the physical parts on hand.1µF7 vs. the schematic's C prefix) — run
KiCad's ERC/DRC and reconcile annotations before fabrication.| Parameter | Value |
|---|---|
| SPI1 (PN532) speed | 1 MHz |
| I2C0 speed | 9600 baud |
| I2C slave address | 0x42 (shared by both side boards — see §3) |
| Display contrast | 0x13 |
Full pinout reference: docs/hardware_connections.md.
Built with the Pico SDK 2.2.0, targeting pico2_w, using lwIP in
polling mode (NO_SYS=1 — no RTOS, everything runs from one
while(true) loop with cyw43_arch_poll() keeping WiFi/MQTT alive).
The same firmware image runs on both side boards — which side/role a
board plays is a compile-time config block at the top of src/main.c:
#define MY_SIDE 'A' // 'A' on this board, 'B' on the other
#define PICO_ROLE_PRIMARY 1 // 1 on exactly ONE board
#define PICO_ID "pico-side-a" // must be unique per boardFlip these three, rebuild, and flash the other board.
| File | Responsibility |
|---|---|
src/main.c | WiFi connect (with on-screen boot status), MQTT init, main loop |
src/rfid_handler.c + lib/pn532/pn532.c | PN532 SPI driver + tap-debounce state machine |
src/i2c_comms.c | Ball-position ring buffer and the offline peer-tap link between the two boards (see below) |
src/game_logic.c | Local game state machine (GAME_WAITING → GAME_PLAYING → GAME_OVER), up to 2 players/side, goal detection, fastest-shot tracking |
src/display_manager.c + lib/ea_dogl128/ | Renders game state to the on-cabinet LCD |
src/pico_mqtt.c + include/pico_mqtt.h | lwIP raw MQTT client wrapper — connects (with a Last-Will-Testament), publishes heartbeat/RFID/state/ball, subscribes to player/sync/rfid/cmd |
lwipopts.h | lwIP buffer/pool sizing — tuned specifically to survive MQTT's keep-alive timers (see bug notes below) |
Both boards need to know about both sides' registered players, but cross-board MQTT sync only works when the Pi is reachable — and the PCBs are already assembled with no spare wiring for a dedicated link. Instead, the two boards share the same physical I2C bus the ball tracker uses:
0x42; both boards listen there as slaves (a
write-only-broadcast trick — see include/i2c_comms.h).i2c_slave_deinit() → write → i2c_slave_init(),
the Pico SDK's documented idiom for this) and writes a short 9-byte
message to that same shared address. The sibling board, still
listening normally, receives it — distinguished from ball-data packets
purely by a different sync header.MQTT's /rfid topic (subscribed by both boards) is a second, best-effort
channel carrying the same information when the Pi is present — the I2C
link is what makes registration work at all with no Pi/WiFi.
rfid_handler_scan() polls the PN532 over SPI; a debounce window
avoids re-firing on the same card sitting on the reader.game_lookup_player() checks a small hardcoded
table of known UIDs → names (demo roster: Alice, Bob, Carol, Dave)
purely so the local LCD can show a name immediately.tablefootball/table/<id>/rfid. The Pi is the identity authority —
it resolves the UID against its own SQLite players table and
echoes the resolved name + slot back over
tablefootball/pico/<id>/player.The ball tracker writes a 20-byte binary packet over I2C
(SYNC_A SYNC_B x y prev_x prev_y field_w field_h speed possession score_a score_b, see include/i2c_comms.h). i2c_comms_poll() drains
this from a ring buffer filled by an I2C-slave interrupt handler — the
same ring buffer also carries the peer-tap messages above, distinguished
by sync header. game_update() diffs the embedded score against its
last-seen baseline to detect goals (rather than trusting the raw score
directly), and the ball position is rescaled to a 0–1000×0–500 grid
before the primary board publishes it on
tablefootball/table/<id>/ball at roughly 12 Hz.
[PICTURE: serial console screenshot showing RFID tap + MQTT publish logs]
Published by each Pico:
| Topic | Rate | Payload |
|---|---|---|
tablefootball/pico/<id>/heartbeat | every 5s | online status, IP, firmware version, uptime |
tablefootball/table/<id>/rfid | on tap | UID, side, slot |
tablefootball/table/<id>/state | ~1/s, primary only | score, mode, fastest shot, winner (on GAME_OVER) |
tablefootball/table/<id>/ball | ~12 Hz, primary only | x, y, speed |
tablefootball/pico/<id>/status | LWT | online:false, set on disconnect |
Subscribed by each Pico (the Pi is source of truth for identity/state, but the board must never depend on it being reachable — see §"Offline board-to-board link" above):
| Topic | Purpose |
|---|---|
tablefootball/pico/<id>/player | Authoritative name for a resolved tap |
tablefootball/table/<id>/sync | Full roster + score/state snapshot (retained) — reconciles admin-driven registration changes, which produce no RFID tap at all |
tablefootball/table/<id>/rfid | The sibling board's own taps (same topic it publishes to) |
tablefootball/pico/<id>/cmd | Admin-panel commands: identify / reset_match / clear_players / show_message |
These came up while building this firmware and are good examples of how easy it is to silently break shared resources or drop a field across a protocol boundary:
rfid_handler.c
disables I2C0_IRQ for the duration of pn532_read_card() to keep
the I2C slave handler from interfering with SPI timing. But PN532's
internal "wait for ready" polling loop can run for up to ~250ms per
scan, and the IRQ stayed off that whole time — so every ball-position
byte arriving during a card scan was lost. Fix: the wait loop now
masks I2C0_IRQ only for the few microseconds of the actual SPI
status read, unmasked during each 1ms sleep in between.*** PANIC *** sys_timeout crash. lwIP's default
MEMP_NUM_SYS_TIMEOUT pool wasn't enough once MQTT's keep-alive timer
joined it. Fix: lwipopts.h explicitly sets it to 16.tablefootball/pico/<id>/cmd from the start, but the
firmware never subscribed to that topic at all — every "Identify" /
"Reset Match" / "Message" button silently no-op'd. Fixed by actually
subscribing and dispatching (see on_pi_cmd() in main.c).mqtt_app_init() is never called, so
the internal MQTT client stays NULL — but every heartbeat/RFID
publish still tried to reconnect through it, crashing on first use.
Fixed with a guard so every publish path is a safe no-op with no
client. This is exactly the "must work fully offline" requirement,
caught by testing the actual no-Pi scenario rather than just a
dropped-connection one.# Requires the Pico SDK (2.2.0) + arm toolchain + CMake + Ninja.
mkdir build && cd build
cmake -G Ninja ..
ninja table-footballFlip MY_SIDE/PICO_ROLE_PRIMARY/PICO_ID at the top of src/main.c
(see above), rebuild, and repeat for the other side's board.
Hold BOOTSEL, plug the Pico in (it mounts as a USB drive), then drag
build/table-football.uf2 onto it.
There are also standalone test targets for bringing up hardware in
isolation without the full stack — useful when debugging a single
peripheral (see tests/):
| Target | Tests |
|---|---|
test_i2c_simulator | Fakes ball movement over I2C — a second Pico can stand in for the real ball tracker |
test_pn532 | Raw PN532 SPI bring-up (firmware version + card polling), independent of the rest of the stack |
test_pn532_lib | Same, using the actual lib/pn532/pn532.c driver the main firmware uses |
test_i2c_scan | Protocol-independent I2C bus scanner (bypasses custom SPI/I2C code entirely — useful for "is this chip even alive" questions) |
Everything in server/ — see server/README.md
for the full setup walkthrough, troubleshooting table, and MQTT
cheat-sheet. Summary:
TableFootball), so the whole system works with zero internet/router
dependency.server/app.py) — HTTP routes, admin auth, and an
/events SSE endpoint that streams table_state, ball_position,
player_update, and pico_status events to every open browser.mqtt_client.py — subscribes to tablefootball/#, owns the
authoritative game state machine per table:
WAITING → PLAYERS_REGISTERING → GAME_PLAYING → GAME_OVER / ABANDONED,
and writes everything through to SQLite.players, live_tables, live_players,
matches, match_players, pico_devices, tournaments /
tournament_entries / tournament_matches.GAME_PLAYING with no /state update for 45s, so a board that
crashed mid-match doesn't leave a permanently "live" game behind.server/static/script.js, templates/index.html)http://tb.local./player/<uid>) — match history and a fastest-shot-over-time
chart.[PICTURE: screenshot of the dashboard mid-match, ideally caught mid-goal-animation]
/player/<uid> — games/wins/losses, best shot, full match history,
and (browser permitting) a fastest-shot-over-time chart./admin — rename guest players into registered ones, watch Pico
online/offline status, per-Pico commands (identify/reset/clear/message —
see §3), and a tournament manager: create a bracket, add entries,
auto-generate a single-elimination tree (byes go to the top seeds,
never bye-vs-bye), assign a pending match to a live table, and watch
it auto-advance as matches finish. Basic auth via .env's
ADMIN_PASSWORD.[PICTURE: screenshot of a player profile page, the admin panel, and a tournament bracket]
cd server
python tests/simulate_game.py # full match: heartbeat → register → goals → GAME_OVER
python tests/simulate_rfid.py DBEF7005 Async.[PICTURE: optional roadmap graphic]
table-football/
├── src/ Pico firmware: main.c, rfid_handler.c, i2c_comms.c,
│ game_logic.c, display_manager.c, pico_mqtt.c
├── include/ Public headers for the above
├── lib/
│ ├── pn532/ PN532 SPI driver
│ └── ea_dogl128/ EA DOGL128 display driver
├── tests/ Standalone Pico test harnesses (see §3 table)
├── PCB/ KiCad schematic + PCB for the per-side controller board (see §2)
├── docs/
│ ├── hardware_connections.md Full pinout + capacitor wiring reference
│ └── hardware_setup.md
├── lwipopts.h lwIP buffer/pool sizing (tuned for MQTT keep-alive)
├── CMakeLists.txt Builds table-football + all standalone test targets
└── server/ Flask + MQTT + SQLite server and dashboard
├── app.py, mqtt_client.py, database.py, state.py, config.py
├── templates/, static/ Dashboard, player profile, admin UI
├── tests/ MQTT simulators (run the server without real Picos)
├── scripts/ setup_hotspot.sh, backup_db.sh
└── systemd/ football.service for boot-time autostartThe 3D-printable enclosure design (enclosure.scad + exported STLs)
lives in a sibling hardware/enclosure/ directory outside this repo,
not version-controlled here.
server/README.md for the full Raspberry Pi setup).| Qty | Value | Footprint | References |
|---|---|---|---|
| 8 | 1µF | Capacitor_SMD:C_0805_2012Metric | 1µF1, 1µF2, 1µF3, 1µF4, 1µF5, 1µF6, 1µF7, 1µF8 |
| 2 | 4.7k | Resistor_SMD:R_0805_2012Metric | R1, R2 |
| 1 | 4.7µF | Capacitor_SMD:C_0805_2012Metric | 4.7µF1 |
| 1 | EA_DOGL128L_6 | ubi_lab:EA_DOGL128-6 | J2 |
| 1 | I2C_SIMULATOR | Connector_JST:JST_XH_S4B-XH-A_1x04_P2.50mm_Horizontal | J3 |
| 1 | PN532 | Connector_PinSocket_2.54mm:PinSocket_1x08_P2.54mm_Vertical | J1 |
| 1 | RaspberryPi_Pico_W | ubi_lab:RaspberryPi_Pico_Socket_THT | U1 |

google/mozc-devices
Circuit diagrams and firmware source code for Gboard DIY keyboards

hoglet67/RGBtoHDMI
Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI

mntmn/amiga2000-gfxcard
MNT VA2000, an Open Source Amiga 2/3/4000 Graphics Card (Zorro II/III), written in Verilog

hackclub/OnBoard
💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

kenp-io/not-for-airpods-repairs
The content of this repository is licensed under the WTFPL License. Please have a close look at the terms before using this material.

Luos-io/luos_engine
Open-source and real-time orchestrator for cyber-physical-systems, to easily design, test and deploy embedded applications and digital twins.

Chrismettal/EleLab_v2
Cheap DIY lab system for hobbyists and the tinkering folk

It measures 76 × 68 mm and has 2 copper layers, 1.6 mm thick.
15 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the navidjavid/table-football-feedback repository on GitHub, at the commit this page was made from: the board is PCB/ubi_lab.kicad_pcb and its schematic PCB/ubi_lab.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask navidjavid before reusing the design.