Getting Started With EMG Muscle Sensors | Measure Muscle Flexing!

Updated 26 October 2025

In this guide, we’re going to be exploring muscle sensors, also known as Electromyography (EMG) sensors, and learning how to use them to measure muscle movement in maker projects. These clever little modules can pick up the tiny voltage changes that happen inside your muscles when they contract, then turn that into a signal your microcontroller can understand. We’ll look at how this actually works, what you need to get them running reliably, and how to read muscle flexing using a Raspberry Pi Pico and MicroPython. Along the way, we’ll also build a fun demo project that lets you scroll endlessly through content feeds — without lifting a finger.

Let’s get into it!
 
 
 
 
 


How EMG Sensors Work

So, how on earth does a little board like this manage to read the flexing of your muscles? It sounds kind of sci‑fi at first, but what’s happening is actually just clever biology mixed with a bit of smart analog circuitry.

Your brain controls your muscles by sending tiny electrical impulses down nerves — these are the commands that say “hey, time to move.” When those signals reach a muscle, they kick off a small chain reaction inside the muscle tissue. There’s a lot of chemistry involved, but in short, this electrical signal causes chemical changes that make billions of muscle fibres contract together.

Here’s the trick: when all that electrical signalling and contracting happens, a tiny voltage is created across the surface of the muscle. And by tiny, we mean really tiny — we’re talking in the range of about one‑thousandth of a volt. But, if we place a couple of electrode pads on the skin near that muscle, those pads will pick up that tiny voltage as the muscle flexes. Every time you move, the voltage shifts slightly, and we can measure those changes to figure out how much the muscle is being flexed.

It’s kind of wild to think about. You’re sitting there moving your arm and there’s this little electrical storm of signals rippling through your muscles the whole time and you constantly have changes in voltages present on the surface of your body.

Inside the EMG module is a very sensitive instrumentation amplifier, which boosts that tiny microvolt‑level signal up to something a microcontroller can actually understand, usually between 0 and 3 volts (or 5 volts, depending on what you power the sensor with).

This sounds easy enough, but that small signal is surrounded by an ocean of noise - other electrical signals caused by interference from power supplies, lights, and even the wiring in the walls of your house. This interference is often not noticeable. But when we have a delicate application like trying to read thousands of a volt, these become a problem. The real cleverness of the board is that it includes filters which strip away most of the unwanted electrical noise WHILE still making the muscle signal larger enough that your microcontroller can read it.

You can think of it like trying to record someone quietly whispering on a noisy street — if you just turn up the volume, you’ll make the background traffic louder as well as their whispering. Filtering is like having smart software that suppresses the traffic noise while only keeping the whisper.

There is only so much you can do with filtering though. It does a good job, but as we will see, it is not entirely perfect.


What You Will Need

To follow along with this guide, you don’t need a whole lab setup — just a few key parts and a bit of patience when it comes to wiring. Here’s what you’ll need to get everything running smoothly:

  • EMG (Electromyography) Sensor Module
  • Microcontroller Board – We’re using a Raspberry Pi Pico running MicroPython, but this guide will also work on boards like the Arduino Uno, or ESP32 with only minor code changes. Any board with at least one analog input (ADC) pin will do the trick.
  • Disposable Electrode Pads – These are the sticky gel pads you place on your skin to pick up the muscle signal. Most sensors ship with a few in the box (the EMG sensor linked above comes with 3), but they wear out quickly — typically two or three uses before the readings get weak. These are consumable but can be bought in bulk for cheap.
  • Power For The EMG Sensor – This one’s a bit special. EMG boards need a positive and a negative supply, so the easiest solution is two 9‑volt batteries and battery clip adapters. One battery provides +9 V, and the other provides – 9 V. We’ll show you exactly how to wire those later. This can also work with other lipo batteries that are atleast 3-5 volts so you could use two lipo batteries or two AA packs of batteries.
  • Breadboard and Jumper Wires – Nothing fancy here — just to make power and signal connections tidy.
  • (Optional but useful) USB or power supply isolator – Helps reduce noise from your computer’s USB ground when reading these tiny muscle signals. Not required, but handy if your readings look messy.

Keep in mind that EMG setups are very sensitive to interference. A noisy power supply, dodgy USB cable, or poor electrode placement can all add extra noise. If you’re chasing the cleanest signal possible, battery power is almost always the best option.


Powering the Sensor and Circuit Wiring

Alrighty, let’s get this little board powered up so we can start seeing some signals. Now, one of the first quirks you’ll notice about EMG boards (or at least the type we are using) is that they don’t run from a single voltage like most sensors do — they need both a positive and negative voltage to work properly. That’s because the tiny signals coming from your muscles can swing slightly above and below zero volts, and the onboard amplifiers need a positive and negative voltage for reference.

The simplest and most reliable way to do this is with two 9‑volt batteries. You can use other battery types — AA packs, LiPos, anything between 3 to 9 volts — we are going to use 9-volt batteries as we found that they provide the best output voltage range (and it is the classic method of powering these - just following tradition).

The board should have 3 terminals. Vs+ which needs the positive voltage, ground which needs ground or 0-volts, and Vs- which needs the negative voltage.

Start with the first battery. Connect its negative terminal to the circuit ground, and the positive terminal to the sensor’s VS+ pin. That one is now providing your positive 9 volts - super straightforward.

Next, grab the second battery. This time connect its positive terminal to ground, and the negative terminal to the sensor’s VS− pin. Here the battery starts at 0 volts (ground,) and because we go from the positive terminal to the negative terminal, it instead subtracts 9volts rather than adding it. This gives us -9 volts.

Together, these two batteries create a ±9 V supply centred around ground. It’s simple, cheap, and wonderfully quiet in terms of electrical noise.

Now, let’s connect the rest of our circuit. The EMG module’s signal-out pin carries the amplified voltage from your muscle. Run that wire to any ADC input on your microcontroller. On the Raspberry Pi Pico, we’ll use ADC0 (pin 26). Then, connect the sensor’s ground pin to the microcontroller’s ground as well — this is to ensure that your Pico and sensor can agree on what 0 volts is.

Double‑check your wiring, especially for your batteries. If you accidentally swap your positive and negative supplies, there’s a good chance you’ll destroy the EMG board instantly. These amplifiers are sensitive little things, so it’s worth spending an extra minute confirming everything is right: +9 V → VS+, ground → GND, and –9 V → VS−.

A side note here. It is possible to power this with only one battery or voltage source and a couple of 1k ohm resistors.

Place one resistor from vs+ to gnd, then the other resistor from ground the vs-. Then connect the positive terminal of your battery or voltage source to vs+ and the negative terminal to vs-. The image on the right shows this setup.

With this, we have created something called a voltage divider. In this example, we used a 9-volt battery, and because the middle between the resistors is connected to ground (which dictates what is 0 volts), we end up with vs+ being fed with 4.5 volts, and vs- being fed with -4.5 volts.

Now, using voltage dividers to power things is often a no-no, and this is one of the few real-world cases where it can work. The only reason it works is because the EMG sensor uses such little power that the voltages are acting more as a reference than a power source.


Electrode Placement

With the electronics powered and wired up, the next thing we need to connect is you. The electrode pads are what let the EMG sensor actually pick up your muscle’s electrical activity, and good placement makes a huge difference to how clean your readings will be.

Most EMG electrode cables will have three leads — typically coloured red, green, and yellow (although sometimes you’ll see blue or black swapped in, so check your board for labels). These correspond to the two active inputs and the reference (or ground) input.

Start with the reference electrode, usually the yellow wire. This one should go somewhere bony or not very muscular, close to the area you’re measuring. Good options are the top of your wrist, your elbow, or a bony part of your forearm. Its job is to act like a baseline — a nice, quiet electrical reference for the other two pads to compare against.

Next, take the remaining two electrodes (red and green) and place them on the muscle you actually want to measure. The best results come when one of them sits right in the middle of the muscle, and the other is placed a few centimetres away along the muscle. That way, the tiny voltage generated along the length of the muscle will show up clearly between them.

If you mix this placement up, don’t worry — you’ll still get a reading — but the signal will likely be smaller or noisier. It’s also worth knowing that preparation matters. Make sure your skin is clean and dry before sticking on the pads. Oils, lotions, or sweat create a bit of resistance between your skin and the gel on the pad, which can really muddy the readings.

Another small but important note — these pads wear out. After two or three uses, the adhesive starts to lose its stickiness and the gel layer doesn’t transmit signals as well. A good rule of thumb is that if they stick well - the signal will be good.

Once all three electrodes are placed — reference on a bony area, and the other two lined up along your chosen muscle — plug the 3.5 mm jack into the EMG sensor. With everything wired and attached, you’re ready to power up the circuit and start seeing what your muscles are doing under the surface.


Reading EMG data with MicroPython

Alrighty, let’s finally fire this thing up and see what our muscles look like as a stream of data. We’re going to be using MicroPython on a Raspberry Pi Pico, but this same process works on pretty much any board that can read analog values.

Go ahead and open Thonny, plug in your Pico, and create a new script with the following code:

from machine import Pin, ADC
import time
pot = ADC(Pin(26))
while True:
    emg = pot.read_u16()
    print(emg)
    time.sleep(0.05)

As we can see, there’s not much to it. We start by importing the required MicroPython libraries and setting up our ADC pin (analog‑to‑digital converter). In our wiring, the EMG signal line is connected to pin 26, which is ADC0 on the Pico. The sensor constantly outputs a voltage between 0 and 3.3 volts (depending on how hard you flex), and this line measures it.

Inside our loop, we call read_u16() to grab the current analog reading, then print it out every 50 milliseconds. If you run the code, you’ll see a stream of numbers scrolling down the shell — that’s your muscle’s electrical activity being turned into raw data.

Try relaxing your arm and then flexing the muscle your electrodes are on. You’ll notice the numbers jump higher whenever you flex, and drop back down when you relax. You might also notice the values jittering slightly even when you stay still — that’s the electrical noise we mentioned earlier sneaking into the signal.

To make that output easier to read and a bit cleaner, we can smooth it out with a quick moving average filter. This will take a few data points at a time and average them, reducing the random spikes.

Here’s an example:

from machine import Pin, ADC
import time

pot = ADC(Pin(26)) 

window_size = 5  # number of samples for moving average
values = []

while True:
    emg = pot.read_u16()

    # add new value to list
    values.append(emg)

    # keep only the last 'window_size' samples
    if len(values) > window_size:
        values.pop(0)

    # compute moving average
    avg_emg = sum(values) / len(values)

    print(avg_emg)
    time.sleep(0.05)

This works much the same way as before, but now keeps a short list of recent readings. Each new value gets added while the oldest value drops off once our list reaches its set length (in this case, 5 samples). The average of these values becomes our smoothed EMG signal.

Run the script, and you should see a far steadier line of numbers. The baseline will still drift a little and there’ll always be some low‑level wiggle — that’s just the natural variation from both you and the sensor — but your flexes will now stand out as clear, rounded “waves” instead of sudden scatter.

This level of filtering is often all you need to detect when a muscle is activated. From here, we can start adding logic in code to decide what’s a flex and what’s normal background noise — and then use that to trigger things like LEDs, motors, or even scrolling commands. All you need to do here is find a value that the signal sits below when resting the muscle, but the signal jumps above when you flex that muscle. With that value, you can use a simple if statement to control what you need!


Content Feed Scroller

Now for something a bit more fun — let’s take all that muscle‑sensing power and use it for the most important task of all: scrolling your infinite vertical content feeds without lifting a finger. We threw together a quick demo that turns the Pico into a USB keyboard, and any time you flex your muscle past a certain threshold, it sends a Down Arrow key press to move to the next post or reel. It’s a little silly, but the experience of handing over computer control to your arm muscle feels strangely futuristic (and slightly weird).

To make this work, we need our Pico to behave like a USB keyboard. That’s easily done using CircuitPython, which is built for hardware that needs to act as a keyboard, mouse, or other USB HID device. CircuitPython is a programming language developed by Adafruit, and it's extremely close to MicroPython - they are cousins. To follow along with this part, you will need to flash CircuitPython onto your Pico, which will wipe all the data on it. You can always reflash MicroPython back when you are done.

Go ahead and head to CircuitPython.org and look for the Pico device you are using. Download the .uf2 file that matches it — that’s the firmware we’ll flash onto the board.

Now unplug your Pico, hold down the BOOTSEL button, and plug it back in. It’ll pop up on your computer as a little drive called RPI‑RP2. Just drag that .uf2 file onto it, and a few seconds later, the Pico will reboot itself and reappear as CIRCUITPY. 

Next, we’ll give the board its keyboard “superpowers.” Grab the Adafruit CircuitPython Library Bundle from the same site and unzip it on your computer. Inside the lib folder, you’ll find a folder called adafruit_hid — copy that into your Pico's storage. Place it in the Pico's lib folder. This is what lets the Pico send key presses to your PC.

With everything set up, open the CIRCUITPY drive and create a new file named code.py, open it in Thonny, then paste in the following:

import time
import usb_hid
import board
import analogio
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

keyboard = Keyboard(usb_hid.devices)

adc = analogio.AnalogIn(board.GP26)

window_size = 5
values = []
threshold = 17000     # pick a value a bit above rest
pressed = False        # track if we've already triggered this flex

while True:
    # read and apply moving average filter
    values.append(adc.value)
    if len(values) > window_size:
        values.pop(0)
    avg = sum(values) / len(values)

    print(f"Avg: {avg:.0f}")

    # if we cross above threshold then press the down arrow.
    if not pressed and avg > threshold:
        print("Flex detected! Sending Down Arrow")
        keyboard.press(Keycode.DOWN_ARROW)
        time.sleep(0.1)
        keyboard.release_all()
        pressed = True            # set a flag saying "we have pressed the button"
        # this flag gets checked above so that we don't keep pressing down multiple times

    # when the signal drops a little below the threshold (muscle has stopped flexing) reset
    # the pressed flag. this means we can press the button again.
    elif pressed and avg < threshold * 0.8:
        pressed = False

    time.sleep(0.05)

You will also need to find a good threshold value for your muscle signal to activate this keypress and ensure you put your value into the code towards the top.

Once you have tuned your threshold value, run the code, and it should press the down button when you flex!

It’s a bit of a novelty demo, but it genuinely feels odd (and kind of amazing) to interact with your computer just by tensing a muscle. There’s a noticeable sense of lag‑free, real‑time control that makes you wonder where else EMG inputs could be used. Of course, this was all a ploy to get paid to watch 3 minutes of YouTube shorts.


Where to From Here?

We’ve now covered quite a bit — from how EMG sensors pick up those tiny electrical signals from your muscles, through powering and wiring them properly, to reading and filtering that data in MicroPython. We even put it to use in a fun little project that lets you scroll content feeds with nothing but a muscle flex.

If you’re new to the Pico or MicroPython and want to keep building your skills, definitely check out our Pico Workshop. It’s a full video course that walks you through electronics fundamentals, coding with MicroPython, and a heap of hands‑on projects — the best next step after this guide.

And if you liked the idea of using your body as an input, take a look at our Raspberry Pi 5 Pose Estimation Guide. It’s the same concept taken further — using AI and computer vision on a Pi 5 to track movement and body position.

That’s a wrap for this one! If you make something cool with EMG sensors or muscle control — or just have a question — jump into the community Forum below. We’re always keen to see what you come up with.

Until next time, happy making!

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.