nullp0tr

Connecting an Arduino to a Myo armband using HM-10/HM-11

This tutorial covers connecting the Myo Armband to an Arduino, with the help of an HM-10 or HM-11 BLE module and the MyoBridge firmware developed by vroland.

[0]: Requirements.

  • Arduino

  • MyoBridge Firmware

  • CCLoader program and arduino sketch

  • HM-10 / HM-11

BLE Modules equipped with the TI CC2541 chip, which we’ll use with our arudino, to communicate with the Myo armband.

HM-10

HM-11

MyoBridge

A high-level Arduino library and custom firmware for the HM-11 (CC2541 SoC) to enable direct Myo Armband and Arduino communication. -vroland.

CCLoader

A free alternative to the TI CCDebugger that uses an arduino to flash mini BLE chips like the CC2541.

[1]: Getting the HM-10 & HM-11 ready.

The HM-10 comes equipped with 4 pins for VCC, GND, TX and RX, and while that’s enough to operate it, we still need to solder three wires to have access to the DEBUG_CLOCK(YELLOW), DEBUG_DATA(BLUE), and RESET(RED) pins.

We designed a little board (pictured below) to flash and test the HM-11.

Even though we’ve access to all the pins, you actually only need 7 of them to flash and operate the module.

The red pins are only needed for flashing, and the blue pins are needed for operation, so you’ll have to design/solder accordingly.

[2]: Flashing the Modules.

To flash the modules with the MyoBridge firmware we’re going to use the CCLoader program developed by RedBearLabs.

To download the MyoBridge firmware open a terminal and paste the following:

$ git clone [https://github.com/RaquenaTeam/MyoBridge](https://github.com/RaquenaTeam/MyoBridge)

Now that we have the firmware we need to download and compile CCLoader for Linux, so go back to the terminal and paste the following command:

$ git clone https://github.com/RedBearLab/CCLoader && cd CCLoader/SourceCode/Linux && gcc main.c -o ccloader

So far so good, now fire up your Arduino IDE, or the IDE of your choice, open the CCLoader sketch from CCLoader/Arduino/CCloader and flash your Arduino with it.

Now that our Arduino is running CCLoader, it is time to connect it with one of our modules. The pinout needs to match the table below.

(BLE) -> DEBUG_CLOCK (YELLOW) (Arduino) -> PIN 5

(BLE) -> DEBUG_DATA (BLUE) (Arduino) -> PIN 6

(BLE) -> RESET (RED) (Arduino) -> PIN 4

(BLE) -> VCC (Arduino) -> VCC

(BLE) -> GND (Arduino) -> GND

The colors used here represent the wires we soldered to the HM-10 board we’re using for the tutorial. You can obviously use any colors you want, we stick to color standards only with finished projects or finished prototypes, since using the proper colors even for testing always leads to a drought in the most used colors like red, and an abundance of not so often used colors.

Alrighty, now that we’re done with that, it’s time to connect our Arduino back to the computer and flash the firmware, next steps are the same for both the HM-10 and the HM-11.

Fire up your terminal again and cd into the folder where you downloaded CCLoader. $ cd CCLoader/SourceCode/Linux

CCLoader has the following parameters: $ ./ccloader <COM_NUMBER> <BINARY_FILE.BIN> <DEVICE_NUMBER>

The COM_NUMBER is the number of the serial port of the arduino on your computer. You can find it in the bottom-right corner of the Arduino IDE:

In my case the COM_NUMBER is /dev/ttyACM1.

The BINARY_FILE.BIN is the path to the firmware binary, you’ll find it under: MyoBridge/myobridge_firmware/Bin/MyoBridge_CC2541.bin MyoBridge is the folder we downloaded earlier.

As for the last parameter, DEVICE_NUMBER, you can either choose 0 or 1, 0 for Arduino Uno, 1 for Arduino Leonardo (or any Arduino other than Uno).

Now that we’ve got all parameters, we can run the following command in the terminal to start flashing: $ ./ccloader /dev/ttyACM1 /home/someuser/somefolder/MyoBridge/myobridge_firmware/Bin/MyoBridge_CC2541.bin 0

You obviously need to change the above path for the firmware to match the path on your computer.

If everything went good you should see the following:

However your terminal might have got stuck at this step:

In which case, you should press CTRL-C to stop the program, run again but this time with 1 instead of 0 as the DEVICE_NUMBER, so:

$ ./ccloader /dev/ttyACM1 /home/$USERNAME/somefolder/MyoBridge/myobridge_firmware/Bin/MyoBridge_CC2541.bin 1

CTRL-C again, and then run again with 0 as the DEVICE_NUMBER, so:

$ ./ccloader /dev/ttyACM1 /home/$USERNAME/somefolder/MyoBridge/myobridge_firmware/Bin/MyoBridge_CC2541.bin 0

If you’re using an Arduino other than the UNO, then do the same just with the numbers reversed.

Now that we’re hopefully done with flashing, we just need to quickly test if everything worked out.

[3]: Using a MyoBridge example sktech for testing

The MyoBridge folder you downloaded earlier comes with a couple of example sketches, you’ll find them under MyoBridge/Arduino/libraries/MyoBridge/examples/, but before you run any sketches you have to either put MyoBridge/Arduino/libraries/MyoBridge/src in your Arduino libraries folder, or you zip the src folder, name it MyoBridge and add it to the Arduino IDE.

After you’re done with that open the MyoBridge/Arduino/libraries/MyoBridge/examples/printFirmwareInfo/ sketch and flash your arduino with it.

Now disconnect your Arduino, wire a cable from PIN 2 on the Arduino to the TX PIN on the BLE Module, and another cable from PIN 3 on the Arduino to the RX PIN on the BLE Module. Plug in your Arduino back to the computer, open the Serial Monitor and set the baud rate to 115200.

If everything worked out you should see searching for myo… connecting with myo.. connected. followed by the firmware information of your Myo armband.

If you however get stuck on this instead:

then you can try the following:

  1. Make sure all wires are connected properly

  2. Make sure the Myo armband is charged and ready

  3. Make sure you’re using the latest version of CCLoader

The reason we mention the third option is because we ourselves had problems with the Linux version of CCLoader before the latest patch, since it missed the last block of firmware sometimes, and didn’t fully flash it.

Hope you enjoyed the tutorial so far, if you have any questions just leave them in a comment below and we’ll try to answer as soon as possible. See you in the next tutorial where we’ll actually start playing the Myo:)

Originally published at blog.raquenaengineering.com on July 24, 2017.