Wednesday 7 January 2015

Controlling things with the Myo Bluetooth gesture controller

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
 I decided it would be interesting to try to use my Myo to control LED lights on a circuit board via my Arduino. The first question I had to answer was what the architecture of my solution would be.

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.

Controlling things with the Myo Bluetooth gesture controller from Martin Woolley on Vimeo.


  1. Hi,
    I am wondering what BLE Shield you are using.
    I am trying to get servo control from a MYO to Arduino (w/BLE Shield) connection without an Android or laptop in between.

    Thalmic Labs have released their MYO Bluetooth Protocol since you uploaded this. Have you taken a look at it yet?

    Thanks in advance!

  2. Hi, I'm using a Redbearlab BLE shield in this particular set up. Yes, I started looking at Myo direct control but have not had much success yet. You need a shield or board which supports GAP Central mode which limits your choice as most appear to only support GAP Peripheral mode. So far I've tried using an Intel Edison with Node.js and the Bleno module. I can connect to Myo and make it vibrate but so far it refuses to send "classifier events" (AKA gesture data). When I get the time I may try using a Bluegiga DKBLE instead as this supports central mode as well. Interested to hear how you get on.



  3. Please let us know if you've had any success with direct Myo to arduino control. Have you had any progress?

  4. I've had no time to do any more on this unfortunately. Meanwhile Thalmic Labs have published details of their GATT profile so it should now be possible to do this:

  5. Hi
    Could you pls tell me more about the app u have created for this purpose.?

  6. What do you want to know? I haven't looked at it in nearly a year but it does what's described in the article, using the Myo API for communication with the Myo and standard Android Bluetooth Low Energy APIs to control the Arduino.


Note: only a member of this blog may post a comment.