MyoBridge - Direct Myo <-> Ardiuno Communication


by valentinrol

MyoBridge - Direct Myo <-> Ardiuno Communication

Hello,

As many others, I wondered if I can use a Myo for an Arduino project. Unfortunately, all BLE shields out there where either incompatible or did not provide the necessary firmware functions. Because we want to use the Myo in a research project for devolping helpful devices for disabled people, I started to write a custom firmware for this, together with a high-level, easy to use library for Arduino, called MyoBridge.
The concept is simple: Flash a Bluetooth module with custom firmware, connect it to the arduino with a simple two-wire serial connection and pack all complicated protocoll stuff in one library for arduino. The Bluetooth module used is the HM-11 Bluetooth Low Energy module. It uses the CC2541 BLE SoC by Texas Instruments, so this project is probably adaptable for other BLE devices with similar hardware.

Currently the library provides support for:
  • Reading Firmware Info
  • Reading IMU Data
  • Reading EMG Data
  • Receiving Classifier Updates
  • Receiving IMU Motion Event Updates
  • Enable/Disable all Messages
  • Enable/Disable Sleeping
  • Lock/Unlock
  • Vibration
  • Reset if necessary
  • And some more, which are not yet that simple to use.
I would really appreciate feedback of any kind. If you have any Questions, feel free to ask. The Project with documentation and source code is available on GitHub:



https://github.com/vroland/MyoBridge

For any more info on how to set this up, visit the wiki: https://github.com/vroland/MyoBridge/wiki

To test this, you will at least need a HM-11 or HM-10 module with a CC2541 (probably easily compilable for CC2540, too) and a CC Debugger to flash the firmware. Maybe you can use an Arduino instead of the CC Debugger, I have heard about something like that, but I have not tested yet.

Hope this is helpful and we can help each other.

regards,

valentinrol

EDIT: Feature list updated. Software serial communication is now more reliable thanks to changed protocol.

Last edit: Dec. 2, 2015 01:45 AM

by @smngreenberg TL

MyoBridge - Direct Myo <-> Ardiuno Communication

Very cool! I'm looking forward to hearing more about this as it progresses.

Sidebar - I've also added it to the list of tools and bindings thread.

Cheers,
Scott
by valentinrol

MyoBridge - Direct Myo <-> Ardiuno Communication

Thank you! Should I make a separate post in the tools and bindings list?

Also: There are some updates!

  • An optional callback function can be provided with the begin() call, allowing to get feedback about the connection process
  • Also optionally, a reset pin can be specified to enable the library to reset the Bluetooth module if it does not respond immediately during startup.
  • more documentation!

The libary usage and the new features are explained here: MyoBridge Wiki
by @smngreenberg TL

MyoBridge - Direct Myo <-> Ardiuno Communication

No need for the separate post, it can live in the list and point back here so people can get more information. Great updates too, I'm loving the documentation.

Cheers,
Scott
by eric_castro

MyoBridge - Direct Myo <-> Ardiuno Communication

Hey, I am very much interested into this library.

I have a electric unicycle I use everyday to commute, but it has no lights and as the winter approaches, Paris is becoming darker everyday when I get out of the office, so I was planning on building a neopixel led system I could attach to my unicycle and be able to show direction lights remotely triggered with my Myo wristband. I could use a custom iPhone app as the bridge between both but seemed overkill, so this library is perfect.

I have a few spare HM-10s so I'd love to test it, but I don't have the CC debugger.

Do you have any more information on how I can flash it using an arduino?

I also have a couple DFRobot BLE bees based on the CC2450, you mention it needs to be recompiled. These are in XBee format so it might be easier to flash ?

Last edit: Oct. 5, 2015 03:58 PM

by valentinrol

MyoBridge - Direct Myo <-> Ardiuno Communication

Sounds like an interesting project, It would be nice to see the results when you're done!
For flashing the Firmware, this project https://github.com/wavesoft/CCLib looks promising, although I have not tested it yet. I hope this helps!
Regarding the CC2540: I'm not really sure what the actual digferences are, but it would at least be safer to recompile. The Problem is, that I could compile for the CC2540, but II dont have a CC2540 device to test it…
For the XBee boards, you probably have to look up the corresponding Pins for Debug Data/Clock.

Please keep me up to date with your progress, knowing a way around the CC Debugger would be very useful.

EDIT: I tried to build for the CC2540F256 by just changing the target device, I hope this is enough. You can try this hex file if you want, but this is untested. So as always: Use a your own risk!
http://www.vroland.de/owncloud/index.php/s/HfZ2exsiReaxr6c

Last edit: Oct. 6, 2015 06:55 PM

by valentinrol

MyoBridge - Direct Myo <-> Ardiuno Communication

Hello,

Just to show you what I use this library for and what an Arduino is capable of: This is the MyoIMUGestureController Arduino library (https://github.com/vroland/MyoIMUGestureController) Because my project is about helping people with hand disabilities, we can't use the built-in gesture detection or hand gestures. Instead, the IMU sensor is used to detect Gestures like Straight Left, Right, Circular Movement, or Arm Rotation. The library can detect 8 gestures in total, using the EMG data just for locking/ unlocking.
Information about how to use it, how it works and what you need is all in the GitHub readme.

Feel free to use it for your own projects
by eric_castro

MyoBridge - Direct Myo <-> Ardiuno Communication

ok sorry for the long silence (I only had time today to try this out)

even if I'm proud and consider I made good progress just by soldering some wires to the debug pins on my already soldered HM-10, I wasn't able to flash it with CCLib because it only supports the CC2540 and not the CC2541 which is what my HM-10 has (or whatever HM it is, I can't remeber).

I get a connection from the CCLib but finally fails with the response:
Using CCDebugger on port /dev/tty.usbmodem1421
ERROR: This class works ONLY with CC2540 TI chips (This is a 0x4113)!


and then I also seen that the XBee breakout in my BLE module with a CC2540 does not expose the debug pins (since the Xbee pinout was not made for BLE in the first place), therefore I cannot flash it either.

I will either get an HM-11 and try CCLib again or continue investigating to see if there's a way to make it work with the CC2541 (opened an issue on github to see if the developer has a clue)

Last edit: Oct. 29, 2015 08:51 PM

by eric_castro

MyoBridge - Direct Myo <-> Ardiuno Communication

IT WORKS!!!!

I was able to flash a CC2541 on a HM-10 with the HEX you compiled for me.

I wasn't able to get CCLib to work, but found this project instead by RedBearLabs: CCLoader which basically does the same but runs on a windows executable instead of a python script (and it takes only bin files so I had to get it from the hex you sent with avr-objcopy that comes bundled with Arduino)

I actually thought I had bricked my CC2541 because I could no longer interact with it as a peripheral, then I realised that the BLE peripheral functionality was probably disabled, so I just went ahead and tried the MyBridge examples and they worked perfectly !

this is absolutely amazing!
impressive work @valentinrol! can't wait to build my gesture based controller for my monocycle lights!

here's a pic of the gesture example running flawlessly:

Last edit: Nov. 1, 2015 06:32 PM

by jdddog

MyoBridge - Direct Myo <-> Ardiuno Communication

I got it working too! (With the CCDebugger) Thanks so much for the library valentinrol!

Just one question, how do you find out if the connection between the Myo and the Arduino has timed out? So that you know to call ‘begin’ again.

Oh my bad, didn't see your comment above:

An optional callback function can be provided with the begin() call, allowing to get feedback about the connection process

Last edit: Nov. 4, 2015 09:17 PM

Moderator control