Download PDF Parts List View on YouTube Download Code

Today we are going to work with a rather unique sensor, the MyoWare Muscle Sensor.

 

 

This cool device can allow you to perform electromyography experiments on yourself and other unsuspecting subjects!  If you’re unsure as to what electromyography is, then read on.

Introduction

There’s a good chance that at one point in your life you have had an EMG test in a clinic, hospital, or doctor’s office.  This non-invasive test is performed for a number of medical reasons.

The technology to perform these exams is very expensive, as most medical equipment is, and is generally out of reach to most experimenters. That hasn’t been a very big concern, as not too many of us really want to build an EMG device anyway.

But the same technology that is used in conducting an EMG test can also be used for other things. Some examples include:

  • Gesture sensing
  • Robot control
  • Exoskeleton design
  • Total immersion video games

In addition to all that, it’s just very interesting to experiment with!

These applications don’t require the same precision that a hospital EMG requires, and they can be performed with much cheaper equipment.

Today, we will be examining a sensor kit that allows you to perform your own EMG experiments, as well as create some very fascinating devices.

Electromyography

A complete description of Electromyography is beyond the scope of this article, however a basic description follows.

Motor Neurons

The whole process centers around Motor Neurons, which are located in your brain and in your spinal cord. 

Every time your brain wants to move a muscle, it uses motor neurons to transmit an electrical signal to them. These electrical signals cause the targeted muscle to contract.

Electromyography is the process of sensing electrical activity produced by skeletal muscles.  An instrument that performs electromyography is called an Electromyograph.

An electromyograph measures those faint electrical signals. In practice, sensors are placed along the path of the neurons. The electromyograph picks up these signals and measures both their speed and strength.

The record produced by an electromyograph is called an Electromyogram, and the entire procedure of getting one is commonly referred to as an EMG

Electromyographs

You have probably had an EMG at least once in your life, they are a common medical diagnostic test. Other uses for electromyography include medical research and muscle training.

An electromyograph machine typically costs several thousand dollars and requires the expertise of a trained medical professional to use and interpret its readings. 

The sensors used in an electromyograph are typically temporary stick-on electrode pads, however, electromyographs can also use sensors that are permanently attached to a body, or even inserted into the skin to measure electrical signals within the body.

Until recently, these experiments and procedures were restricted to hospitals and clinics that can afford both the equipment and trained personnel to operate it. However, the advancement in low-cost sensors has now made it possible to conduct these experiments for a much lower cost.

This has opened up electromyography to experimenters, makers, and developers, who can use this low-cost equipment to create new and exciting applications.

Now, of course, this low-cost equipment is not as sophisticated or as accurate as the machines used in hospitals to perform EMGs. However, it is still useful in its own right.

The MyoWare muscle sensor kit that we will be using today is an example of some of this low-cost equipment.

MyoWare Muscle Sensor Kit

The MyoWare Muscle sensor is built by Advancer Technologies and packaged by Sparkfun. It consists of the following items:

  • MyoWare Muscle Sensor – The heart of the kit, which we’ll be looking at in detail today.
  • LED Shield – An attachment shield with an LED bargraph display and a rechargeable battery.
  • Power Shield – A shield with slots for two CR2032 coin-cell batteries, to power the sensor.
  • Cable Shield – This shield allows you to attach external electrodes to the MyoWare sensor.
  • Proto Shield – A blank shield that can be used for prototyping.
  • Electrode Cable – The cable that connects to the Cable Shield. It has three electrodes.
  • Sensor Pads- Monitoring electrode pads to use with the electrodes.

The kit also includes a number of connectors that you can solder to the sensor and shields in order to mate them together.  It’s a good idea to do this before you start using the boards.

Muscle Sensor

The main component in the kit is the MyoWare Muscle Sensor itself. This is the latest generation of a sensor that has evolved over several years, so you might still find information regarding previous versions when you are researching it on the internet.

The Sparkfun version of the MyoWare sensor is a wearable board that has two electrode connectors on the bottom. These attach to standard monitoring electrode pads, and are labeled “middle” and “end”.

There is also a small cable attached to a third pad, which is the “reference electrode”. 

The sensor circuit board has connections for power, signal out, raw data, and external electrodes. These connections are meant to be attached to female connectors, which will allow you to stack the other shields directly onto the sensor board.

On the top of the board you’ll also find a power switch and a gain control, which can be adjusted to increase the sensitivity of the sensor.

The board has a power LED, as well as an LED that indicates when a signal has been detected.

The MyoWare Muscle Sensor operates on 2.9 – 5.7 violets DC, so it is compatible with virtually all microcontrollers.

LED Shield

The LED Shield’s most prominent feature is a 10-element LED bargraph display, which indicates muscle activity when paired with the MyoWare sensor.

This shield also has a rechargeable battery, so it can also power the muscle sensor.  A microUSB connector on the board can be used to recharge the battery.

Power Shield

The Power Shield is a very simple device, consisting just of two battery holders. This allows you to use two CR2032 coin-cell batteries to power the MyoWare muscle sensor and other shields.

It is very important to note that you should never use this board in conjunction with the LED shield, as they will both attempt to provide power and will conflict if used together.

Cable Shield

The Cable Shield is also a pretty simple board. It has a 3-conductor. 3.5mm jack that is used with a mating cable assembly.

The cable assembly has the three electrodes (middle, end, and reference) on it, and extends approximately 100 centimeters (40 inches). 

This cable allows you to place the electrodes on parts of your body that are not conveniently accessed using the wearable sensor. You should note, however, that the cable is not shielded, so it may pick up interference in areas with high electrical noise.

Proto Shield

The Proto Shield is simply a blank perfboard that is cut to the same form factor as the MyoWare sensor. It has space for the three connectors used for all the shields.

You can use this board to prototype your own external circuits for use with the MyoWare muscle sensor.

Using the LED Shield

The easiest way to get started with the MyoWare muscle sensor is to mate it with the LED Shield. As this shield has its own power source, it’s simply a matter of mating the two together.

When you do join the shield to the sensor, pay particular attention to getting it the right way around, as it will fit both ways. The pins on the connector are labeled, so use those markings to ensure you have installed the shield correctly.  

It’s also a good idea to turn the MyoWare muscle sensor off while mating it to the LED, or to any shield. 

Getting Prepared

After attaching the LED Shield to the MyoWare sensor, you’ll need to get ready to use the assembly. This involves attaching three pads to the electrode connectors, two on the sensor itself and a third one on the short black electrode, which is the reference sensor.

You are better off attaching the pads to the electrode connectors first, as opposed to placing them on your body and attaching the electrodes later.  This makes it easier to align the pads on the sensor, plus it reduces the chances of bruising the skin.

Before you place the pads on your body, you’ll need to determine exactly where to place them! I suggest starting with your arm, flex some muscles (squeezing your hand closed is a good method) and observe your arm to see the muscular movement.  The place you see a lot of activity is a good place to start.

Clean the area with isopropyl alcohol first, to remove any dirt or skin oils. Then peel the protective paper off of the back of the electrode pads and mount the MyoWare sensor directly on your skin.

The reference electrode should be placed somewhere where there is NO muscle activity, as its purpose is to establish a baseline reference.

Now we are ready to use the MyoWare muscle sensor!

Using the MyoWare Muscle Sensor

With the MyoWare muscle sensor and LED Shield firmly attached to your arm, or wherever you are taking your measurement, turn on the power switch.   Try and relax your muscles as you do this.

Initially, the LEDs on the LED Shield will all illuminate, and you’ll observe a lot of activity. Within a few seconds, it will calm down, with only one LED lit (or possibly none). Again, try and relax your muscles as best you can.

This initial activity is normal, the muscle sensor is stabilizing itself using the reference probe.

After the display has settled down, try flexing the muscle you are measuring. You should see the LED bargraph display the results. The more you flex the muscle, the higher the bargraph will read.

Experiment with the MyoWare muscle sensor and LED Shield combination by placing the electrodes in different spots and observing the results.

Using External Probes

The Probe Shield allows you to use remote electrode sensors with the MyoWare muscle sensor.  These are connected to a 3.5mm jack on the shield.

We can stack this shield in between the MyoWare sensor and the LED Shield. Once again, be sure to observe the correct orientation by looking at the pinout markings on all three boards when you do that.

Before you mount the shield, however, you should confirm which electrode goes to which sensor input – middle, end or reference.  You can do this with a multimeter, measuring continuity to the R, E, and M pins on the connector on the side of the shield.  Make a sure you don’t have the shield plugged into any other board while performing this measurement.

The measurements on my cable were as follows:

  • Black – Reference Electrode
  • Red – Middle Electrode
  • Blue – End Electrode

According to Sparkfun, there can be differences in the color-coding of the shields. They have a chart on their website page illustrating the differences, by this chart I seem to have a v11 cable version.

Once you know which wire is which, you can mount the shields. Be sure to keep the power switch OFF on the MyoWare muscle sensor board.

Place some pads on each electrode. Then peel off the backing from the pads and place them on the desired locations.

Now turn on the MyoWare sensor and observe the LED Shield bargraph display. Give it a few seconds to stabilize, then try flexing and relaxing the target muscle.  You should see the results on the display.

The external probes make it much easier to experiment with the MyoWare Muscle sensor, and they can be used with or without the LED Shield. 

On that subject, let’s see how we can use the MyoWare muscle sensor with a microcontroller.

Connect to an Arduino

We will be using an Arduino Uno for these experiments for no particular reason, as any microcontroller with analog inputs will do just fine. In fact, using a more advanced microcontroller like an ESP32 or Raspberry Pi Pico would have advantages, as their analog to digital convertors have more precision than the Uno. But, as everyone probably has a Uno I’ll go with that, you can substitute a different microcontroller if you wish.

Safety Considerations

Before we hook up a microcontroller (any microcontroller) to the MyoWare muscle sensor, we need to discuss safety.

When operating on batteries, the MyoWare muscle sensor is completely safe, as there is no electrical connection to AC ground and the voltages used are very small and low-current. The muscle sensor itself does not transmit any electricity to the electrodes, it works the opposite way. Think of them as very sensitive voltmeters, or the inputs to very sensitive audio amplifiers.

But, when attaching an external device like a microcontroller, or using an external power supply, you run the risk of connecting the negative (GND) input of the MyoWare sensor to AC ground.

Under normal circumstances this is not an issue, after all, the very purpose of the AC ground is to establish a baseline reference for the AC power in your home or office.

But a wiring fault, ground loop, or voltage leak in the system can raise the potential of the AC ground.  And that could pose a safety hazard.

Connecting a battery-powered microcontroller, like an Arduino Uno using a 9-volt battery, would be completely safe, as once again there is no path to AC ground. 

But connecting via a USB cable to a computer, as you do when programming and testing an Arduino, runs a risk as you make an AC ground connection via the USB cable. 

Using a battery-powered notebook or laptop computer to connect to the USB cable is fine, as once again, there is no connection to AC ground. Be sure not to connect any external accessories, such as an external video monitor, to the computer.

But you CAN safely use a desktop computer (or AC-powered notebook computer) with a microcontroller without passing through an AC ground. You just need a device called a “USB Isolator”.

Adafruit USB Isolator

The Adafruit 100ma USB Isolator is the perfect board for the job. It will allow you to connect your Arduino, or other microcontroller, through USB without passing a common ground.

Of course, to maintain this isolation you’ll need to ensure that you don’t allow any additional source of AC ground to connect to the microcontroller, this would defeat the purpose of the isolator.

The Adafruit device is small and very simple to hook up. It has two connectors:

  • Input – a microUSB connector is used as an input connector, so you’ll need a microUSB cable.
  • Output – A standard USB type A connector. For the Arduino Uno, you’ll need a USB type A to B cable, like the one that probably came with your Uno (and every other Uno you ever purchased).

There is also a small switch on the USB Isolator for speed, labeled HIGH and LOW. There are instructions for its use on the back of the board. I used mine in “HIGH” speed, and it worked fine, the instructions allude to issues with timing for keyboards and mice.

Using this isolator is as simple a plugging it in. If you don’t find that it passed enough current (as I initially did) try using a powered USB hub between your computer and the USB isolator. That seemed to fix it for me.

Arduino & MyoWare Hookup

The hookup is shown here, as you can see it’s about as simple as it gets. 

I’m not showing the USB isolator, but you’ll need it unless you’re using a battery-powered computer. In this experiment, you’ll need an external computer, as we require the serial monitor.

Arduino & MyoWare Code

Just as the hookup is very simple, so is the code. All we are doing is reading the analog input and displaying its contents to the serial monitor, without modification.

We define a connection to the analog input pin on pin A0 and an integer to hold the value of that input.

In the Setup, we initialize the serial port.

And, in the Loop, we read the value of the analog input, assign it to our variable, and write it to the serial monitor.

As I said, very simple!

Load the sketch to your Arduino, power on your MyoWare sensor (the LEDs on the MyoWare sensor will indicate that you are getting power from the Arduino) and open the serial monitor.

You should see a rapid display of numbers, that change when you flex the muscle you are measuring. It should get higher as you tighten the muscle.

It’s an interesting display, but a bit hard to read. 

Serial Plotter

A better display for the output data from the MyoWare sensor is the Serial Plotter.

Close the serial monitor and open the serial plotter, it’s the next item in the menu. You should now see a graphical representation of the analog input value, with the bottom (X) axis representing time and the Y-axis representing level.

A big improvement over a stream of numbers, but still difficult to read. Difficult because the Y-axis does not stay fixed, instead it dynamically adjusts itself to the input level. 

This makes it very hard to see rises and falls in the data, as they are compensated for as they happen.

We need to try and fix that.

Improved EMG Plotter Code

The problem with the Y-axis continually moving can be resolved by giving the plotter two other values to display:

  • A lower limit of 0
  • An upper limit of 1000

The following code does exactly that:

It’s the identical code to the first one until you get into the Loop.  There, we also print two “fake” output values to the serial port, one of them at zero and the other at 1000.

You might wonder why not 1024 instead of 1000? The reason is the way the serial plotter scales, which would increase the scale to 1250 or 1500, which is a waste of space.  The data seldom, if ever, will get to 1024.

Load that up to the Arduino and repeat the first experiment, observing the serial plotter as you flex your muscle. The Y-axis of the display should now stay fixed at 0-1000, making it easier to reads the MyoWare muscle sensor data.

Moving a Robot Arm

As a final experiment, I’m going to attempt to control a robot arm with two MyoWare sensors.  Spoiler alert – it didn’t really work very well!

MeArm Robot Arm

A long time ago I put together a MeArm robotic arm, it’s a kit of acrylic parts and MG-90 stepper motors that is really just for educational purposes, as it’s not particularly capable of manipulating anything.

Since I had it around collecting dust (literally, I had to clean it off) I decided it might be fun to try and control a couple of the servo motors using MyoWare sensors.

The eventual goal was to have the arm mimic the motion my arm was making, but I didn’t come anywhere near achieving that!  But the fundamental design still has, I believe, some merit, so I’m presenting it here.

MeArm and MyoWare Hookup

The hookup is pretty simple, there is just a lot of wiring, but it’s all quite straightforward.

Essentially, you can break down the wiring as follows:

  • The two MyoWare muscle sensors – These connect to analog inputs 0 and 1.
  • The two potentiometers – These have their wipers connected to analog inputs 2 and 3.
  • The four stepper motors – These are BATTERY POWERED (no AC adapters for safety) and connect to four of the Arduino digital outputs.
  • The power – Make sure not t forget the common ground between the servo battery pack and the Arduino ground. Once again, keep safety in mind when wiring!

Observe all precautions as we did before regarding safety and using a USB isolator when developing. When you have the experiment “fine-tuned” to your liking, it’s best to use everything battery-powered. The serial monitor is only used for diagnostics and isn’t required for operation.

The purpose of the two potentiometers is to just position the servo motors that we are NOT controlling. They can be trim-pots if you like, or you could eliminate them entirely and just use fixed values for those servos PWM outputs.

MeArm & MyoWare Code

Here is the code we are using to control the MeArm with the two MyoWare sensors, and the two potentiometers.

We start by including Arduino’s built-in Servo library.

We then define a number of variables and constants:

  • Objects to represent each servo motor
  • Variables to hold the servo position, in degrees.
  • The two analog pins used for the MyoWare sensors
  • The two analog pins used for the potentiometer inputs.
  • Variables to hold the values of the four analog inputs
  • Variables to hold the minimum and maximum positions (in degrees) for each servo motor. Adjust to suit your application.
  • Variables to hold the minimum and maximum values from each MyoWare sensor. You’ll need to come up with your own values from 0 to 1023 for these.

For that last set of variables, you can use the previous experiment with the serial monitor, instead of the serial plotter. Run it for a while and flex your muscles! Then disconnect the Arduino but leave the serial monitor open. You can now scroll back and look at the data.

Determine the minimum and maximum values and use this in the code for the minimum and maximum sensor values. Do this for each sensor.

In the Setup, we initialize the serial monitor, which again is only for diagnostics. And we also attach the four servo motors to their Arduino I/O pins.

Then we have a short delay, to prevent the servos from going crazy while the MyoWare sensors stabilize.

In the Loop, we read the analog inputs and map them to their predefined limits, for both the MyoWare sensors and the potentiometers. Then we map the outputs to the pre-defined range we set earlier.

We then write these values to all the servo motors.

Testing & Improving Performance

Load the code into the Arduino, disconnect it, and then battery-power it.  

Hook up your electrodes to the position you notice your muscles moving when you make the required arm and fist movements. I had good luck capturing the arm movements, but terrible luck getting the arm flexing!

It will take some time to get this to work, especially the arm movement. It would be much easier to have two sets of cable shields and their remote electrodes, to give you more flexibility and to avoid pulling apart your experiment every time you flexed your muscle!

Conclusion

While I may have failed at mastering robot arm control, I did nonetheless find the MyoWare Muscle Sensor Kit to be both interesting and entertaining. 

To be able to even work with technology like this in a home environment was unthinkable not too long ago. This kit is the basis for a lot of fun and educational experiments.

And I may just be able to control that robot arm one day yet – stay tuned!

 

Parts List

Here are some components that you might need to complete the experiments in this article. Please note that some of these links may be affiliate links, and the DroneBot Workshop may receive a commission on your purchases. This does not increase the cost to you and is a method of supporting this ad-free website.

COMING SOON!

 

Resources

 

Code used today – All the Arduino code used today, in a handy ZIP file!

Sparkfun Guide  – The MyoWare Muscle Kit guide from Sparkfun.

Advancer Technologies – GitHub page for Advancer Technologies. Get the latest MyoWare documentation here.

 

MyoWare Muscle Sensor
Summary
MyoWare Muscle Sensor
Article Name
MyoWare Muscle Sensor
Description
Learn how electromyography works and how to use the MyoWare Muscle Sensor, both stand-alone and with an Arduino. We will also attempt to move a robotic arm with them!
Author
Publisher Name
DroneBot Workshop
Publisher Logo
Tagged on:
Subscribe
Notify of

2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Alex Thunder
2 years ago

Thanks for the cool tutorial. These things will help preserve the hair on your hands) https://www.elemyo.com/products

John Clements
2 years ago

I really enjoy your articles and projects. I retired just prior to the COVID 19 pandemic with big plans about traveling, but….. Now I spend more time on my electronics projects. Thank you!!