DIY Electromyography

-Arresh Amleshi

Like all good things in life, this project was born of a question-- a question that has disconcerted man since the advent of the mirror.

While there were numerous possible methods that I could use to quantify my swoll factor, electromyography provided the highest risk of electrocution, so I decided to go for it.

What is electromyography?

The word electromyography itself is born of three words:

Electro- Electric, having to do with electricity
Myo- Having to do with muscles
Graph- The act of writing or recording something

Essentially, electromyography entails measurement the electric potential generated by muscle cells (I will get into the origin of this electric potential later). This is a technique that has numerous medical applications, and is often used in the diagnosis of problems with the neuromuscular systems of the body.

Additionally, as even isometric muscle contractions (muscle contractions that are opposed by an antagonistic muscle or otherwise produce no action around an articulation) will produce a measurable voltage(0-10 millivolts), there is a lot of interest in the idea of using electromyography on pectoral and dorsal muscle groups in order to provide granular and organic control of prosthesis in amputation patients.

Where does the voltage come from?

Warning: This section will contain hardcore biology, turn back all ye physics majors.

The answer behind the existence of the voltages measured in electromyography lies in the core mechanism in how muscles are activated by the nervous system.

You may have noticed how muscles seem to react instantaneously to your will. This can be most clearly seen in reflexive actions that don't pass through the central nervous system. When you put your hand on a hot plate, you immediately jerk it back. While it may seem unremarkable, this reaction is very unique in the sphere of biological communications.

  • It is fast - the signal to jerk your arm away must travel from your hand, to your spine, then to the correct muscle group to cause you to jerk your hand away in the time before you sustain irreparable damage from the heat. Most biological signals are transferred via delocalized diffusion, and can take hours to reach threshold concentrations in distant parts of the body.
  • It is targeted- The signal is sent to one muscle group, and one muscle group only. This is different from the bodily norm of diffusing a signal throughout the entirety of the body, but only having targeted receptors on the surfaces of the cells to be effected by the signal.

Neurons act as the information superhighway of the body, and to allow for the quick transmission of targeted signals we fire muscles via the activation of voltage-gated sodium-potassium pumps.

In the resting state (state 1), neurons have constant NaK pumps running across the membrane of the cell, which pump out 3 Na+ ions out of the cell, while pumping in 2K+ ions via active transport. Each cycle of the pump generates a -1 charge, that accumulates to make the membrane potential of a neuron to drop to about -70 millivolts in its resting state.

If a small positive voltage is applied to the activation gate, it opens a channel between the outer membrane of the cell and its inner membrane. Because the principles of diffusion state that ion concentrations seek equilibrium across permeable membranes, Na+ ions begin to rush into the intercellular space. If a threshold potential (state 2) of around +20 mV is applied to the membrane, then enough voltage-mediated gates open that the rising internal voltage inside the cell causes more gates to open.

The depolarization (state 3) of the voltage inside the cell continues until it reaches its Action Potential (usually around 50 mV). This action potential is when the magic happens, and usually causes a contraction of a muscle fiber (I will save the topic of the contraction of a sacromere unit for another time).

Immediately after an action potential, all voltage-activated sodium potassium pumps are deactivated for a refractory period(state 4) which allows the cell time to return to its resting potential. The voltage actually undershoots its resting potential (state 5) before it settles at it, but that is not important to this conversation.

At this point it is worth noting the similarities between the triggering of an action potential via a smaller threshold voltage and the use of a transistor to control a large voltage with a smaller one.

Here is a larger graph of the voltage inside of a cell as a function of time during an action potential.

The Transmission of Signals through a Nerve

The action potential is routed from place via waves of depolarization that occur throughout the axons, similar to how voltage is carried through a wire.

The relation between Action Potential and Muscle Output

It is important to understand the connection between Action Potential and the contraction state of a given muscle group. While voltage is expressed over an analog range, and a muscle can express force over a range, individual muscle fibers can only be contracted or not contracted at any given time. Thus, the only thing we care about in terms of muscle output is the frequency of action potentials. If there is a small amount of time between action potentials, the muscle twitches blend together to form what seems like one solid output. Greater amounts of time between individual action potentials cause the muscle to be in a more and more relaxed state, until it is effectively not contracted.

An EMG sensor receptor effectively takes the integral of the rectified voltages generated as a result of an action potential. This value can be directly related to the force exerted by a muscle with some caveats.

Limitations on Surface Electromyography

Most medical EMG tests are done with conductive needles inserted into the body of the muscle being tested. Because Mr. Schmit hates fun, I had to use surface electrodes for the sake of this experiment. This limited my ability to only study surface muscles. Surface electrodes mean that I had to deal with interference due to dermal layers and adipose tissue between the muscle body and the probe. Additionally, my ability to stay consistent in the spot I probed between sessions was compromised.

The combination of all these factors meant that creating some form of general equation to correlate voltage to force on an axis was not an option. Instead I decided to use my EMG setup to create a line for me lifting a serise of weights in one sitting, then seeing if I could use it to predict an intermediate weight given only it's EMG values.

The reason why three electrodes are used in this setup is in order to eliminate background electrical noise, but I suspect this is nowhere near 100 percent effective as well.

My Hardware Setup

I used the EMG sensor available from Advancer Technologies in order to process the signal from the electrodes, and amplify it to a state that could be processed by my Arduino UNO microcontroller. I also used a small OLED display to give a readout of information on the board, though I captured my data through a serial connection of the arduino to my computer.

This was the Arduino Uno Microcontroller on which I processed the data

My Code:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

const int musclePin = A0;
const int speakerPin = 11;
const int switchPin = 8;

int incrementor = 0;
int speakerValue = 0;
int muscleValue = 0;
long averageMuscleValue = 0;
long averageOutput;

void setup()
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// init done
pinMode(speakerPin, OUTPUT);

// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
pinMode(switchPin, INPUT);

// Clear the buffer.

// draw a single pixel
display.drawPixel(10, 10, WHITE);
// Show the display buffer on the hardware.
// NOTE: You _must_ call ddisplay after making any drawing commands
// to make them visible on the display hardware!
display.setTextColor(BLACK, WHITE);

void loop()
for(int i = 0; i < 150; i++)
averageMuscleValue = averageMuscleValue/150;

averageOutput += averageMuscleValue;

speakerValue = map(averageMuscleValue, 0, 1023, 0, 255);
if (digitalReMad(switchPin) != HIGH)
analogWrite(speakerPin, speakerValue-20);
analogWrite(speakerPin, 0);
incrementor +=1;
if (incrementor == 75)
for (int i = 0; i < 30; i ++)
averageOutput = averageOutput/75;

Commentary on my Code:

I wrote my software to take the average of 75 averages of 150 readings of the EMG sensor, then output the result to Serial. The reason I wrote every data point to essentially be the average of 11250 readings of the EMG sensor was that there is a high amount of inherent variation between readings of the sensor. It is very difficult to not involuntarily twitch a muscle over a period of time, and factors such as heartbeat will also elicit some variation in the data. My hope with my code was to average out a large ammount of the variation.

My experiment:

I held a series of weights at a 90 degree angle to my body straight forward. I then incremented the weight by 2.5 pounds until I 12.5 pounds (I skipped 7.5 because that was the value I wanted to test my fit for).

My Data

The result

I took the average of 5 points at 7.5 lbs, then added them to the graph without changing the fit line. From a purely qualitative measure, you can see that it is fairly close to what my model predicted. I will not delve into any quantitative measure at this point, as the methods I used for this demonstration are purely useful for demonstrating the qualitative relation. (In fact, I am pretty sure I got lucky with how close my values were, looking at the graph, I would have expected more variation than I ended up getting.

Further reading/ Sources:

- General Source on EMG  

-cool abstract on the relation between signal amplitude and motor neuron activation.

- More information on the relation between action potential and the detected voltage.

- Blank diagrams of neural system

-Great Source on the factors that effect EMG readings

The EMG Sensor used was purchased from

and all documentation can be found there, including sample code and schematics.

All other parts were either purchased from,, or were spontaneously generated on the floor of my room.

I choose not to reveal the source of electrodes used in the project.