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:
- 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!
- 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! - 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);
}