얕고 넓게

[Arduino] 2. Gyro Sensor 본문

IT/Platform

[Arduino] 2. Gyro Sensor

블랙오닉스 2022. 2. 3. 20:21

0. Spec.

Sensor: MPU-6050

Board: GY-521

5V-> LDO -> 3.3V

A0: Pull-down 0x68 (default), Pull-up(3.3V) 0x60

 

1. Ref.

https://playground.arduino.cc/Main/MPU-6050/

 

Arduino Playground - MPU-6050

MPU-6050 Accelerometer + Gyro Navigation Introduction The InvenSense MPU-6050 sensor contains a MEMS accelerometer and a MEMS gyro in a single chip. It is very accurate, as it contains 16-bits analog to digital conversion hardware for each channel. Therefo

playground.arduino.cc

https://www.i2cdevlib.com/docs/html/class_m_p_u6050.html

 

I2Cdevlib: MPU6050 Class Reference

Get word pair grouping order offset for the specified slave (0-3). This sets specifies the grouping order of word pairs received from registers. When cleared to 0, bytes from register addresses 0 and 1, 2 and 3, etc (even, then odd register addresses) are

www.i2cdevlib.com

https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050

 

GitHub - jrowberg/i2cdevlib: I2C device library collection for AVR/Arduino or other C++-based MCUs

I2C device library collection for AVR/Arduino or other C++-based MCUs - GitHub - jrowberg/i2cdevlib: I2C device library collection for AVR/Arduino or other C++-based MCUs

github.com

http://www.jkelec.co.kr/img/sensors/manual/mpu6050_gy521/mpu6050_gy521_manual.html

 

MPU6050 GY-521 센서 메뉴얼

  1. MPU6050 센서 소개 MPU6050은 가속도와 자이로센서가 1개의 센서에 모두 포함하고 있는 6DOF(Degrees of Freedom) 센서이다. MPU6050은 I2C (Inter Integrated Circuit) 통신 프로토콜을 통해서 데이터를 추출 할

www.jkelec.co.kr

 

 

https://github.com/adafruit/Adafruit_MPU6050

 

GitHub - adafruit/Adafruit_MPU6050

Contribute to adafruit/Adafruit_MPU6050 development by creating an account on GitHub.

github.com


3. 샘플 코드

#include <Arduino.h>

#include <Adafruit_MPU6050.h>
//#include <Adafruit_Sensor.h>

Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(9600);
  Serial.println("Test Gyro");

  if (!mpu.begin()) {
    Serial.println("Sensor init failed");
    while (1)
      yield();
  }
  Serial.println("Found a MPU-6050 sensor");

  delay(500);
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  Serial.print("Accelerometer ");
  Serial.print("X: ");
  Serial.print(a.acceleration.x, 1);
  Serial.print(" m/s^2, ");
  Serial.print("Y: ");
  Serial.print(a.acceleration.y, 1);
  Serial.print(" m/s^2, ");
  Serial.print("Z: ");
  Serial.print(a.acceleration.z, 1);
  Serial.println(" m/s^2");

  Serial.print("Gyroscope ");
  Serial.print("X: ");
  Serial.print(g.gyro.x, 1);
  Serial.print(" rps, ");
  Serial.print("Y: ");
  Serial.print(g.gyro.y, 1);
  Serial.print(" rps, ");
  Serial.print("Z: ");
  Serial.print(g.gyro.z, 1);
  Serial.println(" rps");

  delay(100);
}

4. 연결

Arduino Nano Sensor Board
5V VCC
GND GND
A4(SDA) SDA
A5(SCL) SCL
D2(IRQ) INT

'IT > Platform' 카테고리의 다른 글

[Arduino] Sun Keyboard Converter  (0) 2022.02.03
[Arduino] 4. LCD 20x4  (0) 2022.02.03
[Arduino] 3. I2C PWM Controller  (0) 2022.02.03
[Arduino] 1. PWM  (0) 2022.02.03
[Arduino] 0. 개발 환경  (0) 2022.02.03