ZHomeSlice / Simple_MPU6050

Going Live
MIT License
88 stars 24 forks source link

Simple_MPU6050_Basic_Example.ino not working for ESP8266 #13

Closed fanlessfan closed 3 years ago

fanlessfan commented 3 years ago

Hello,

I am trying to compile Simple_MPU6050_Example_No_interrupt_pin_used.ino (https://forum.arduino.cc/uploads/short-url/qY4D0CYmR2l0wQzHyoaMQahJVtW.ino) on Wemos D1 mini and got the error below.

Thanks in advance for the help.

`/Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:575:3: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive] 575 VectorInt16 :: normalize() { ^~~ /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:575:3: error: extra qualification 'VectorInt16::' on member 'normalize' [-fpermissive] /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:590:3: error: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive] 590 VectorInt16 :: rotate(Quaternion *q) { ^~~ /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:590:3: error: extra qualification 'VectorInt16::' on member 'rotate' [-fpermissive] /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h: In member function 'int VectorInt16::normalize()': /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:581:12: error: cannot convert 'VectorInt16' to 'int' in return 581 return VectorInt16(x /= m,y /= m,z /= m); ^~~~~~~~~
VectorInt16
In file included from /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/Simple_MPU6050.h:7, from /Volumes/Shared/Downloads/Simple_MPU6050_Example_No_interrupt_pin_used/Simple_MPU6050_Example_No_interrupt_pin_used.ino:3: /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h: In member function 'int VectorInt16::rotate(Quaternion*)': /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:613:12: error: cannot convert 'VectorInt16' to 'int' in return 613 return VectorInt16(p.x,p.y,p.z); ^~~~~~~~
VectorInt16
/Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h: At global scope: /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:645:3: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive] 645 VectorFloat :: normalize() { ^~~ /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:645:3: error: extra qualification 'VectorFloat::' on member 'normalize' [-fpermissive] /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:660:3: error: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive] 660 VectorFloat :: rotate(Quaternion *q) { ^~~ /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:660:3: error: extra qualification 'VectorFloat::' on member 'rotate' [-fpermissive] /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h: In member function 'int VectorFloat::normalize()': /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:651:12: error: cannot convert 'VectorFloat' to 'int' in return 651 return VectorFloat( x /= m,y /= m,z /= m); ^~~~~~~~~~
VectorFloat
/Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h: In member function 'int VectorFloat::rotate(Quaternion*)': /Volumes/Shared/Documents/Arduino/libraries/Simple_MPU6050/DMP_Image.h:674:13: error: cannot convert 'VectorFloat' to 'int' in return 674 return VectorFloat( p.x,p.y,p.z); ^~~~~~~~~
VectorFloat

exit status 1 Error compiling for board LOLIN(WEMOS) D1 R2 & mini.`

ZHomeSlice commented 3 years ago

The errors are caused by my inexperience in programming. The -fpermissive flag will downgrade some diagnostics about nonconformant code from errors to warnings. Thus, using -fpermissive will allow some nonconforming code to compile.

For those with better programming knowledge, helping me correct this nonconformant code would be great.

hope this helps Z

fanlessfan commented 3 years ago

Thanks Z. Could you let me know how to use -fpermissive on Arduino IDE?

ZHomeSlice commented 3 years ago

Try it out now

fanlessfan commented 3 years ago

Thank you so much @ZHomeSlice . now there are new errors below.

Simple_MPU6050_Example_No_interrupt_pin_used:9:33: error: expected constructor, destructor, or type conversion before ';' token

====full error===== Arduino: 1.8.16 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

/Volumes/data/apps/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Volumes/data/apps/Arduino.app/Contents/Java/hardware -hardware /Users/fzhou/Library/Arduino15/packages -tools /Volumes/data/apps/Arduino.app/Contents/Java/tools-builder -tools /Volumes/data/apps/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/fzhou/Library/Arduino15/packages -built-in-libraries /Volumes/data/apps/Arduino.app/Contents/Java/libraries -libraries /Users/fzhou/Documents/Arduino/libraries -fqbn=esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=40,FlashMode=dout,eesz=1M64,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None,wipe=none,baud=115200 -vid-pid=0000_0000 -ide-version=10816 -build-path /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013 -warnings=none -build-cache /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_cache_587836 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.mkspiffs.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs-3.0.4-gcc10.3-1757bed.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.4-gcc10.3-1757bed.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.python3.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.mklittlefs.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs-3.0.4-gcc10.3-1757bed.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -verbose /Volumes/personal/fzhou/Arduino/Simple_MPU6050_Example_No_interrupt_pin_used/Simple_MPU6050_Example_No_interrupt_pin_used.ino /Volumes/data/apps/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Volumes/data/apps/Arduino.app/Contents/Java/hardware -hardware /Users/fzhou/Library/Arduino15/packages -tools /Volumes/data/apps/Arduino.app/Contents/Java/tools-builder -tools /Volumes/data/apps/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/fzhou/Library/Arduino15/packages -built-in-libraries /Volumes/data/apps/Arduino.app/Contents/Java/libraries -libraries /Users/fzhou/Documents/Arduino/libraries -fqbn=esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=40,FlashMode=dout,eesz=1M64,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None,wipe=none,baud=115200 -vid-pid=0000_0000 -ide-version=10816 -build-path /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013 -warnings=none -build-cache /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_cache_587836 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.mkspiffs.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs-3.0.4-gcc10.3-1757bed.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.4-gcc10.3-1757bed.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.python3.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.mklittlefs.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs-3.0.4-gcc10.3-1757bed.path=/Users/fzhou/Library/Arduino15/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -verbose /Volumes/personal/fzhou/Arduino/Simple_MPU6050_Example_No_interrupt_pin_used/Simple_MPU6050_Example_No_interrupt_pin_used.ino Using board 'generic' from platform in folder: /Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2 Using core 'esp8266' from platform in folder: /Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2 Detecting libraries used... /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -USTRICT_ANSI__ -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp -o /dev/null Alternatives for MPU_ReadMacros.h: [Simple_MPU6050] ResolveLibrary(MPU_ReadMacros.h) -> candidates: [Simple_MPU6050] /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -U__STRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp -o /dev/null Alternatives for Wire.h: [Wire@1.0] ResolveLibrary(Wire.h) -> candidates: [Wire@1.0] /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -USTRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp -o /dev/null Alternatives for I2Cdev.h: [I2Cdev] ResolveLibrary(I2Cdev.h) -> candidates: [I2Cdev] /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets__ -DICACHE_FLASH -USTRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire -I/Users/fzhou/Documents/Arduino/libraries/I2Cdev /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp -o /dev/null /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -U__STRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire -I/Users/fzhou/Documents/Arduino/libraries/I2Cdev /Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050/Simple_MPU6050.cpp -o /dev/null /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -USTRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire -I/Users/fzhou/Documents/Arduino/libraries/I2Cdev /Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.cpp -o /dev/null /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets__ -DICACHE_FLASH -USTRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire -I/Users/fzhou/Documents/Arduino/libraries/I2Cdev /Users/fzhou/Documents/Arduino/libraries/I2Cdev/I2Cdev.cpp -o /dev/null Generating function prototypes... /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -U__STRICT_ANSI -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire -I/Users/fzhou/Documents/Arduino/libraries/I2Cdev /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp -o /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/preproc/ctags_target_for_gcc_minus_e.cpp /Users/fzhou/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/preproc/ctags_target_for_gcc_minus_e.cpp Compiling sketch... /Users/fzhou/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1/python3 -I /Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/signing.py --mode header --publickey /Volumes/personal/fzhou/Arduino/Simple_MPU6050_Example_No_interrupt_pin_used/public.key --out /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core/Updater_Signing.h /Users/fzhou/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++ -Dets -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_SOURCE -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/lwip2/include -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/core -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/variants/generic -I/Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 -I/Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire -I/Users/fzhou/Documents/Arduino/libraries/I2Cdev /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp -o /var/folders/wg/hrp4gsks3n1bt34wc0w3pl680000gp/T/arduino_build_216013/sketch/Simple_MPU6050_Example_No_interrupt_pin_used.ino.cpp.o Simple_MPU6050_Example_No_interrupt_pin_used:9:33: error: expected constructor, destructor, or type conversion before ';' token 9 | ENABLE_MPU_OVERFLOW_PROTECTION(); // this is a macro involving the yield() function | ^ /Volumes/personal/fzhou/Arduino/Simple_MPU6050_Example_No_interrupt_pin_used/Simple_MPU6050_Example_No_interrupt_pin_used.ino: In function 'void loop()': Simple_MPU6050_Example_No_interrupt_pin_used:110:11: error: 'class Simple_MPU6050' has no member named 'OverflowProtection' 110 | mpu.OverflowProtection(); // add this line to keep the FIFO buffer from overflowing while we wait | ^~~~~~ Using library Simple_MPU6050 in folder: /Users/fzhou/Documents/Arduino/libraries/Simple_MPU6050 (legacy) Using library Wire at version 1.0 in folder: /Users/fzhou/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire Using library I2Cdev in folder: /Users/fzhou/Documents/Arduino/libraries/I2Cdev (legacy) exit status 1 expected constructor, destructor, or type conversion before ';' token

ZHomeSlice commented 3 years ago

So I have a ESP8266 and I have many MPU6050's but I have never tried to use them together :) I will need to see how you are attaching them electrically. Please prived a schematic. I will also need to test code What GUI are you using to get this to work? Please provide an example code to test. Z

note that 'OverflowProtection' was completely removed. you will need to update your scripts.

fanlessfan commented 3 years ago

Thank you @ZHomeSlice

I use D1-mini with GY-521 MPU6050 board without interrupt pin. using an example code from Simple_MPU6050_Example_No_interrupt_pin_used.ino (https://forum.arduino.cc/uploads/short-url/qY4D0CYmR2l0wQzHyoaMQahJVtW.ino). I use Arduino IDE 1.8.16 (https://www.arduino.cc/en/software). I wonder if you can provide no interrupt pin example.

D1-MINI MPU6050 5V------> VCC G ------> GND SCL----> D4 (GPIO2) SDA----> D3 (GPIO0)

ZHomeSlice commented 3 years ago

This may take a few days before I can build the unit I'm ordering the D1-mini. I like the size of that development board.

Z

fanlessfan commented 3 years ago

Thanks @ZHomeSlice I think you existing ESP8266 should be the same. I just need a no interrupt pin example to use your library.

ZHomeSlice commented 3 years ago

@fanlessfan so I just updated the entire code base Nothing I did should affect you adversely

to prevent the pin from being added in Simple_MPU6050.h on line 4 Remark out

define interruptPin 2

this will remove all interrupt settings.

try this example: https://github.com/ZHomeSlice/Simple_MPU6050/blob/master/Examples/Simple_MPU6050_Basic_Example/Simple_MPU6050_Basic_Example.ino

it doesn't use interrupts and is as simple as possible. Z

fanlessfan commented 3 years ago

Thank you @ZHomeSlice for your quick response.

I compiled the basic_Example and got error below. I also remove the interruptPin and use your latest code class TwoWire' has no member named 'setWireTimeout'; did you mean 'setTimeout'?

If I remove the code like below. I passed the compile and got run time error

void setup() { uint8_t val; // join I2C bus (I2Cdev library doesn't do this automatically)

if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE

Wire.begin(0,2); Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties //Wire.setWireTimeout(3000, true); //timeout value in uSec <---------------comment out this line

run time error: --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0): epc1=0x402071a2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

stack>>>

ctx: cont sp: 3ffffe00 end: 3fffffc0 offset: 0190 3fffff90: 3fffdad0 00000000 3ffee7c8 4020122c
3fffffa0: feefeffe feefeffe 3ffee81c 40203ff8
3fffffb0: feefeffe feefeffe 3ffe85e4 40100f35
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 tail 4 chksum 0xcc load 0x3fff20b8, len 40, room 4 tail 4 chksum 0xc9 csum 0xc9 v00046970 ~ld Start:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0): epc1=0x402071a2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

stack>>>

ctx: cont sp: 3ffffe00 end: 3fffffc0 offset: 0190 3fffff90: 3fffdad0 00000000 3ffee7c8 4020122c
3fffffa0: feefeffe feefeffe 3ffee81c 40203ff8
3fffffb0: feefeffe feefeffe 3ffe85e4 40100f35
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

ZHomeSlice commented 3 years ago

Remove it Just added it to fix issues related to:

"the classic I2C bus 'freeze' problem, and if so, it has nothing at all to do with the MPU6060. I2C bus freezes are a known problem with Arduino, and it has only been recently addressed. See this post for all the gory details. The good news is, if you use the latest Wire library code and add the timeout setting line to your setup() function like this

Wire.setWireTimeout(3000, true); //timeout value in uSec

then the I2C freeze problem should go away. Note that if you aren't using the latest Wire library, the above code line won't compile, so it's easy to tell one way or the other." https://github.com/jrowberg/i2cdevlib/issues/543#issuecomment-707336866

fanlessfan commented 3 years ago

Thank you @ZHomeSlice for your help. I still can't compile the basic example on ESP8266. as you mentioned above(i2cdev comment) the wire library is part of the board platform and can't update separately. so I am stack there.

I just wonder if you compile the basic example on ESP8266 platform?

I can compile the i2cdev example MPU6050_DMP6_ESPWiFi.ino (https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/examples/MPU6050_DMP6_ESPWiFi/MPU6050_DMP6_ESPWiFi.ino) successfully, but I don't want the interrupt pin, and i2cdev don't have MPU9250_DMP support. So I come to your library for both 6050 and 9250. unfortunately it seems they don't work for ESP8266.

any idea to make them working on ESP8266?

Just to let you know that you old example passed the compile, but have run time error below.

Found MPU at: 0x68 WhoAmI= 0x34

Reset Offsets set Offsets

..............................>..............................Found MPU6050 or MPU9150 Found MPU at: 0x68 WhoAmI= 0x34

Reset Offsets set Offsets

// X Accel Y Accel Z Accel X Gyro Y Gyro Z Gyro

define OFFSETS -3724, 1668, 1640, 114, 54, -21

Failed to Find MagnetometerISR not in IRAM!

User exception (panic/abort/assert) --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Abort called

stack>>>

ctx: cont sp: 3ffffef0 end: 3fffffc0 offset: 0000 3ffffef0: 00000001 00000068 00000068 4020312a
3fffff00: 000000fe 00000000 00000000 00000000
3fffff10: 00000000 00000000 00000000 00ff0000
3fffff20: 5ffffe00 5ffffe00 00002adf 3ffee834
3fffff30: 00000000 00000001 00000002 402046e2
3fffff40: 40100679 3ffee7cc 3ffee58c 402046f4
3fffff50: 3fffdad0 00000000 00000002 402052ed
3fffff60: 3fffdad0 00000000 3ffee58c 402017aa
3fffff70: 3fffdad0 00000000 3ffee58c 4020538c
3fffff80: 3fffdad0 00000000 3ffee58c 40202cb0
3fffff90: 3fffdad0 00000000 3ffee58c 40201241
3fffffa0: feefeffe feefeffe 3ffee820 40204008
3fffffb0: feefeffe feefeffe 3ffe85e4 40100f35
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Thanks in advance

ZHomeSlice commented 3 years ago

Use this to find the error locaiton:

https://github.com/me-no-dev/EspExceptionDecoder

Z

fanlessfan commented 3 years ago

I got the decoder. here is the output and

the line 68 is

mpu.Set_DMP_Output_Rate(DMP_10Hz); // Set the DMP output rate from 200Hz to 5 Minutes.

the line 198 is

static void loop_wrapper() {
    static bool setup_done = false;
    preloop_update_frequency();
    if(!setup_done) {
        setup();
        setup_done = true;     <--------- 198
    }
    loop();
    loop_end();
    if (serialEventRun) {
        serialEventRun();
    }
    esp_schedule();
}

any idea?

thx

====== Exception 0: Illegal instruction PC: 0x402071fe EXCVADDR: 0x00000000

Decoding stack results 0x40201239: setup() at C:\Users\admin\Documents\Arduino\Simple_MPU6050\Examples\Simple_MPU6050_Basic_Example/Simple_MPU6050_Basic_Example.ino line 68 0x40204058: loop_wrapper() at C:\Users\admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 198

======

ZHomeSlice commented 3 years ago

thanks for the example code that works with the esp8266. I'm interested in getting it to work with the esp8266 so I will continue to improve it. also, I have been working with Jeff and his mpu6050 library. https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 The two libraries are very similar. I find my library to be easy to set up and follow. so my development cycle is shorter to implement. I need to compile his library and try it out on the esp8266 I have and see what the difference is.

mpu.Set_DMP_Output_Rate(DMP_10Hz); // Set the DMP output rate from 200Hz to 5 Minutes. this was intended to reduce the output to 10 hz so the serial port isn't spammed.

You will need to add a spam limiter to get past that next error.

Z

fanlessfan commented 3 years ago

Thanks @ZHomeSlice. You code indeed is easy to setup and have both MPU6050 and MPU9250 works. Hope you can make it work with esp8266 soon.

Thanks again for your hard working

ZHomeSlice commented 3 years ago

@fanlessfan Got it to work :) I'll Send the temporary fix shortly Hoping to implement a new example into my library Z

ZHomeSlice commented 3 years ago

Ok Here you go You can remove the wifi setup stuff and only watch the serial port. I kept the other as it worked and I didn't want to degrade the usefulness of the WiFi connectivity of the esp8266!

in Simple_MPU6050.h remark out line 4 //#define interruptPin 2

This is the sketch I am using it is an adjustment to jeffs MPU6050's library example sketch MPU6050_DMP6_ESPWiFi.ino

/* ============================================
  I2Cdev device library code is placed under the MIT license
  Copyright (c) 2012 Jeff Rowberg

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  ===============================================
*/

/* This driver reads quaternion data from the MPU6060 and sends
   Open Sound Control messages.

  GY-521  NodeMCU
  MPU6050 devkit 1.0
  board   Lolin         Description
  ======= ==========    ====================================================
  VCC     VU (5V USB)   Not available on all boards so use 3.3V if needed.
  GND     G             Ground
  SCL     D1 (GPIO05)   I2C clock
  SDA     D2 (GPIO04)   I2C data
  XDA     not connected
  XCL     not connected
  AD0     not connected
  INT     D8 (GPIO15)   Interrupt pin

*/

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <DNSServer.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <WiFiManager.h>         //https://github.com/tzapu/WiFiManager

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"

#define MPU6050_DEFAULT_ADDRESS     0x68 // address pin low (GND), default for InvenSense evaluation board
#include "Simple_MPU6050.h"

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
// AD0 high = 0x69

#define MPU6050_DEFAULT_ADDRESS     0x68 // address pin low (GND), default for InvenSense evaluation board
Simple_MPU6050 mpu;

/* =========================================================================
   NOTE: In addition to connection 5/3.3v, GND, SDA, and SCL, this sketch
   depends on the MPU-6050's INT pin being connected to the ESP8266 GPIO15
   pin.
   ========================================================================= */

// MPU control/status vars
bool dmpReady = false;  // set true if DMP init was successful
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector

// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
// quaternion components in a [w, x, y, z] format (not best for parsing
// on a remote host such as Processing or something though)
//#define OUTPUT_READABLE_QUATERNION

// uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles
// (in degrees) calculated from the quaternions coming from the FIFO.
// Note that Euler angles suffer from gimbal lock (for more info, see
// http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_EULER

// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
// pitch/roll angles (in degrees) calculated from the quaternions coming
// from the FIFO. Note this also requires gravity vector calculations.
// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_YAWPITCHROLL

// uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
// components with gravity removed. This acceleration reference frame is
// not compensated for orientation, so +X is always +X according to the
// sensor, just without the effects of gravity. If you want acceleration
// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.
//#define OUTPUT_READABLE_REALACCEL

// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
// components with gravity removed and adjusted for the world frame of
// reference (yaw is relative to initial orientation, since no magnetometer
// is present in this case). Could be quite handy in some cases.
//#define OUTPUT_READABLE_WORLDACCEL

// uncomment "OUTPUT_TEAPOT_OSC" if you want output that matches the
// format used for the InvenSense teapot demo
#define OUTPUT_TEAPOT_OSC

#ifdef OUTPUT_READABLE_EULER
float euler[3];         // [psi, theta, phi]    Euler angle container
#endif
#ifdef OUTPUT_READABLE_YAWPITCHROLL
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
#endif

#define INTERRUPT_PIN 15 // use pin 15 on ESP8266

const char DEVICE_NAME[] = "mpu6050";

WiFiUDP Udp;                                // A UDP instance to let us send and receive packets over UDP
const IPAddress outIp(192, 168, 0, 242);     // remote IP to receive OSC
const unsigned int outPort = 9999;          // remote port to receive OSC

//================================================================
//===                    Callback Funciton                     ===
//================================================================

// See mpu.on_FIFO(print_Values); in the Setup Loop
void print_Values (int16_t *gyro, int16_t *accel, int32_t *quat, uint32_t *timestamp) {
  Quaternion q;
  VectorFloat gravity;
  float ypr[3] = { 0, 0, 0 };
  float xyz[3] = { 0, 0, 0 };
  mpu.GetQuaternion(&q, quat);
  mpu.GetGravity(&gravity, &q);
  mpu.GetYawPitchRoll(ypr, &q, &gravity);
  mpu.ConvertToDegrees(ypr, xyz);
  static unsigned long SpamTimer;
  if ((millis() - SpamTimer) >= (100)) { // only 10Hz insted of 100Hz
    SpamTimer = millis();
    Serial.print(F("Yaw "));   Serial.print(xyz[0]);   Serial.print(F(",   "));
    Serial.print(F("Pitch ")); Serial.print(xyz[1]);   Serial.print(F(",   "));
    Serial.print(F("Roll "));  Serial.print(xyz[2]);   Serial.print(F(",   "));
    Serial.print(F("ax "));    Serial.print(accel[0]); Serial.print(F(",   "));
    Serial.print(F("ay "));    Serial.print(accel[1]); Serial.print(F(",   "));
    Serial.print(F("az "));    Serial.print(accel[2]); Serial.print(F(",   "));
    Serial.print(F("gx "));    Serial.print(gyro[0]);  Serial.print(F(",   "));
    Serial.print(F("gy "));    Serial.print(gyro[1]);  Serial.print(F(",   "));
    Serial.print(F("gz "));    Serial.print(gyro[2]);  Serial.print(F("\n"));
  }
}

void WiFi_setup() {

  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;
  //reset saved settings
  //wifiManager.resetSettings();

  //fetches ssid and pass from eeprom and tries to connect
  //if it does not connect it starts an access point with the specified name
  //and goes into a blocking loop awaiting configuration
  wifiManager.autoConnect(DEVICE_NAME);

  Serial.print(F("WiFi connected! IP address: "));
  Serial.println(WiFi.localIP());
}
//================================================================
//===                        MPU Setup                         ===
//================================================================
void mpu_setup()
{
  // join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  Wire.begin();
  Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
  // Setup the MPU
   /* Baffeled as to why this next line fails all the time!!! */
 //   mpu.Set_DMP_Output_Rate((uint8_t)0, (uint8_t)19);     // Set the DMP output rate from 200Hz to 5 Minutes.
  /*
     Set the DMP output rate from 200Hz to 5 Minutes!!!
     These are the DMP output rates pre calculated
     #define DMP_200Hz  0x00, 0x00
     #define DMP_100Hz  0x00, 0x01
     #define DMP_50Hz   0x00, 0x03
     #define DMP_40Hz   0x00, 0x04
     #define DMP_25Hz   0x00, 0x07
     #define DMP_20Hz   0x00, 0x09
     #define DMP_10Hz   0x00, 0x13
     #define DMP_5Hz    0x00, 0x27
     #define DMP_1Hz    0x00, 0xC7
     #define DMP_1Sec   0x00, 0xC7
     #define DMP_10Sec  0x07, 0xCF
     #define DMP_60Sec  0x2E, 0xDF
     #define DMP_1Min   0x2E, 0xDF
     #define DMP_5Min   0xEA, 0x5F

     How to Calculate your own
     div = DMP_SAMPLE_RATE / rate_in_Hz - 1;
     div = 200 / rate - 1;
     #define DMP_xxx High Bit,  Low Bit
  */
  mpu.SetAddress(MPU6050_DEFAULT_ADDRESS); //Sets the address of the MPU.
  mpu.CalibrateMPU();                      // Calibrates the MPU.
  mpu.load_DMP_Image();                    // Loads the DMP image into the MPU and finish configuration.
  mpu.on_FIFO(print_Values);               // Set callback function that is triggered when FIFO Data is retrieved
  // Setup is complete!

}
//================================================================
//===                          Setup                           ===
//================================================================
void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("\nOrientation Sensor OSC output")); Serial.println();

  WiFi_setup();
  mpu_setup();
}
//================================================================
//===                        Main Loop                         ===
//================================================================

void loop(void)
{
  if (WiFi.status() != WL_CONNECTED) {
    Serial.println();
    Serial.println("*** Disconnected from AP so rebooting ***");
    Serial.println();
    ESP.reset();
  }
  delay(1); // required to allow the esp8266 to do other things
  mpu.dmp_read_fifo(false); // false = no interrupt pin attachment required.
  // Tests for Data in the FIFO Buffer
  // when it finds data it runs the mpu.on_FIFO(print_Values)
  // functin which we set run the print_Values Function
  // The print_Values function MUST have the following variables available to attach data
  // void print_Values (int16_t *gyro, int16_t *accel, int32_t *quat, uint32_t *timestamp)
  // Variables:
  // int16_t *gyro for the gyro values to be passed to it (The * tells the function it will be a pointer to the value)
  // int16_t *accel for the accel values to be passed to it
  // int32_t *quat for the quaternion values to be passed to it
  // uint32_t *timestamp which will be the micros()value at the time we retrieved the Newest value from the FIFO Buffer.
}

ToDo: I will work on removing the #define interruptPin 2 in the .h file and make it a callback function or something to simplify setup across multiple platforms.

Z

fanlessfan commented 3 years ago

your code @ZHomeSlice is great. It works with both 6050 and 9250 at the same time. and the output is almost the same. Great works.

ZHomeSlice commented 3 years ago

@fanlessfan I just added several examples and now you can adjust the DMP output rate from 200Hz to 5 minutes! Try them out :)