ESP32 Thing MPU6050 - cchamchi/ESP32 GitHub Wiki
MPU6050์ 6์ถ IMU์ ๋๋ค. IMU์ ๋ํ ์์ธํ ์ค๋ช ์ ์ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ์ธ์
Fritzing ํ์ผ ๋ค์ด ๋ก๋
VCC : 3.3V๋ฅผ MPU6050์ 3.3V์ ์ฐ๊ฒฐ
SDA : pin 21
SCL : pin 22
Arduino IDE๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ช ํฉ๋๋ค. (esp-idf์๋) ์ฐ์ ์๋์ด๋ ธ์ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถ๊ฐํฉ๋๋ค. MPU6050์ I2Cํต์ ์ ์ฌ์ฉํฉ๋๋ค. ๋ฐ๋ผ์ I2C๋ผ์ด๋ธ๋ฌ๋ฆฌ์ MPU6050 ๋๊ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ์ํฉ๋๋ค.
์ฌ๊ธฐ๋ฅผ ํด๋ฆญํ์ฌ i2cdevlib-master.zip์ ๋ค์ด๋ฐ๊ณ ์์ถ์ ํ๋ฉด arduino ํด๋์์ I2Cdev ์ MPU6050 ํด๋๋ฅผ ๋ณต์ฌํ์ฌ arduino/library ํด๋์ ๋ถ์ฌ๋ฃ์ต๋๋ค.
์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ arduino๋ฅผ ์ํ ๊ฒ์ด๋ผ์ ESP32 Thing์์ ์ฌ์ฉํ๋ ค ํ ๋ 2๊ฐ์ง ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
MPU๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ESP32 ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฐ์ data type์ ์ธ์ด ๋ฌ๋ผ์ ์๊ธฐ๋ ์๋ฌ์ ๋๋ค.
In file included from /Users/lineplus/Documents/Arduino/esp32MPU6050/esp32MPU6050.ino:4:0:
/Users/cchamchi/Documents/Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:63:24: error: conflicting
declaration 'typedef int8_t prog_int8_t'
typedef int8_t prog_int8_t;
^
In file included from /Users/lineplus/Documents/Arduino/hardware/espressif/esp32/cores/esp32/WString.h:29:0,
from /Users/lineplus/Documents/Arduino/hardware/espressif/esp32/cores/esp32/Arduino.h:150,
from sketch/esp32MPU6050.ino.cpp:1:
/Users/cchamchi/Documents/Arduino/hardware/espressif/esp32/cores/esp32/pgmspace.h:25:14: note: previous
declaration as 'typedef char prog_int8_t'
typedef char prog_int8_t;
/Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h ๋ฅผ ๊ณ ์น๊ธฐ๋ก ํ์ต๋๋ค.
๊ธฐ์กด์ ์ ์ธ์ ๋ง์๋ฒ๋ฆฌ๊ณ .. 62 line ์ฏค์ ์์ต๋๋ค.
/*
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
*/
์๋ก์ด ์ ์ธ์ ๋ฃ์ด ์ฃผ์ธ์
typedef char prog_int8_t;
typedef unsigned char prog_uint8_t;
typedef short prog_int16_t;
typedef unsigned short prog_uint16_t;
typedef long prog_int32_t;
typedef unsigned long prog_uint32_t;
BUFFER_LENGTH ๊ฐ ์์ด์ ์๊ธฐ๋ ์๋ฌ ์ ๋๋ค. ์๋ง arduino๋ณด๋๋ผ๋ฉด ์ด๋๊ฐ์ ์ ์ธ์ด ๋์ด์๋ ๋ด ๋๋ค.
In file included from /Users/lineplus/Documents/Arduino/libraries/I2Cdev/I2Cdev.h:80:0,
from /Users/lineplus/Documents/Arduino/libraries/I2Cdev/I2Cdev.cpp:46:
/Users/lineplus/Documents/Arduino/libraries/I2Cdev/I2Cdev.cpp: In static member function 'static int8_t
I2Cdev::readBytes(uint8_t, uint8_t, uint8_t, uint8_t*, uint16_t)':
/Users/lineplus/Documents/Arduino/libraries/I2Cdev/I2Cdev.cpp:276:62: error: 'BUFFER_LENGTH' was not declared
in this scope
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
Arduino/libraries/I2Cdev/I2Cdev.h์ ์ ์ธ์ ๋ฃ์ต๋๋ค. ๋๋ต 83 line ์ฏค์ ๋๋ค.
// -----------------------------------------------------------------------------
// Arduino-style "Serial.print" debug constant (uncomment to enable)
// -----------------------------------------------------------------------------
//#define I2CDEV_SERIAL_DEBUG
#ifdef ARDUINO
#if ARDUINO < 100
#include "WProgram.h"
#else
#include "Arduino.h"
#endif
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#define BUFFER_LENGTH 32
#include <Wire.h>
#endif
#if I2CDEV_IMPLEMENTATION == I2CDEV_I2CMASTER_LIBRARY
#include <I2C.h>
#endif
#endif