Arduino and MPU6050 sensor create fall reminder - realize intelligent monitoring

In this tutorial, we will show you how to make a simple fall reminder system using Arduino and MPU6050 sensor. The system can detect if a person has fallen and trigger an alarm or send a notification.

1. Materials:

Arduino UNO board
MPU6050 accelerometer and gyroscope sensor
buzzer or LED light (for triggering alarm)
Dupont wire

2. Connect the circuit:

The 5V pin of the Arduino UNO is connected to the VCC pin of the MPU6050.
The GND pin of the Arduino UNO is connected to the GND pin of the MPU6050.
The A4 pin (SDA) of the Arduino UNO is connected to the SDA pin of the MPU6050.
The A5 pin (SCL) of the Arduino UNO is connected to the SCL pin of the MPU6050.
Connect the buzzer or LED light to the digital pins of the Arduino UNO (depending on the device you choose).

This time we choose the onboard light that comes with arduino, which is pin 13

Wiring diagram

3. Install MPU6050 library:

a. Open Arduino IDE.
b. Go to Tools > Manage Library.
c. Search for "MPU6050" in the library manager.
d. Select the appropriate MPU6050 library and install it.

Insert image description here

4.Code

#include <Adafruit_MPU6050.h>
#include <Wire.h>

Adafruit_MPU6050 mpu;
int thre = 80;//设置阈值
int led = 13;

void setup() {
    
    
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  
  if (!mpu.begin()) {
    
    
    Serial.println("Failed to start MPU6050");
    while (1);
  }
  
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
}

void loop() {
    
    
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);
  
  Serial.print("Acceleration X: ");
  Serial.println(a.acceleration.x);
  
  Serial.print("Acceleration Y: ");
  Serial.println(a.acceleration.y);
  
  Serial.print("Acceleration Z: ");
  Serial.println(a.acceleration.z);
  
  int offset = abs(a.acceleration.x)+abs(a.acceleration.y)+abs(a.acceleration.z);
  //偏移量绝对值相加
  Serial.print("offset: ");
  Serial.println(offset);
  if (offset > thre){
    
    
    digitalWrite(13,HIGH);
  }
  else{
    
    
    digitalWrite(13,LOW);
  }
  
  Serial.println();
  
  delay(500);
}

5. Test:

a. Place the Arduino UNO board on a stable surface.
b. Gently tilt the board to simulate a fall.
c. If a fall is detected, the buzzer will trigger an alarm or the LED light will flash.

6.Improvement

The operation of the LED or buzzer can be improved to send text messages to family members through the SIM900A module, notifying family members of a fall and whether help is needed, and monitoring the user's current condition.
You can extend and customize it to suit your needs, such as adding notification features or connecting alarms to other devices.

Guess you like

Origin blog.csdn.net/m0_63715549/article/details/131777878