Wireless "Smart" Dice - Escape Room Portable Puzzle (Patreon)
Content
Hello, and Happy 2021 to you all!
This project was inspired by an advert that popped up in my Facebook feed for a product called "Smart Dice" - a set of dice that wirelessly connected to a mobile phone app, which reported the value of what you rolled. I don't actually know the exact details of how they worked, but I decided to recreate the functionality they were described as having, using the linear accelerometer sensor in an MPU6050 chip (on a GY-521 module), and a Wemos D1 Mini.
Having used the accelerometer to work out which face of the dice is pointing upwards, I then broadcast that information as an MQTT message sent over Wi-Fi to a Node-RED server, which updates a display to show the value rolled. I'm sure you can think of lots of possible uses for this!
I've also used this video to talk about a couple of topics that I haven't really mentioned much in previous projects: firstly, how to provide battery power to portable props. And, secondly, how you can write "Arduino" code (or ESP8266/ESP32) to write and read values to any I2C sensor, without using any third-party library. This is useful information to know should you ever find yourself wanting to use an I²C component in a project and these is not an existing library available!
Even though I'm using a Wemos D1 Mini, which is based on an ESP8266 chip, I've tried to structure the wiring and the code so that it will be portable to work on ESP32 or Arduino UNO/Nano (although the Arduinos don't have Wi-Fi built-in, so you'll either have to add a Wi-Fi shield, or replace that bit of code with something that creates an entirely self-contained response - i.e. popping open a side of the cube once it has been rotated in the correct sequence of turns)
Components
GY-521 board (MPU-6050 chip), https://www.banggood.com/custlink/v33hSP1shT
Wemos D1 Mini (ESP8266 chip), https://www.banggood.com/custlink/v33RJLItSj
D1 Mini Battery Shield, https://www.banggood.com/custlink/mvGhSFfsh2
Total cost = ~$7
Timings
00:00:00-00:03:23 Introduction and Demonstration
00:03:23-00:07:17 Hardware Overview
00:07:18-00:19:02 Wiring and power requirements
00:19:03-01:00:07 Arduino/ESP8266/ESP32 Code
01:00:08-01:15:36 Node-RED flow
01:15:37-01:17:27 Wrapup
I'll put up another post shortly with all the downloads for folks to access but, in the meanwhile, please ask if you have any questions or comments!