|Controlling my Arduino with the Myo gesture controller|
Last year I got myself a Myo gesture controller from Thalmic Labs and have enjoyed following the product's progress from beta. The firmware works well now and gestures are reliably recognised. I fully expect that Myo will be my standard means of controlling Powerpoint presentations this year.
I was thinking about IoT and the role something like Myo might play. The question was, whilst Myo is easy to use with PC applications, either using the canned capabilities it comes with or by writing your own scripts, could I use it to interact with miscellaneous inanimate objects like lights?
I did some investigation using some Bluetooth tools and discovered that Myo uses a custom Bluetooth Smart profile with a number of custom services.
|Myo's GATT services|
In terms of GAP roles, it's a GAP Peripheral and advertises. GATT Notifications are used to communicate movement and gesture data to a connected device.
|Myo protocol trace showing notifications|
Thalmic Labs have not yet published details of their custom profile so writing GATT client applications which connect directly with Myo, which acts as a GATT server, is difficult unless you use one of their APIs, such as the one for Android smart phones or you write scripts for your PC which work with their Myo Connect service. I didn't really want to have an intermediate device in between the Myo and my Arduino but realistically, without spending time I don't have, trying to reverse engineer their notifications from protocol traces, I had no choice. So I decided to write an Android application using the Myo official API that the Myo device would connect to and communicate with and create a custom GATT profile of my own for the Arduino and which I could use to control some LEDs and an LCD serial display.
|My solution architecture|
So how does this work exactly? The Android app is connected to both the Myo and to my Arduino/BLE shield. The app receives gesture data via the Myo API, formed from GATT notifications which the Myo is transmitting. The Android app takes the gesture data and uses it to send "commands" to the Arduino, which I've equipped with a custom profile I called the Simple Controller profile. It has a custom service, the Simple Controller service, which has a single characteristic to which I can write a value, representing a command of some sort. In the service implementation in my Arduino sketch, I respond to the characteristic write events by switching on an LED according to the gesture the characteristic value represents and I write the name of the gesture to the LCD display. Simples!
|The Simple Controller profile implemented in the Arduino|
Whilst this isn't my first choice architecture I have to say, it does in fact work fine. I'm hoping Thalmic Labs will provide details of their custom profile at some point in the future though so I can take a second look at this use case and see if I can eliminate the Android proxy component. Not a bad start though!
Here's a video of the solution in action. Enjoy it right here or if you prefer, over in Vimeo.