How to use EMG Grove Sensor, an experience with my students

Hi!

I bought and been testing Grove EMG detector.
I’m posting here what will later become documentation of my course of IoT telemetry for health, in which we are testing other sensors from seeedstudio, and other producers.

The experience with Seeedstudio products (mainly grove, but also mmWave) is overall good.

I’m opening a post here to let my students go on and document their foundings, as well as shedding some light in the use of the product.

The code provided by seeed is missing the led bar library, as stated from @Baozhu here. This should be updated on wiki as well.

The vast majority of the problems (like jaggy data, super noisy) encoutered by the users (here and elsewhere on the internet) are related to three different topics:

  1. power and common grounds: if you are using the sensor connected to a PC, check if the reading changes if the PC is a portable pc and you can disconnect it from the power. On the other hand, crosscheck if when this is connected, the power is connected to the ground. Possibly the signal could be less noisy if you connect the microcontroller to the same ground (throught a power supply). Another way to test would be power the microcontroller with a battery!
  2. the code I attach here[1] is not using the led bar. The code is recording a stasis in static_analog_dta, don’t move anything when the code starts!
  3. The picture provided is not recording correctly one muscle. This video tutorial explain it in a better way, but in general this guide is picturing the various ways in a more detailed way.

The surface EMG electrodes should be placed between the motor unit and the tendinous insertion of the muscle, along the longitudinal midline of the muscle

I’m having decent readings in this way, while more noisy / false one in the one proposed on the wiki of seeed.

hope this is useful for now, will keep you posted.

[1]

//  example taken from here https://wiki.seeedstudio.com/Grove-EMG_Detector/
// took away the LED BAR references, printing the value on the serial port. 
//
// the position of the electrodes is possibly wrong. 
// this tutorial (that is using a different sensor) may put you on the correct path
// https://www.youtube.com/watch?v=1LjE07z5r7c


// Grove - EMG Sensor demo code
// This demo will need a Grove - Led Bar to show the motion
// Grove - EMG Sensor connect to A0
// Grove - LED Bar connect to D8, D9
// note: it'll take about serval seconds to detect static analog value
// when you should hold your muscle static. You will see led bar from level 10 turn to
// level 0, it means static analog value get ok

//#include <LED_Bar.h>

//LED_Bar bar(9, 8);

int max_analog_dta = 300;   // max analog data
int min_analog_dta = 100;   // min analog data
int static_analog_dta = 0;  // static analog data


// get analog value
int getAnalog(int pin) {
  long sum = 0;

  for (int i = 0; i < 32; i++) {
    sum += analogRead(pin);
  }

  int dta = sum >> 5;

  max_analog_dta = dta > max_analog_dta ? dta : max_analog_dta;  // if max data
  min_analog_dta = min_analog_dta > dta ? dta : min_analog_dta;  // if min data

  return sum >> 5;
}

void setup() {
  Serial.begin(115200);

  long sum = 0;

  for (int i = 0; i <= 10; i++) {
    for (int j = 0; j < 100; j++) {
      sum += getAnalog(A0);
      delay(1);
    }

    //bar.setLevel(10-i);
    Serial.println(10 - i);
  }

  sum /= 1100;

  static_analog_dta = sum;

 /// Serial.print("static_analog_dta = ");
 // Serial.println(static_analog_dta);
}

int level = 5;
int level_buf = 5;

void loop() {

  int val = getAnalog(A0);  // get Analog value

  int level2;

  if (val > static_analog_dta)  // larger than static_analog_dta
  {
    level2 = 5 + map(val, static_analog_dta, max_analog_dta, 0, 5);
  } else {
    level2 = 5 - map(val, min_analog_dta, static_analog_dta, 0, 5);
  }

  // to smooth the change of led bar
  if (level2 > level) {
    level++;
  } else if (level2 < level) {
    level--;
  }

  if (level != level_buf) {
    level_buf = level;
    //        bar.setLevel(level);
    Serial.println(level);
  }

  delay(10);
}

Hi there, I like to seek some guidance from you regarding this particular sensor due to you have a much higher success rate of using it compared to me.

I recently bought this sensor and i tried testing them by attaching it to my forearm area and I am using a simple analogRead(sensor) function to read signal. I am getting around 307-310 range in an idle state (no flex) and when i clenched my fist, the signal spiked up as shown in the image. However, the value starts to gradually decrease until it reaches the idle state value even though my fist are still clenched. I tried changing the electrodes pads position but the results were the same.

I feel that the signals i am getting are all noise. I tried using an external supply of 9V battery and connect it to the DFrobot mega power jack while connecting the usb to my laptop, but the signals were the same.

Any advice will be great! Thank you.