ESP32 Thing MPU6050 - cchamchi/ESP32 GitHub Wiki

MPU6050์€ 6์ถ• IMU์ž…๋‹ˆ๋‹ค. IMU์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์„ค๋ช…์€ ์—ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”

HW์—ฐ๊ฒฐ

Fritzing ํŒŒ์ผ ๋‹ค์šด ๋กœ๋“œ

VCC : 3.3V๋ฅผ MPU6050์˜ 3.3V์™€ ์—ฐ๊ฒฐ

SDA : pin 21

SCL : pin 22

SW Library ์ถ”๊ฐ€

Arduino IDE๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. (esp-idf์•„๋‹˜) ์šฐ์„  ์•„๋‘์ด๋…ธ์šฉ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. MPU6050์€ I2Cํ†ต์‹ ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ I2C๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ MPU6050 ๋‘๊ฐœ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ๋ฅผ ํด๋ฆญํ•˜์—ฌ i2cdevlib-master.zip์„ ๋‹ค์šด๋ฐ›๊ณ  ์••์ถ•์„ ํ’€๋ฉด arduino ํด๋”์•ˆ์— I2Cdev ์™€ MPU6050 ํด๋”๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ arduino/library ํด๋”์— ๋ถ™์—ฌ๋„ฃ์Šต๋‹ˆ๋‹ค.

Library ์ˆ˜์ •

์œ„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” arduino๋ฅผ ์œ„ํ•œ ๊ฒƒ์ด๋ผ์„œ ESP32 Thing์—์„œ ์‚ฌ์šฉํ•˜๋ ค ํ• ๋•Œ 2๊ฐ€์ง€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

typedef error

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 ์—๋Ÿฌ

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
โš ๏ธ **GitHub.com Fallback** โš ๏ธ