This is a muscle sensor, and as the name suggests, they can read the flexing of muscles. Pretty straightforward, right? Well, let's actually think about that for a second. You place some pads on your skin, and then the sensor module somehow takes that biological process, you're moving your muscles, and turns that into an electrical signal that you can read with a microcontroller. What? How does that actually work?
Well, we're going to be explaining that in the video, as well as how to actually use these practically, and we'll be harnessing the power of this magical device to create something that lets you watch infinitely scrollable vertical content feeds without having to move a muscle. Welcome back to Core Electronics. Today we are playing around with electromyography sensors, or EMG sensors. I'm not saying that big word every time I'm just going to call it EMG.
First things first, how the heck does this thing work? How is it that you can flex a muscle and get a signal output to represent that flexing force? Well, your brain controls your muscles by sending tiny electrical signals down your nerves, which are connected to your muscles. When that electrical signal reaches your muscle, there is a whole heap of complex biology that goes on, but essentially the electrical signal kind of gets turned into a sort of chemical signal, and that chemical signal tells the muscle, hey, it's time to contract so we can move the body.
At this point, the muscle has heard that chemical signal and knows that it's been told by the brain to actually do something. It then creates another signal that travels through the muscle itself. This is another electrical signal that ripples through all the billions of muscle fibers in there, telling them to contract, and so your muscle moves. However, when this new electrical signal travels through your muscle, through all the fibers, it actually creates a very small voltage across the muscle itself. And let's say, maybe hypothetically we had some pads connected close to that muscle, we could read this voltage change and know that the muscle is being flexed.
It's a bit weird if you think about it. When you imagine the human body moving, you don't think of the measurable little electrical storm happening when you were just doing something as mundane as walking around. But it is happening and we can measure it. So what is this board doing? Well, mainly it's taking that little tiny voltage signal from your muscles and scaling it up so it's big enough that your microcontroller can read it. Ideally, it's going to put out a voltage between 0 and 3 or 0 and 5 volts that represents how hard that muscle is being told to flex. That is easier said than done.
The voltage that your muscles produce is measured in the range of about a thousandth of a volt. So it is super, super tiny. Now, it is really easy to take a small little signal like that and scale it up. But when you do that, you also scale up all the noise surrounding it. There is electrical noise and rogue voltage signals coming from your power supply, from the power outlets in your wall. A lot of things around you are creating tiny voltage changes as well. Even our cable here is acting as an antenna to pick up all those signals and all that noise.
So the real cleverness of these boards is that they scale up the muscle signal, but they also try and filter out a lot of the other electrical noise. It would be like trying to record somebody whispering on a busy street. If you wanted to make their voice louder, you would also make the busy street louder. So you would need to find a way to isolate their whispering and remove the busy street noise. Alrighty, let's fire one up and see all of this in action. First of all, we're going to need an EMG sensor, obviously, and also a microcontroller to read it with.
And we're going to be using a Raspberry Pi Pico here with MicroPython for our demo, but it's super easy to translate these examples to C++ and an ESP32 or Arduino. Now, this is where the problems start arising. You are going to need electrode pads. Most EMG sensors and kits will come with them, but they are disposable and it can only be used a certain amount of times before they either don't stick or the signal gets a bit hard to read. It depends a lot on your setup, but often you can get only two, maybe three uses out of these and fresh pads are usually going to give you better performance.
However, these EMG electrode pads can be bought in bulk for pretty cheap. They're not a very expensive consumer. The next problem, power supplies. The board itself needs a positive power supply and it also needs a negative power supply. It needs a positive and negative voltage to work. This is really easy to do with the classic solution of two 9-volt batteries, which we'll show you how to do in this video. We could do an entire guide on just selecting the right power supply for this sensor, but long story short, a battery is going to work best here.
These sensors use barely any power, so even on our 9-volt battery, I'm going to estimate that it could last probably a thousand hours or so. They just sip such little power. The other power issue is power to the microcontroller. If you are using a really cheap power supply, chances are it will be horribly noisy and give you dodgy results from the added noise. If you're using power from a USB in your computer, it should be all right though. But a USB isolator can help quite a bit if you're getting a bunch of noise or weird kind of things going on.
Again though, powering your microcontroller with a battery is going to be king here because 9 volts, AA batteries, lipos, these all provide a nice and clean supply with very little noise. Running your Pico off battery might be a bit of overkill here as the USB from your computer is usually more than good enough. We just wanted to mention it in case you really want to be sweaty about this. So, pads have limited uses, you need to use a not too noisy power supply, and you need a way to get negative voltage. These are all little inconveniences of using EMG sensors, but if you can deal with these, you're going to have a blast.
By the way, in the written version of this guide linked below, you'll find all the things you'll need to get this going, as well as all the code that we're about to look at. Alrighty, let's wire it up. Starting off, we'll power the EMG board with our positive and negative voltages. We're going to be using 9V batteries here with these adapters. We're going to go ahead and plug the ground of one battery into the ground of the board, and then the positive into VS+. So here the battery is taking 0V, or ground, and then as it goes from the negative to the positive wire, it adds 9V, so we get 9V on VS+.
Now let's get the second battery, and this time we're going to plug the negative terminal into VS-, and then the positive into ground. So now our battery starts at 0V, or ground, and because we're going the other way, we're going from our positive terminal to our negative terminal, it subtracts 9V, and this gives us negative 9V on VS-. This can't be done on every single power supply in existence, but it can be done with most standard batteries, by the way. You could use a pack of AA batteries or a LiPo battery here, just something that's going to have at least 3-5V to get a nice signal.
Also ensure that you really check your wiring, and you have it shown as here. If you mix it up and accidentally put the negative into the positive terminal or something like that, chances are you will destroy your sensor pretty much instantly, so be careful and check your wiring. Also, there is a way to only use a single battery with some resistors. We'll go over that in the written guide if you are interested, as I don't want to keep waffling on about power supplies anymore. Now we're going to go ahead and whack in our Pico like so, and all we're going to need to do is connect the ground pin of our microcontroller to the ground pin of the board so that they both know what 0V actually is, and then we'll plug the signal output pin into an ADC or analog pin of our microcontroller.
I'm going to be using ADC0 or pin 26 on our Pico here, but as you can see, all we're really doing is reading an analog output, so as long as your microcontroller has an analog pin that you can read on, it's very easy to rewire this for that. Now let's wire up our human. You'll probably have a 3.5mm jack that goes into the board, and this is connected to a red, green, and yellow electrode. Now, electrode placement is key here to getting a good reading. First of all, get the yellow one and connect it to a nearby part of the body without many muscles in it. A good place is somewhere like your elbow or the top of your wrist because it's a lot of bone and not much muscle.
This yellow one is going to be your reference or kind of your ground of the body, and you don't want any muscles firing and creating these small voltages just to mess it all up. You want something that doesn't have muscles. Then get the two remaining electrodes and connect them to the muscle that you want to read. Now, there is a little bit of an art to this. You actually want to place one of them directly in the middle of the muscle, and then the other one a few centimeters away. If you mess this up, you can still get a reading just fine, but the better the placement, the stronger the signal will be, and it might be worth taking a look at a muscle diagram and looking for some good spots and maybe just having a little trial and error to see what works.
Regardless, as long as the yellow one is placed where you have little to no muscle and the green and red one are close or next to each other running along a muscle, you're going to get a reading of some sorts. And then we're just going to go ahead and plug into our board. Alrighty, let's plug in our Pico and boot up Thonny, which is just going to be our MicroPython IDE of choice. Alrighty, as you can see, it's really not that much. All we're doing is reading an ADC pin, which is a very fundamental basic skill here, but if you do need the code, it's going to be in the written guide.
Alrighty, let's give that a run. We're going to go ahead and open up the plotter so we can see what is going on. I'm just going to drag that across here. I don't really care about the raw number reading. And we're going to run that. And, oh, that's strange. Hmm, that's a bit of a new one. I ain't seen that happening before. Maybe we need to put the USB isolator in. Alright, so those issues were from my yellow pad falling off. We've been wearing it all day and testing. And looking at this now, the graph, there is a lot more noise in this room compared to where I was testing in my office.
I think I'm guessing it might be the studio lights. I'm unsure if that's kind of a 60 hertz signal we might be seeing through our sampling rate. Regardless, every environment is different. This is probably a very horrendous environment to be doing it in. Something that might help is wrapping up the cable in a little ball and making it as short as possible. Let's just give that a go and see what we get. I'm going to say maybe marginally improved there. Regardless though, let's go ahead and give that a good flex. Flex again. As you can see, there's a big spike when we flex it up like that. Noise all around, but when we...
Flex, I'm sorry, I just want a really, want an excuse to do that. You can see it jumps up. Now that data is pretty hectic, so let's run this code here that instead has a moving average filter. This is a very, very basic filter that kind of just averages off all of those spikes, and it's going to maybe help us see everything a little bit better. So let's go ahead and run it, and as you can see, our graph is a lot nicer, and if I flex, we can see a bit nicer. There we go. Moving average filter, really low-hanging fruit that kind of really drastically, you know, improves the effectiveness of all of this.
We've just moved into this new studio, and this is probably the first time we're realizing how incredibly noisy it is in here. But nonetheless, we can flex, and we're still going to see the spike going up like so. So how can you actually use this? Well, first of all, you can see that when we're kind of just not flexing, it doesn't really cross a value, so you could just do a little bit of trial and error, find a value here, and say, if it goes above, say, 30,000 like so, you know that we're flexing a muscle. Flex, no flex. Flex, no flex.
However, the number that you choose here will likely change every time that you reattach the pads or even go into a different room like the one we're in here. When I was testing in my office, the noise didn't really push it past this kind of 13,000 value here. So ensure that you can basically change it on the fly. You might need a little bit of tuning every time you set this up. Also remember that your pads might be put in a better or worse environment so that this kind of signal that cuts through the noise might be bigger or smaller. Just be prepared to tune all of this in that threshold value.
Another thing is that this is really good at first detecting when the muscle is flexed, but if I keep flexing it, you can see it kind of drops back down sort of to our base level eventually like so. I'm still flexing this really, really hard and it's kind of dropped down. If I let go, you can see there's not really much of a difference. But if I start flexing again, you can see it spikes up. I'm not sure how much of this is the filtering on the board and how much of it is biological. If you are a body science person, let us know below.
So detecting constant flexing is a bit harder. Detecting that initial flex is easier. So if you are looking to put this in a project, it's probably better to think of it as, you know, flexing to tap a button rather than, you know, flexing to push a slider or something like that. It's more of a, are you flexing or are you not? Or how hard are you initially flexing? Also, I want to make something really clear. This is not going to detect the angle of your arm. It's just going to detect how hard a certain muscle is being flexed. I can flex this at any angle and it's going to give us the same pretty much signal.
Just to show I'm not completely crazy, here is some footage we snapped in my office that isn't a film studio with no 10,000 sources of noise and cables hanging everywhere to really interfere with this. As you can see, it's pretty stable at rest and it's a lot clearer when you actually flex the muscle. It's also able to pick up little movements of the wrist. I'm not actually flexing very hard here. I'm just moving my hand as I usually would. And with this more favorable, probably what you're going to see in the real world environment, it's also a lot clearer to see how hard that muscle is actually being flexed.
We also went ahead and made a funny little thing, a device that controls your infinitely scrollable vertical content with muscle flexing. It's actually pretty straightforward. The Pico is acting as like a USB keyboard here and the code looks for the muscle signal to pass a certain value to know that we're flexing the muscle. And if it does, it presses down the arrow key and moves to the next short. It's a bit of a silly demo, you know, it's only working on a desktop and that's why we're using YouTube shorts. But I tell you what, when I was actually plugged into it, it was quite a weird and unusual feeling being able to interact with a computer like this.
I don't know, it was like there's a new neural pathway being trained that, oh, this is how you interact with the fun square, you know, like, ooh. If you want to replicate this, we will have some instructions in the written guide link below. There's just a bit too much to explain in this video. This entire demo was, of course, an elaborate ploy to be able to watch Mr. Beast YouTube shorts on company time. I love Mr. Beast. Mr. Beast.
Well, that about wraps us up. When you think about it, it is pretty cool that we can take the absolute thousandth of a voltage that our body produces when we flex a muscle and have a cheap, inexpensive sensor like this that can take that and create a signal that we can read on a microcontroller. If you do make anything cool with this or you need a hand with anything we covered in this video, feel free to head on over to our community forums. We're all makers over there and we're happy to help. Till next time, though, happy making.

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