• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

MPU6050 code for Arduino not compiling for ESP32. Please help.

Q&A Forum › Category: ESP32 › MPU6050 code for Arduino not compiling for ESP32. Please help.
0 Vote Up Vote Down
Yasir Sultani asked 5 years ago

Hi, am trying to run the MPU6050 with an ESP32 and have found the code and downloaded all the libraries. However, the code doesn’t compile when I change board from Arduino to ESP32 . Error posted in full below.

Arduino: 1.8.10 (Windows 10), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"
C:\Users\61426\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)':
C:\Users\61426\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)) {
^
C:\Users\61426\Documents\Arduino\libraries\I2Cdev\I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readWords(uint8_t, uint8_t, uint8_t, uint16_t*, uint16_t)':
C:\Users\61426\Documents\Arduino\libraries\I2Cdev\I2Cdev.cpp:414:70: error: 'BUFFER_LENGTH' was not declared in this scope
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
^
Multiple libraries were found for "I2Cdev.h"
Used: C:\Users\61426\Documents\Arduino\libraries\I2Cdev
Multiple libraries were found for "Wire.h"
Used: C:\Users\61426\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\Wire
Multiple libraries were found for "MPU6050.h"
Used: C:\Users\61426\Documents\Arduino\libraries\MPU6050
exit status 1
Error compiling for board DOIT ESP32 DEVKIT V1.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The code and setup used is from this website here :

  • dronebotworkshop.com/mpu-6050-level/

I used one of the examples (the second one) . Any help would be greatly appreciated.

4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
How did you install your libraries?
The MPU6050.h library should be installed on this path like the wire library:

C:\Users\61426\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries

Additionally, it seems that there is an error in the I2Cdev.cpp file from the I2Cdev library.
Maybe you should start by trying the MPU6050 examples provided in the library:https://github.com/ElectronicCats/mpu6050 and see if they work and then proceed with your project.
Regards,
Sara

0 Vote Up Vote Down
Yasir Sultani answered 5 years ago

Hi, I installed it using sketch->include library-> add .zip library. Can you link me a way to add it to that particular path?

0 Vote Up Vote Down
Yasir Sultani answered 5 years ago

The main problem is that the code runs for arduino uno, but not for esp32 :(. 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
You should unzip the library and copy the library folder to this path:

C:\Users\61426\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries

I think it works with Arduino because the library is in the arduino folder, but it is not in the ESP32 libraries folder.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.