Hi everyone! I'm working on a project where I need to determine if a patient is sitting or standing or walking using the MPU6050 sensor. Does anyone have experience with this sensor and could share tips or examples on how to process and interpret the acceleration data to distinguish between these two positions? Any help or references would be greatly appreciated!
The acceleration readings will help you figure out what orientation the patient is in, by telling you which direction is down. So you might attach the sensor to a patient's thigh, for example, which would be horizontal when sitting but vertical when standing. But it would also be horizontal when lying down, so you would not be able to differentiate between sitting and lying down.
If you attached the sensor to the patient's chest, you could not differentiate between sitting down and standing up. But it would be able to tell if the patient is lying down.
Differentiating between standing and walking is more difficult. A sensor attached to the patient's thigh would alternately see periods of horizontal acceleration or no acceleration as each step is taken.
Yes, this is the problem I have been thinking about. They suggested that I use an AI model, but I don't know how it would identify this problem. Oh, and do you know of any materials for me to study about the MPU6050?
They? Do "they" have any idea how difficult it is to make a successful AI model of anything? My guess is not.
Maybe start here
Haha, it's really hard. I was studying how to do this, but it's going to take so much time. I'm going to read what you recommend. Thanks very much!
The MPU-6050 can be used to measure two tilt angles for a stationary object, as described in this tutorial: How_to_Use_a_Three-Axis_Accelerometer_for_Tilt_Sensing-DFRobot
The code is very simple:
// minimal MPU-6050 pitch and roll. Works with MPU-9250 as well.
// Tested with GY-521, pitch and roll signs agree with arrows on sensor module 7/2019
//
// Tested with 3.3V eBay Pro Mini with no external pullups on I2C bus (worked with internal pullups)
// Add 4.7K pullup resistors to 3.3V if required. A4 = SDA, A5 = SCL
#include<Wire.h>
const int MPU_addr1 = 0x68;
float xa, ya, za, roll, pitch;
void setup() {
Wire.begin(); //begin the wire communication
Wire.beginTransmission(MPU_addr1); //begin, send the slave adress (in this case 68)
Wire.write(0x6B); //make the reset (place a 0 into the 6B register)
Wire.write(0);
Wire.endTransmission(true); //end the transmission
Serial.begin(9600);
}
void loop() {
Wire.beginTransmission(MPU_addr1);
Wire.write(0x3B); //send starting register address, accelerometer high byte
Wire.endTransmission(false); //restart for read
Wire.requestFrom(MPU_addr1, 6); //get six bytes accelerometer data
int t = Wire.read();
xa = (t << 8) | Wire.read();
t = Wire.read();
ya = (t << 8) | Wire.read();
t = Wire.read();
za = (t << 8) | Wire.read();
// formula from https://wiki.dfrobot.com/How_to_Use_a_Three-Axis_Accelerometer_for_Tilt_Sensing
roll = atan2(ya , za) * 180.0 / PI;
pitch = atan2(-xa , sqrt(ya * ya + za * za)) * 180.0 / PI; //account for roll already applied
Serial.print("roll = ");
Serial.print(roll,1);
Serial.print(", pitch = ");
Serial.println(pitch,1);
delay(400);
}
It's a good idea, but it might be overkill for this project. All that's really needed is to know if the sensor is roughly horizontal or roughly vertical. It might be enough to simply compare the y & z accelerometer values. Assuming the sensor is attached to the front of the patient's thigh with the y axis pointing away from the knee, if z is significantly larger in magnitude than y, the patient is sitting. If y is significantly larger than z, they are standing. If z and y are roughly similar, the patient is in the process of standing up or sitting down, so wait a few seconds and measure again. If x is largest, maybe the patient has fallen, unless they are a gymnast or something
To know if the patient is walking, first of all, check they are standing. Then take readings a few times per second over several seconds and see how much variation in the readings there is. If the variations are only small, the patient is standing still. If the variations are large, the patient is walking.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.