I love chess.
I recently got a DGT Centaur digital chess board. I loved it for most part, except I cannot analyze the game in real time or export my games and analyze them later in my computer. I went on to explore if that is even a possibility, and so, after some head scratching, here we are. As an added bonus, I also got to update the stockfish engine from the factory version (stockfish 8) to newer stockfish 11, which is supposed to be providing better game positions and suggestions.
Here is the video showing it in action.
Let’s Dig in
The back of the board has a simple, black rectangular cover which is secured by ~5 screws. Once you open them, you can see the raspberry pi zero and the lithium battery.
Zero to Hero (Zero-w)
Raspberry pi zero does not support wireless functions (wifi or bluetooth). So first thing is to upgrade to raspberry pi zero-w, which has wifi support.
You can simply lift open the circuit board with the raspberry pi, and you can see it is attached by a 20 pin, right angle male pin header. We need to get our raspberry pi zero-w ready with similar setup. Here is my raspberry pi zero-w after soldering the pins. Install Raspbian OS on new SD card (I used 32 GB card). We will not need the original card that came with the board. Save it as backup, in case we screw up and have to restore the board to factory defaults.
Then we need to copy the “centaur” folder and its content from the old raspberry pi to our new pi, to the root of the home folder. Since it might be a copyright issue, I am not providing the copy of that folder here, but if you are savvy enough, you should be able to find ways online to copy files from any linux SD card directly.
The Hack
So here is the actual “hacking” part. The way this works is that centaur is using the stockfish engine to analyze the moves and provide suggestions. I modified the stockfish engine to log the FEN position that the centaur is currently analyzing, which turned out to be the move that corresponds to current position. The go.log file contains the current FEN position.
I replaced the modified stock fish engine under the “centaur/engines” path. As you can see the “stockfish_pi” file is now version 11, while the back up “stockfish_pi_b” is the older version 8 from DGT.
One last thing is to make sure we set the “centaur” file under the “centaur” folder to run every time on reboot of pi. I used the cron job to set that up.
Once everything is taken care, time to replace the raspberry pi zero with new pi zero-w. You can just pull out the pi, which should expose the header female pins on the circuit board and plug in the new pi. Close the cover and reboot the board.
If everything is done right, the DGT board should reboot fine and come back with the menu options as normal.
Now we can connect to our board remotely using wifi (ssh) from any PC.
I have written a python program to read the “go.log” file and display the current FEN position in browser. I am also saving the last 100 games as PGN to analyze later.
If you are following so far, thank you for your time. Enjoy!
“இன்னாசெய் தாரை ஒறுத்தல் அவர்நாண
நன்னயஞ் செய்து விடல்”
“If you really want to punish a person who has harmed you, then make him embarrassed
by doing a kind deed towards him.”
– Thiruvalluvar