Using a Rubik's Cube as an Input Controller for ESP32 (Patreon)
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!