Using Machine-Learning to Train an ESP32 Morse Code Decoder (Patreon)
Content
Hi folks!
It seems that, what with Midjourney, Dall-E and, most recently, ChatGPT, everyone is getting very excited about A.I. at the moment. So, I thought I'd jump on the boat....
But, rather than looking at the high-end distributed supercomputer-powered awesomeness of those content generation engines, I've been focussed on something a little closer to home - whether A.I. can be used to interpret player inputs in an escape room puzzle controller. So, I picked an example of a classic Morse code puzzle, where players need to tap out the sequence of dots and dashes to convey a particular message. Rather than hard-code any rules about the precise length of pauses or durations of those elements, I decided to use machine-learning to train a model that would learn the Morse code alphabet by itself.
Sure - there are example Arduino Morse code decoders already available on the internet but all those I found were very rigid. They needed to be explicitly told the pattern of dots and dashes for every letter, and only worked when supplied with very clean input that adhered to a near-perfect Morse code standard, or required some degree of manual tuning to distinguish between the length of dots and dashes. But, by using machine learning to train an A.I. based on real-world player input instead, my hope is to have a decoder that is not restricted by such arbitrary, rigid interpretation or "correct" input. It classifies data based on rules that have been created based on actual input, on actual hardware, of actual players, and therefore is less likely to incur player frustration. And, even though I've only conducted limited tests so far, I'm really encouraged by how it's performed so far - and it can be run on a single ESP32!
I've made the code available in my GitHub repository, which you can find here: https://github.com/playfultechnology/esp32-morse-decoder
It makes use of two Python libraries:
SciKit-Learn (https://scikit-learn.org), which trains the machine learning model
MicroMLGen (https://pypi.org/project/micromlgen/), which converts the output from SciKit-Learn into a C header file that can be imported into a regular Arduino/ESP32 sketch
I'm really excited that there are loads of possible uses for this beyond this fairly trivial example - if you have any questions or comments of how you'd like to see this tested, please let me know - and do try it yourself!
And, as it's now mid-December, may I take this opportunity to wish you a very Happy Christmas, and may it be peaceful and full of joy, wherever you may be in the world.
x