By Kevin McAleer, 9 Minutes
Page last updated November 24, 2026

By the end of this lesson you will be able to explain how the chess camera App splits its work between the two brains, and reuse its key idea in your own project.
Kev wanted to play chess against a computer without staring at a screen. So he pointed a webcam at a real board, plugged it into an Uno Q, and built an App that watches the game, works out each move you make, and plays back.
This lesson is a guided tour of that finished App. It uses nearly everything in the course, and it has one clever idea you can steal for your own projects. Watch the video first.
The App’s code is in Kev’s repository, and he wrote the build up in Playing chess on a real board with the Arduino UNO Q. This lesson does not reprint the code.
You move a piece and take your hand away. The App reads the move. It tracks the whole game: check, checkmate, castling, en passant and promotion. Stockfish, a chess engine, picks a reply, and you choose how strong it plays from skill 0 to skill 20.
The reply appears on the web page, as an arrow on the camera view, and on the Uno Q’s LED matrix, with the from-square dim and the to-square bright. You move the computer’s piece for it, and the App checks that you moved the right one. It can speak through a Bluetooth speaker or your browser, and a Coach me option comments on your moves.
It is an App Lab App, so it has the folders you know: app.yaml, python/, assets/ and sketch/.
flowchart LR
Cam["USB webcam"] --> Linux["Linux: OpenCV, python-chess, Stockfish, web page"]
Phone["Phone or computer"] <--> Linux
Linux -->|"Bridge"| MCU["Microcontroller"]
MCU --> Matrix["LED matrix"]
Linux does the heavy work. It runs OpenCV on the camera frames, python-chess for the rules, Stockfish for the thinking, and the web page on port 7000, as in lesson 11. The microcontroller has one job: driving the LED matrix.
| Course lesson | Part of the chess App |
|---|---|
| Lesson 4, the LED matrix | Shows the computer’s move on the board itself |
| Lessons 7 and 8, the Bridge | Python tells the sketch what to draw |
| Lesson 10, containers and requirements | Stockfish is downloaded by the App, as an App cannot use apt install |
| Lesson 11, the web page on port 7000 | The control page |
| Lesson 12, the camera | The webcam frames |
| Lesson 13, run at startup | A chess board that is ready when you switch it on |
You might expect the App to look at the board and work out which piece is on which square. It does not. It never needs to know what kind of piece is on a square. It reads a move in four steps.
This works because a typical position has only about 30 legal moves, and only one of them changes the right squares. Castling changes four squares and en passant changes three, and the App handles them the same way.
Try it. This board is in the opening position, where there are exactly 20 legal moves.
This demo needs JavaScript. In short: after a move, two squares have changed a lot. Of the 20 legal moves in the opening position, only one uses those two squares, so that is the move.
Make a move and read the scores. Watch the squares that “changed” in the camera’s eyes, then watch the 20 legal moves get scored until one is left. Then switch on camera noise and see that the right move still wins.
The trick is to use what you already know. The App knows the rules, so the vision problem shrinks from “what is on every square?” to “which of about 30 moves matches these changes?”. Before you reach for a bigger model, ask yourself: what do I already know that narrows this down?
A real table is messier than a demo. Kev added three checks for that.
Kev found that tall pieces are a problem. Unless the camera is directly overhead, a tall king leans into the squares next to it in the image. So he designed low, wide printable pieces and flat coins. He also found that colours matter: pick ones that stand out from both the light and the dark squares. In Kev’s build, cream pieces with red symbols and black pieces with yellow symbols worked well. Plain white pieces on light squares were the hardest for the camera to see.
These are the steps from Kev’s post, in order.
git clone https://github.com/kevinmcaleer/uno_q_chess ~/ArduinoApps/chess-camera
data/ folder.http://<board>:7000 on your phone or computer.You only need to calibrate again if the camera moves.
The repository also has offline tests, including 604 simulated moves from angled, noisy, fake camera images. That means you can try the detector on a laptop before buying any hardware.
Problem: A tall piece seems to be read on the wrong square. Solution: Move the camera directly overhead, or use low, wide pieces or flat coins. Why: Seen from an angle, a tall piece leans into the squares next to it in the image.
Problem: White pieces on light squares are hard for the camera to see. Solution: Choose piece colours that stand out from both the light and the dark squares. Why: The App reads moves from how much each square changes. A piece that looks like the square under it changes very little.
Problem: The grid no longer sits on the squares. Solution: Calibrate again and save the new calibration. Why: The calibration is tied to where the camera is. If the camera moves, the grid does not move with it.
Problem: The first game does not start.
Solution: Make sure the board is online.
Why: The first game downloads Stockfish, about 30 MB, into the App’s data/ folder.
Quick quiz 1 of 3
How does the chess camera read a move?
Quick quiz 2 of 3
Why does the App wait until the board is still before reading?
Quick quiz 3 of 3
Why does the App download Stockfish itself instead of using apt install?
apt are not available inside an App, so the App fetches what it needs itself.
Comments