• AIPressRoom
  • Posts
  • Exploratory Evaluation of MEMS Sensor Information | by Dmitrii Eliuseev | Aug, 2023

Exploratory Evaluation of MEMS Sensor Information | by Dmitrii Eliuseev | Aug, 2023

Studying, gathering, and analyzing information from the MPU6050 sensor

MEMS (Micro-electromechanical Methods) sensors are broadly utilized in completely different purposes, from recreation controllers and smartphones to unmanned aerial autos. On this article, I’ll present the right way to join a gyroscope and accelerometer sensor, what sort of information it’s potential to get from it, and the way this information could be processed and visualized.

Let’s get began.

{Hardware}

The MPU-6050 is a 6-axis sensor that mixes a 3-axis gyroscope, a 3-axis accelerometer, and the I2C interface. As written within the datasheet, it’s broadly used for tablets and smartphones. When our smartphone or smartwatch calculates the steps and energy throughout the exercise, the information from MEMS sensors is definitely used. However sensors like this can be utilized for extra than simply sports activities. I made a decision to put the sensor in my condo for a number of days and work out if I’d have the ability to detect and analyze completely different vibrations within the constructing the place I dwell.

If we need to acquire information inside a number of days, the Raspberry Pi is an efficient answer for that. The Raspberry Pi is an affordable (30–50$) single-board laptop; it has low energy consumption and loads of pins to attach several types of {hardware}. An MPU-6050 prototyping board could be ordered on Amazon for 3–5$. The sensor itself makes use of the I2C bus for information switch, and it may be linked to a Rasberry Pi utilizing solely 4 wires:

Earlier than utilizing the sensor, the I2C bus needs to be enabled on the Raspbian OS (there are sufficient tutorials about the right way to join the MPU6050 to the Raspberry Pi, so I’ll skip the “{hardware}” particulars right here). After connecting the sensor, I created a easy Python software that reads the sensor information and writes it “as is” into log information:

from datetime import datetime
import smbus
import math
import time

# MPU6050 Registers
PWR_MGMT_1 = 0x6B
SMPLRT_DIV = 0x19
CONFIG = 0x1A
GYRO_CONFIG = 0x1B
INT_ENABLE = 0x38
ACCEL_XOUT_H = 0x3B
ACCEL_YOUT_H = 0x3D
ACCEL_ZOUT_H = 0x3F
GYRO_XOUT_H = 0x43
GYRO_YOUT_H = 0x45
GYRO_ZOUT_H = 0x47

bus = smbus.SMBus(1)
tackle = 0x68

def device_init():
""" Init the MPU-6050 """
bus.write_byte_data(tackle, SMPLRT_DIV, 0x4)…