Home Creators Posts Import Register Favorites Logout

Content

Earlier this month I described how I'd got a Bluetooth-enabled "smart" Rubik's Cube for Christmas that came with a companion Android app. I wasn't entirely happy with the app - for one, it required creating an online account with Xiaomi, and also it frequently crashed. So I said I was going to experiment with intercepting the data from the cube some other way...

...I'm pleased to say that my experiments were successful, and I've just published my code that runs on an ESP32 and instantly and automatically receives Bluetooth notications every time the cube is twisted, can identify the current state of the puzzle, and the last move made. I've demonstrated this in the video by releasing a maglock when the cube is fully solved (well, I *do* like escape rooms!).

Note that I've used an ESP32 in this case because the cube requires BLE (i.e. Bluetooth 4.0) which the ESP32 has built-in support for, whereas the Arduino HC-05 Bluetooth modules I've used in the past only support Bluetooth "Classic" (BT 2.0). ESP-32s are also faster, have more memory than an Arduino, and have built-in Wi-Fi, so they're definitely worth considering if you want a processor for your next project. The two downsides they have is that not every Arduino library supports ESP32, and they run at 3.3V logic rather than 5V, which means not every sensor will work with them (but, on the plus side, 3.3V sensors will work without logic-level conversion!).

Anyway, you can buy the cube I'm using from BangGood for about $16, here: https://www.banggood.com/custlink/D3DvQbsa4f 

And you can download the code from my GitHub: https://github.com/playfultechnology/esp32-smartcube 

Please ask if any questions!

Files

How to Hack a "Smart" Bluetooth Rubik's Cube using an ESP32

In this video tutorial, I'll explain how you can "hack" a smart bluetooth-enabled Rubik's Cube (as advertised by Giiker, Xiaomi, etc.), using the BLE capabilities of an ESP32 to intercept and decrypt the data packets that are sent every time a side is twisted. The data packet describes the complete state of the puzzle, together with the last two moves made. You could use this code to turn the Rubik's Cube into an input device for a home automation system - to control your smart speakers or lighting, or any other IoT connected device. I'll demonstrate how you could also use this as the basis for an escape room puzzle - by comparing the state of the puzzle to a known solution state and, if matched, energising a relay to release a maglock, sending a spectacular display of balloons into the sky to celebrate the solver's achievement... You can buy a cube for about £12 from https://www.banggood.com/custlink/D3DvQbsa4f Full Arduino code is available on my GitHub: https://github.com/playfultechnology/esp32-smartcube Further resources about this and all my other escape room tech puzzles can be found on my Patreon: https://www.patreon.com/playfultech

Comments

Minter Arnaud

I'm having trouble understanding everything in your code. I'd like to trigger something not based on solving the cube (it's too complicated in an escape room to require a complete resolution), but rather based on the colors. Would it be possible to trigger something based on rotating the blue side 3 times, the yellow side 2 times, and the red side 4 times, for example?

mark dennis (edited)

Comment edits

2026-09-07 18:00 Is it possible to use an ESP-01?
2020-01-24 01:07

Jake

This is an amazing puzzle, thanks Alastair! I would be very interested in applying the same basic code to the GoDice on indiegogo right now. Just a suggestion for further tutorials.