Muscle Sensor EMG Reading

This project involves reading data from a Muscle Sensor EMG (Electromyography) sensor connected to an Arduino board. The Muscle Sensor EMG sensor measures electrical signals generated by muscle contractions, providing valuable insights into muscle activity.

How It Works

An EMG — electromyography — sensor detects the electrical activity muscles produce when they contract. Motor neurons fire, muscle fibres depolarise, and the resulting potentials reach the skin at an amplitude of roughly 20 µV to 2 mV. That is thousands of times smaller than anything a microcontroller can read directly.

The sensor board, such as the MyoWare or the older Advancer Technologies kit, does three jobs. It amplifies with an instrumentation amplifier that rejects noise common to both electrodes; it rectifies the alternating signal; and it integrates the result into a smooth envelope that rises with contraction strength. What reaches A0 is that envelope, not the raw EMG.

The Arduino Uno samples with a 10-bit ADC, so analogRead() returns 0–1023 across 5 V. The envelope sits near zero at rest and rises toward the supply rail under strong contraction, so the full ADC range is genuinely used.

Electrode placement dominates everything else. Two electrodes go along the muscle belly, parallel to the fibres, and a third reference electrode goes on a bony, electrically quiet point such as an elbow or wrist bone. Moving an electrode a centimetre changes the signal more than any software adjustment will.

Components Needed

  • Arduino Uno
  • EMG Muscle Sensor module
  • Arduino Uno
  • USB cable for programming and power
  • Arduino Uno

Wiring to the Arduino Uno

Connect SIG to A0, +Vs to the 5 V rail and GND to ground. Some older EMG boards need a split supply; the MyoWare family runs from a single rail, which is why it is the easier choice.

Place the two measurement electrodes about 2 cm apart along the muscle, aligned with the fibre direction, and the reference electrode on a nearby bone. Clean the skin with alcohol first — skin oil raises contact impedance and ruins the signal.

Never connect an EMG sensor to a body while the project is powered from mains-derived USB on a desktop machine. Run it from a battery. This isolates the subject from mains entirely and is the standard safety practice for any biosignal work.

Module pinArduino Uno pinFunction
SIGA0Rectified, smoothed EMG envelope
+Vs5VPositive supply
GNDGNDCommon ground
Electrodes—Two on the muscle, one on a bony reference

Example Code

Reading the EMG envelope, establishing a resting baseline and detecting flexes. Upload it with the board set to Arduino Uno and open the Serial Monitor at 9600 baud.

Reading the EMG envelope, establishing a resting baseline and detecting flexes
const int EMG_PIN = A0;
const int FLEX_MARGIN = 123;

int baseline = 0;
bool flexing = false;

void setup() {
  Serial.begin(9600);
  Serial.println("Relax the muscle — calibrating...");
  delay(2000);

  long total = 0;                       // resting level varies per person and placement
  for (int i = 0; i < 200; i++) { total += analogRead(EMG_PIN); delay(5); }
  baseline = total / 200;

  Serial.print("Resting baseline: ");
  Serial.println(baseline);
}

void loop() {
  int level = analogRead(EMG_PIN);
  int above = level - baseline;

  bool nowFlexing = (above > FLEX_MARGIN);
  if (nowFlexing != flexing) {
    flexing = nowFlexing;
    Serial.println(flexing ? "CONTRACTION" : "relaxed");
  }

  Serial.print("level=");
  Serial.print(level);
  Serial.print("  above baseline=");
  Serial.println(above);
  delay(50);
}

Applications

A emg muscle sensor turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:

  • Gesture-controlled prosthetic and robotic hands
  • Rehabilitation tools that give patients feedback on muscle activation
  • Hands-free switches for accessibility devices
  • Sports and physiotherapy research into muscle recruitment
  • Human-machine interfaces where a flex replaces a button

Working with the Arduino Uno

The Arduino Uno is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.

The Uno runs at 5 V, so most hobby sensor modules connect directly with no level shifting.

With only 2 KB of SRAM, avoid large buffers and prefer the F() macro for constant strings.

The single hardware UART is shared with the USB connection, so heavy Serial printing competes with uploads.

Arduino Uno characteristicValueWhy it matters here
Logic voltage5 VMatches most hobby modules directly
ADC resolution10-bit (0–1023)Sets how finely an analog reading can be resolved
Analog inputsA0–A5 (six channels)Determines how many analog sensors can share the board
PWM outputsD3, D5, D6, D9, D10 and D11Needed for brightness, speed and tone control
I²C pinsA4 (SDA) and A5 (SCL)Fixed by hardware — wiring copied from another board may not match
Interrupt pinsD2 and D3 onlyRequired for counting fast or asynchronous events
Seriala single hardware UART shared with USBMonitor runs at 9600 baud by default

Troubleshooting

Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:

  • The signal is enormous and rhythmic at rest — that is 50/60 Hz mains pickup. Run from a battery and move away from mains wiring.
  • Almost no signal under contraction — the electrodes are misplaced or the skin was not cleaned. Reposition along the muscle belly.
  • The baseline drifts upward over minutes — electrode gel is drying out. Replace the electrodes.
  • Readings spike whenever the cable moves — motion artefact. Tape the leads down near the electrodes.
  • Two people give completely different numbers — this is expected. Always calibrate per person, per session.
  • Code written for an ESP board gives odd analog values — the Arduino Uno uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
  • An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Uno I²C is on A4 (SDA) and A5 (SCL).

Taking It Further on the Arduino Uno

Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the Arduino Uno specifically:

The Uno’s shield ecosystem is its real advantage. Once the circuit works on a breadboard, a prototyping shield turns it into something permanent that still stacks with a data-logging or Ethernet shield without rewiring.

Logging to an SD card via a shield is the natural next step, since the Uno has no onboard storage and no network. Timestamp each reading with a DS3231 real-time clock so the log survives power cuts with correct times.

Because SRAM is limited to 2 KB, keep logged strings short and write them out immediately rather than buffering. Building a long String in memory is the most common cause of an Uno sketch that runs for hours and then freezes.

Notes and Practical Limits

Battery power is a safety requirement here, not a convenience. Never connect electrodes to a person while the board shares a ground with mains equipment.

EMG output is not a measurement of force. It correlates with activation, but fatigue, electrode position and skin condition all shift it, so treat it as a control signal rather than a quantity.